Skip to content

Commit 7f8e249

Browse files
author
Jaegeuk Kim
committed
f2fs: introduce F2FS_UNFAIR_RWSEM to support unfair rwsem
Unfair rwsem should be used when blk-cg is on. Otherwise, there is regression. FYI, we noticed a -26.7% regression of aim7.jobs-per-min due to commit: commit: e4544b6 ("f2fs: move f2fs to use reader-unfair rwsems") https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git master in testcase: aim7 on test machine: 88 threads 2 sockets Intel(R) Xeon(R) Gold 6238M CPU @ 2.10GHz with 128G memory with following parameters: disk: 4BRD_12G md: RAID0 fs: f2fs test: sync_disk_rw load: 100 cpufreq_governor: performance ucode: 0x500320a test-description: AIM7 is a traditional UNIX system level benchmark suite which is used to test and measure the performance of multiuser system. test-url: https://sourceforge.net/projects/aimbench/files/aim-suite7/ Reported-by: kernel test robot <oliver.sang@intel.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 50c6300 commit 7f8e249

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

fs/f2fs/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,10 @@ config F2FS_IOSTAT
143143
Support getting IO statistics through sysfs and printing out periodic
144144
IO statistics tracepoint events. You have to turn on "iostat_enable"
145145
sysfs node to enable this feature.
146+
147+
config F2FS_UNFAIR_RWSEM
148+
bool "F2FS unfair rw_semaphore"
149+
depends on F2FS_FS && BLK_CGROUP
150+
help
151+
Use unfair rw_semaphore, if system configured IO priority by block
152+
cgroup.

fs/f2fs/f2fs.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ typedef u32 nid_t;
132132

133133
struct f2fs_rwsem {
134134
struct rw_semaphore internal_rwsem;
135+
#ifdef CONFIG_F2FS_UNFAIR_RWSEM
135136
wait_queue_head_t read_waiters;
137+
#endif
136138
};
137139

138140
struct f2fs_mount_info {
@@ -2131,7 +2133,9 @@ static inline void __init_f2fs_rwsem(struct f2fs_rwsem *sem,
21312133
const char *sem_name, struct lock_class_key *key)
21322134
{
21332135
__init_rwsem(&sem->internal_rwsem, sem_name, key);
2136+
#ifdef CONFIG_F2FS_UNFAIR_RWSEM
21342137
init_waitqueue_head(&sem->read_waiters);
2138+
#endif
21352139
}
21362140

21372141
static inline int f2fs_rwsem_is_locked(struct f2fs_rwsem *sem)
@@ -2146,7 +2150,11 @@ static inline int f2fs_rwsem_is_contended(struct f2fs_rwsem *sem)
21462150

21472151
static inline void f2fs_down_read(struct f2fs_rwsem *sem)
21482152
{
2153+
#ifdef CONFIG_F2FS_UNFAIR_RWSEM
21492154
wait_event(sem->read_waiters, down_read_trylock(&sem->internal_rwsem));
2155+
#else
2156+
down_read(&sem->internal_rwsem);
2157+
#endif
21502158
}
21512159

21522160
static inline int f2fs_down_read_trylock(struct f2fs_rwsem *sem)
@@ -2181,7 +2189,9 @@ static inline int f2fs_down_write_trylock(struct f2fs_rwsem *sem)
21812189
static inline void f2fs_up_write(struct f2fs_rwsem *sem)
21822190
{
21832191
up_write(&sem->internal_rwsem);
2192+
#ifdef CONFIG_F2FS_UNFAIR_RWSEM
21842193
wake_up_all(&sem->read_waiters);
2194+
#endif
21852195
}
21862196

21872197
static inline void f2fs_lock_op(struct f2fs_sb_info *sbi)

0 commit comments

Comments
 (0)