Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fc13457f authored by Jens Axboe's avatar Jens Axboe
Browse files

blk-mq: document the need to have STARTED and COMPLETED share a byte



For memory ordering guarantees on stores, we need to ensure that
these two bits share the same byte of storage in the unsigned
long. Add a comment as to why, and a BUILD_BUG_ON() to ensure that
we don't violate this requirement.

Suggested-by: default avatarBoqun Feng <boqun.feng@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent a7af0af3
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2923,6 +2923,12 @@ EXPORT_SYMBOL_GPL(blk_mq_poll);

static int __init blk_mq_init(void)
{
	/*
	 * See comment in block/blk.h rq_atomic_flags enum
	 */
	BUILD_BUG_ON((REQ_ATOM_STARTED / BITS_PER_BYTE) !=
			(REQ_ATOM_COMPLETE / BITS_PER_BYTE));

	cpuhp_setup_state_multi(CPUHP_BLK_MQ_DEAD, "block/mq:dead", NULL,
				blk_mq_hctx_notify_dead);
	return 0;
+7 −0
Original line number Diff line number Diff line
@@ -122,8 +122,15 @@ void blk_account_io_done(struct request *req);
 * Internal atomic flags for request handling
 */
enum rq_atomic_flags {
	/*
	 * Keep these two bits first - not because we depend on the
	 * value of them, but we do depend on them being in the same
	 * byte of storage to ensure ordering on writes. Keeping them
	 * first will achieve that nicely.
	 */
	REQ_ATOM_COMPLETE = 0,
	REQ_ATOM_STARTED,

	REQ_ATOM_POLL_SLEPT,
};