]> git.baikalelectronics.ru Git - kernel.git/commit
io_uring: ensure RCU callback ordering with rcu_barrier()
authorJens Axboe <axboe@kernel.dk>
Mon, 9 Mar 2020 02:07:28 +0000 (20:07 -0600)
committerJens Axboe <axboe@kernel.dk>
Mon, 9 Mar 2020 02:07:28 +0000 (20:07 -0600)
commitf88b452731012bf9dafe08f0cf678f7f06c4ab2a
treec79c1839ac977bc84f7b8f6bed0038bf3f95b8e2
parent57ffe3564d43b0b01b9067be2c077cc9081bb4de
io_uring: ensure RCU callback ordering with rcu_barrier()

After more careful studying, Paul informs me that we cannot rely on
ordering of RCU callbacks in the way that the the tagged commit did.
The current construct looks like this:

void C(struct rcu_head *rhp)
{
do_something(rhp);
call_rcu(&p->rh, B);
}

call_rcu(&p->rh, A);
call_rcu(&p->rh, C);

and we're relying on ordering between A and B, which isn't guaranteed.
Make this explicit instead, and have a work item issue the rcu_barrier()
to ensure that A has run before we manually execute B.

While thorough testing never showed this issue, it's dependent on the
per-cpu load in terms of RCU callbacks. The updated method simplifies
the code as well, and eliminates the need to maintain an rcu_head in
the fileset data.

Fixes: 38e3f7a2a7b5 ("io_uring: free fixed_file_data after RCU grace period")
Reported-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c