* [PATCH] block: cleanup the VM accounting in submit_bio
@ 2022-05-16 6:36 Christoph Hellwig
2022-05-16 12:38 ` Jens Axboe
2022-05-16 13:45 ` Damien Le Moal
0 siblings, 2 replies; 5+ messages in thread
From: Christoph Hellwig @ 2022-05-16 6:36 UTC (permalink / raw)
To: axboe; +Cc: linux-block
submit_bio uses some extremely convoluted checks and confusing comments
to only account REQ_OP_READ/REQ_OP_WRITE comments. Just switch to the
plain obvious checks instead.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-core.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/block/blk-core.c b/block/blk-core.c
index ee18b6a699bdf..48a58c24d452e 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -893,19 +893,11 @@ void submit_bio(struct bio *bio)
if (blkcg_punt_bio_submit(bio))
return;
- /*
- * If it's a regular read/write or a barrier with data attached,
- * go through the normal accounting stuff before submission.
- */
- if (bio_has_data(bio)) {
- unsigned int count = bio_sectors(bio);
-
- if (op_is_write(bio_op(bio))) {
- count_vm_events(PGPGOUT, count);
- } else {
- task_io_account_read(bio->bi_iter.bi_size);
- count_vm_events(PGPGIN, count);
- }
+ if (bio_op(bio) == REQ_OP_READ) {
+ task_io_account_read(bio->bi_iter.bi_size);
+ count_vm_events(PGPGIN, bio_sectors(bio));
+ } else if (bio_op(bio) == WRITE) {
+ count_vm_events(PGPGOUT, bio_sectors(bio));
}
/*
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] block: cleanup the VM accounting in submit_bio
2022-05-16 6:36 [PATCH] block: cleanup the VM accounting in submit_bio Christoph Hellwig
@ 2022-05-16 12:38 ` Jens Axboe
2022-05-16 13:45 ` Damien Le Moal
1 sibling, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2022-05-16 12:38 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-block
On Mon, 16 May 2022 08:36:54 +0200, Christoph Hellwig wrote:
> submit_bio uses some extremely convoluted checks and confusing comments
> to only account REQ_OP_READ/REQ_OP_WRITE comments. Just switch to the
> plain obvious checks instead.
>
>
Applied, thanks!
[1/1] block: cleanup the VM accounting in submit_bio
commit: b1ec1bae3b425e145e134fd63347576c478b85db
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] block: cleanup the VM accounting in submit_bio
2022-05-16 6:36 [PATCH] block: cleanup the VM accounting in submit_bio Christoph Hellwig
2022-05-16 12:38 ` Jens Axboe
@ 2022-05-16 13:45 ` Damien Le Moal
2022-05-16 14:11 ` Christoph Hellwig
1 sibling, 1 reply; 5+ messages in thread
From: Damien Le Moal @ 2022-05-16 13:45 UTC (permalink / raw)
To: Christoph Hellwig, axboe; +Cc: linux-block
On 2022/05/16 8:36, Christoph Hellwig wrote:
> submit_bio uses some extremely convoluted checks and confusing comments
> to only account REQ_OP_READ/REQ_OP_WRITE comments. Just switch to the
> plain obvious checks instead.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-core.c | 18 +++++-------------
> 1 file changed, 5 insertions(+), 13 deletions(-)
>
> diff --git a/block/blk-core.c b/block/blk-core.c
> index ee18b6a699bdf..48a58c24d452e 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -893,19 +893,11 @@ void submit_bio(struct bio *bio)
> if (blkcg_punt_bio_submit(bio))
> return;
>
> - /*
> - * If it's a regular read/write or a barrier with data attached,
> - * go through the normal accounting stuff before submission.
> - */
> - if (bio_has_data(bio)) {
> - unsigned int count = bio_sectors(bio);
> -
> - if (op_is_write(bio_op(bio))) {
> - count_vm_events(PGPGOUT, count);
> - } else {
> - task_io_account_read(bio->bi_iter.bi_size);
> - count_vm_events(PGPGIN, count);
> - }
> + if (bio_op(bio) == REQ_OP_READ) {
> + task_io_account_read(bio->bi_iter.bi_size);
> + count_vm_events(PGPGIN, bio_sectors(bio));
> + } else if (bio_op(bio) == WRITE) {
I know it is the same value, but for consistency, wouldn't it be better to use
REQ_OP_WRITE here ?
> + count_vm_events(PGPGOUT, bio_sectors(bio));
> }
>
> /*
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] block: cleanup the VM accounting in submit_bio
2022-05-16 13:45 ` Damien Le Moal
@ 2022-05-16 14:11 ` Christoph Hellwig
2022-05-16 17:37 ` Jens Axboe
0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2022-05-16 14:11 UTC (permalink / raw)
To: Damien Le Moal; +Cc: Christoph Hellwig, axboe, linux-block
On Mon, May 16, 2022 at 03:45:08PM +0200, Damien Le Moal wrote:
> I know it is the same value, but for consistency, wouldn't it be better to use
> REQ_OP_WRITE here ?
Yes, it absolutely would. The use of WRITE wasn't even initentional.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] block: cleanup the VM accounting in submit_bio
2022-05-16 14:11 ` Christoph Hellwig
@ 2022-05-16 17:37 ` Jens Axboe
0 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2022-05-16 17:37 UTC (permalink / raw)
To: Christoph Hellwig, Damien Le Moal; +Cc: linux-block
On 5/16/22 8:11 AM, Christoph Hellwig wrote:
> On Mon, May 16, 2022 at 03:45:08PM +0200, Damien Le Moal wrote:
>> I know it is the same value, but for consistency, wouldn't it be better to use
>> REQ_OP_WRITE here ?
>
> Yes, it absolutely would. The use of WRITE wasn't even initentional.
I'll fix it up.
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-05-16 17:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-16 6:36 [PATCH] block: cleanup the VM accounting in submit_bio Christoph Hellwig
2022-05-16 12:38 ` Jens Axboe
2022-05-16 13:45 ` Damien Le Moal
2022-05-16 14:11 ` Christoph Hellwig
2022-05-16 17:37 ` Jens Axboe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.