Skip to content

Commit b4f937c

Browse files
trondmypdamschuma-ntap
authored andcommitted
NFS: Don't run wake_up_bit() when nobody is waiting...
"perf lock" shows fairly heavy contention for the bit waitqueue locks when doing an I/O heavy workload. Use a bit to tell whether or not there has been contention for a lock so that we can optimise away the bit waitqueue options in those cases. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent 20fa190 commit b4f937c

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎fs/nfs/pagelist.c‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,12 @@ nfs_page_group_lock(struct nfs_page *req, bool nonblock)
155155
if (!test_and_set_bit(PG_HEADLOCK, &head->wb_flags))
156156
return 0;
157157

158-
if (!nonblock)
158+
if (!nonblock) {
159+
set_bit(PG_CONTENDED1, &head->wb_flags);
160+
smp_mb__after_atomic();
159161
return wait_on_bit_lock(&head->wb_flags, PG_HEADLOCK,
160162
TASK_UNINTERRUPTIBLE);
163+
}
161164

162165
return -EAGAIN;
163166
}
@@ -175,6 +178,10 @@ nfs_page_group_lock_wait(struct nfs_page *req)
175178

176179
WARN_ON_ONCE(head != head->wb_head);
177180

181+
if (!test_bit(PG_HEADLOCK, &head->wb_flags))
182+
return;
183+
set_bit(PG_CONTENDED1, &head->wb_flags);
184+
smp_mb__after_atomic();
178185
wait_on_bit(&head->wb_flags, PG_HEADLOCK,
179186
TASK_UNINTERRUPTIBLE);
180187
}
@@ -193,6 +200,8 @@ nfs_page_group_unlock(struct nfs_page *req)
193200
smp_mb__before_atomic();
194201
clear_bit(PG_HEADLOCK, &head->wb_flags);
195202
smp_mb__after_atomic();
203+
if (!test_bit(PG_CONTENDED1, &head->wb_flags))
204+
return;
196205
wake_up_bit(&head->wb_flags, PG_HEADLOCK);
197206
}
198207

@@ -383,6 +392,8 @@ void nfs_unlock_request(struct nfs_page *req)
383392
smp_mb__before_atomic();
384393
clear_bit(PG_BUSY, &req->wb_flags);
385394
smp_mb__after_atomic();
395+
if (!test_bit(PG_CONTENDED2, &req->wb_flags))
396+
return;
386397
wake_up_bit(&req->wb_flags, PG_BUSY);
387398
}
388399

@@ -465,6 +476,10 @@ void nfs_release_request(struct nfs_page *req)
465476
int
466477
nfs_wait_on_request(struct nfs_page *req)
467478
{
479+
if (!test_bit(PG_BUSY, &req->wb_flags))
480+
return 0;
481+
set_bit(PG_CONTENDED2, &req->wb_flags);
482+
smp_mb__after_atomic();
468483
return wait_on_bit_io(&req->wb_flags, PG_BUSY,
469484
TASK_UNINTERRUPTIBLE);
470485
}

‎include/linux/nfs_page.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ enum {
3333
PG_UPTODATE, /* page group sync bit in read path */
3434
PG_WB_END, /* page group sync bit in write path */
3535
PG_REMOVE, /* page group sync bit in write path */
36+
PG_CONTENDED1, /* Is someone waiting for a lock? */
37+
PG_CONTENDED2, /* Is someone waiting for a lock? */
3638
};
3739

3840
struct nfs_inode;

0 commit comments

Comments
 (0)