Message ID | 20240111160226.1936351-3-axboe@kernel.dk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Integrity cleanups and optimization | expand |
On Thu, Jan 11, 2024 at 09:00:20AM -0700, Jens Axboe wrote: > Now that we don't set a dummy profile, if someone registers and actual > profile, flag the queue as such. > > Signed-off-by: Jens Axboe <axboe@kernel.dk> > --- > block/blk-integrity.c | 14 +++++++++----- > include/linux/blkdev.h | 1 + > 2 files changed, 10 insertions(+), 5 deletions(-) > > diff --git a/block/blk-integrity.c b/block/blk-integrity.c > index a1ea1794c7c8..974af93de2da 100644 > --- a/block/blk-integrity.c > +++ b/block/blk-integrity.c > @@ -339,22 +339,25 @@ const struct attribute_group blk_integrity_attr_group = { > */ > void blk_integrity_register(struct gendisk *disk, struct blk_integrity *template) > { > - struct blk_integrity *bi = &disk->queue->integrity; > + struct request_queue *q = disk->queue; > + struct blk_integrity *bi = &q->integrity; > > bi->flags = BLK_INTEGRITY_VERIFY | BLK_INTEGRITY_GENERATE | > template->flags; > bi->interval_exp = template->interval_exp ? : > - ilog2(queue_logical_block_size(disk->queue)); > + ilog2(queue_logical_block_size(q)); > bi->profile = template->profile; > + if (bi->profile) > + blk_queue_flag_set(QUEUE_FLAG_INTG_PROFILE, q); Is this really so much better vs just checking for bi->profile being non-NULL?
On 1/11/24 9:06 AM, Christoph Hellwig wrote: > On Thu, Jan 11, 2024 at 09:00:20AM -0700, Jens Axboe wrote: >> Now that we don't set a dummy profile, if someone registers and actual >> profile, flag the queue as such. >> >> Signed-off-by: Jens Axboe <axboe@kernel.dk> >> --- >> block/blk-integrity.c | 14 +++++++++----- >> include/linux/blkdev.h | 1 + >> 2 files changed, 10 insertions(+), 5 deletions(-) >> >> diff --git a/block/blk-integrity.c b/block/blk-integrity.c >> index a1ea1794c7c8..974af93de2da 100644 >> --- a/block/blk-integrity.c >> +++ b/block/blk-integrity.c >> @@ -339,22 +339,25 @@ const struct attribute_group blk_integrity_attr_group = { >> */ >> void blk_integrity_register(struct gendisk *disk, struct blk_integrity *template) >> { >> - struct blk_integrity *bi = &disk->queue->integrity; >> + struct request_queue *q = disk->queue; >> + struct blk_integrity *bi = &q->integrity; >> >> bi->flags = BLK_INTEGRITY_VERIFY | BLK_INTEGRITY_GENERATE | >> template->flags; >> bi->interval_exp = template->interval_exp ? : >> - ilog2(queue_logical_block_size(disk->queue)); >> + ilog2(queue_logical_block_size(q)); >> bi->profile = template->profile; >> + if (bi->profile) >> + blk_queue_flag_set(QUEUE_FLAG_INTG_PROFILE, q); > > Is this really so much better vs just checking for bi->profile > being non-NULL? Before we can check that, we have to load bio->bi_bdev->bd_disk->queue->integrity, and we have to call in to bio_integrity_prep() as well needlessly. We could do that in patch 3 and then we just need to load q->integrity->profile, and while queue_flags is certainly hot, it's probably not a huge deal to load that cacheline. I think if we do that, we stick integrity before limits. I can make that change, and then we can drop the flag.
On Thu, Jan 11, 2024 at 09:16:42AM -0700, Jens Axboe wrote: > Before we can check that, we have to load > bio->bi_bdev->bd_disk->queue->integrity, and we have to call in to > bio_integrity_prep() as well needlessly. We could do that in patch 3 and > then we just need to load q->integrity->profile, and while queue_flags > is certainly hot, it's probably not a huge deal to load that cacheline. > I think if we do that, we stick integrity before limits. > > I can make that change, and then we can drop the flag. If this is good enough in your benchmarks I'd prefer that over adding a redundant flag.
diff --git a/block/blk-integrity.c b/block/blk-integrity.c index a1ea1794c7c8..974af93de2da 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -339,22 +339,25 @@ const struct attribute_group blk_integrity_attr_group = { */ void blk_integrity_register(struct gendisk *disk, struct blk_integrity *template) { - struct blk_integrity *bi = &disk->queue->integrity; + struct request_queue *q = disk->queue; + struct blk_integrity *bi = &q->integrity; bi->flags = BLK_INTEGRITY_VERIFY | BLK_INTEGRITY_GENERATE | template->flags; bi->interval_exp = template->interval_exp ? : - ilog2(queue_logical_block_size(disk->queue)); + ilog2(queue_logical_block_size(q)); bi->profile = template->profile; + if (bi->profile) + blk_queue_flag_set(QUEUE_FLAG_INTG_PROFILE, q); bi->tuple_size = template->tuple_size; bi->tag_size = template->tag_size; - blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, disk->queue); + blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, q); #ifdef CONFIG_BLK_INLINE_ENCRYPTION - if (disk->queue->crypto_profile) { + if (q->crypto_profile) { pr_warn("blk-integrity: Integrity and hardware inline encryption are not supported together. Disabling hardware inline encryption.\n"); - disk->queue->crypto_profile = NULL; + q->crypto_profile = NULL; } #endif } @@ -377,6 +380,7 @@ void blk_integrity_unregister(struct gendisk *disk) /* ensure all bios are off the integrity workqueue */ blk_flush_integrity(); blk_queue_flag_clear(QUEUE_FLAG_STABLE_WRITES, disk->queue); + blk_queue_flag_clear(QUEUE_FLAG_INTG_PROFILE, disk->queue); memset(bi, 0, sizeof(*bi)); } EXPORT_SYMBOL(blk_integrity_unregister); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index e1e705aef51e..de81642831bb 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -510,6 +510,7 @@ struct request_queue { /* Keep blk_queue_flag_name[] in sync with the definitions below */ #define QUEUE_FLAG_STOPPED 0 /* queue is stopped */ #define QUEUE_FLAG_DYING 1 /* queue being torn down */ +#define QUEUE_FLAG_INTG_PROFILE 2 /* has integrity profile */ #define QUEUE_FLAG_NOMERGES 3 /* disable merge attempts */ #define QUEUE_FLAG_SAME_COMP 4 /* complete on same CPU-group */ #define QUEUE_FLAG_FAIL_IO 5 /* fake timeout */
Now that we don't set a dummy profile, if someone registers and actual profile, flag the queue as such. Signed-off-by: Jens Axboe <axboe@kernel.dk> --- block/blk-integrity.c | 14 +++++++++----- include/linux/blkdev.h | 1 + 2 files changed, 10 insertions(+), 5 deletions(-)