Skip to content

Commit 2ca97ac

Browse files
a-darwishPeter Zijlstra
authored andcommitted
userfaultfd: Use sequence counter with associated spinlock
A sequence counter write side critical section must be protected by some form of locking to serialize writers. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_spinlock_t data type, which allows to associate a spinlock with the sequence counter. This enables lockdep to verify that the spinlock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 76246c9 commit 2ca97ac

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/userfaultfd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct userfaultfd_ctx {
6161
/* waitqueue head for events */
6262
wait_queue_head_t event_wqh;
6363
/* a refile sequence protected by fault_pending_wqh lock */
64-
struct seqcount refile_seq;
64+
seqcount_spinlock_t refile_seq;
6565
/* pseudo fd refcounting */
6666
refcount_t refcount;
6767
/* userfaultfd syscall flags */
@@ -1998,7 +1998,7 @@ static void init_once_userfaultfd_ctx(void *mem)
19981998
init_waitqueue_head(&ctx->fault_wqh);
19991999
init_waitqueue_head(&ctx->event_wqh);
20002000
init_waitqueue_head(&ctx->fd_wqh);
2001-
seqcount_init(&ctx->refile_seq);
2001+
seqcount_spinlock_init(&ctx->refile_seq, &ctx->fault_pending_wqh.lock);
20022002
}
20032003

20042004
SYSCALL_DEFINE1(userfaultfd, int, flags)

0 commit comments

Comments
 (0)