]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
blktrace: re-write setting q->blk_trace
authorDavidlohr Bueso <dave@stgolabs.ne>
Thu, 29 Oct 2015 20:25:59 +0000 (05:25 +0900)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 28 Apr 2020 18:03:37 +0000 (19:03 +0100)
commit12b91f8bd81a4e97c86bbf4ebbec35fec7c33dce
tree0530536cce593573306935db01901655696080dc
parentc3ad4536984df3869f42144a1449e9f27f42e524
blktrace: re-write setting q->blk_trace

commit cdea01b2bf98affb7e9c44530108a4a28535eee8 upstream.

This is really about simplifying the double xchg patterns into
a single cmpxchg, with the same logic. Other than the immediate
cleanup, there are some subtleties this change deals with:

(i) While the load of the old bt is fully ordered wrt everything,
ie:

        old_bt = xchg(&q->blk_trace, bt);             [barrier]
        if (old_bt)
     (void) xchg(&q->blk_trace, old_bt);    [barrier]

blk_trace could still be changed between the xchg and the old_bt
load. Note that this description is merely theoretical and afaict
very small, but doing everything in a single context with cmpxchg
closes this potential race.

(ii) Ordering guarantees are obviously kept with cmpxchg.

(iii) Gets rid of the hacky-by-nature (void)xchg pattern.

Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
eviewed-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
kernel/trace/blktrace.c