From: Christoph Hellwig <hch@lst.de> To: Jens Axboe <axboe@kernel.dk> Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>, Minchan Kim <minchan@kernel.org>, Nitin Gupta <ngupta@vflare.org>, dm-devel@redhat.com, linux-block@vger.kernel.org, drbd-dev@lists.linbit.com, linux-bcache@vger.kernel.org, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Subject: [PATCH 16/16] block: reduce part_stat_lock() scope Date: Mon, 25 May 2020 13:30:14 +0200 [thread overview] Message-ID: <20200525113014.345997-17-hch@lst.de> (raw) In-Reply-To: <20200525113014.345997-1-hch@lst.de> We only need the stats lock (aka preempt_disable()) for updating the states, not for looking up or dropping the hd_struct reference. Signed-off-by: Christoph Hellwig <hch@lst.de> --- block/blk-core.c | 5 +++-- block/blk-merge.c | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index bf2f7d4bc0c1c..a01fb2b508f0e 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1437,9 +1437,9 @@ void blk_account_io_done(struct request *req, u64 now) update_io_ticks(part, jiffies, true); part_stat_inc(part, ios[sgrp]); part_stat_add(part, nsecs[sgrp], now - req->start_time_ns); + part_stat_unlock(); hd_struct_put(part); - part_stat_unlock(); } } @@ -1448,8 +1448,9 @@ void blk_account_io_start(struct request *rq) if (!blk_do_io_stat(rq)) return; - part_stat_lock(); rq->part = disk_map_sector_rcu(rq->rq_disk, blk_rq_pos(rq)); + + part_stat_lock(); update_io_ticks(rq->part, jiffies, false); part_stat_unlock(); } diff --git a/block/blk-merge.c b/block/blk-merge.c index c3beae5c1be71..f0b0bae075a0c 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -674,8 +674,9 @@ static void blk_account_io_merge_request(struct request *req) if (blk_do_io_stat(req)) { part_stat_lock(); part_stat_inc(req->part, merges[op_stat_group(req_op(req))]); - hd_struct_put(req->part); part_stat_unlock(); + + hd_struct_put(req->part); } } -- 2.26.2 _______________________________________________ Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org To unsubscribe send an email to linux-nvdimm-leave@lists.01.org
WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de> To: Jens Axboe <axboe@kernel.dk> Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>, Minchan Kim <minchan@kernel.org>, Nitin Gupta <ngupta@vflare.org>, dm-devel@redhat.com, linux-block@vger.kernel.org, drbd-dev@lists.linbit.com, linux-bcache@vger.kernel.org, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Subject: [PATCH 16/16] block: reduce part_stat_lock() scope Date: Mon, 25 May 2020 13:30:14 +0200 [thread overview] Message-ID: <20200525113014.345997-17-hch@lst.de> (raw) In-Reply-To: <20200525113014.345997-1-hch@lst.de> We only need the stats lock (aka preempt_disable()) for updating the states, not for looking up or dropping the hd_struct reference. Signed-off-by: Christoph Hellwig <hch@lst.de> --- block/blk-core.c | 5 +++-- block/blk-merge.c | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index bf2f7d4bc0c1c..a01fb2b508f0e 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1437,9 +1437,9 @@ void blk_account_io_done(struct request *req, u64 now) update_io_ticks(part, jiffies, true); part_stat_inc(part, ios[sgrp]); part_stat_add(part, nsecs[sgrp], now - req->start_time_ns); + part_stat_unlock(); hd_struct_put(part); - part_stat_unlock(); } } @@ -1448,8 +1448,9 @@ void blk_account_io_start(struct request *rq) if (!blk_do_io_stat(rq)) return; - part_stat_lock(); rq->part = disk_map_sector_rcu(rq->rq_disk, blk_rq_pos(rq)); + + part_stat_lock(); update_io_ticks(rq->part, jiffies, false); part_stat_unlock(); } diff --git a/block/blk-merge.c b/block/blk-merge.c index c3beae5c1be71..f0b0bae075a0c 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -674,8 +674,9 @@ static void blk_account_io_merge_request(struct request *req) if (blk_do_io_stat(req)) { part_stat_lock(); part_stat_inc(req->part, merges[op_stat_group(req_op(req))]); - hd_struct_put(req->part); part_stat_unlock(); + + hd_struct_put(req->part); } } -- 2.26.2
next prev parent reply other threads:[~2020-05-25 11:31 UTC|newest] Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-25 11:29 block I/O accounting improvements Christoph Hellwig 2020-05-25 11:29 ` Christoph Hellwig 2020-05-25 11:29 ` [PATCH 01/16] block: add disk/bio-based accounting helpers Christoph Hellwig 2020-05-25 11:29 ` Christoph Hellwig 2020-05-25 12:28 ` Konstantin Khlebnikov 2020-05-27 5:23 ` Christoph Hellwig 2020-05-27 5:23 ` Christoph Hellwig 2020-05-27 5:23 ` Christoph Hellwig 2020-05-25 11:30 ` [PATCH 02/16] drbd: use bio_{start,end}_io_acct Christoph Hellwig 2020-05-25 11:30 ` Christoph Hellwig 2020-05-25 11:30 ` [PATCH 03/16] rsxx: " Christoph Hellwig 2020-05-25 11:30 ` Christoph Hellwig 2020-05-25 11:30 ` [PATCH 04/16] lightnvm/pblk: " Christoph Hellwig 2020-05-25 11:30 ` Christoph Hellwig 2020-05-25 11:30 ` [PATCH 05/16] bcache: " Christoph Hellwig 2020-05-25 11:30 ` Christoph Hellwig 2020-05-25 13:03 ` Coly Li 2020-05-25 13:03 ` Coly Li 2020-05-25 11:30 ` [PATCH 06/16] dm: " Christoph Hellwig 2020-05-25 11:30 ` Christoph Hellwig 2020-05-25 11:30 ` [PATCH 07/16] nvdimm: " Christoph Hellwig 2020-05-25 11:30 ` Christoph Hellwig 2020-05-25 11:30 ` [PATCH 08/16] zram: nvdimm: use bio_{start,end}_io_acct and disk_{start,end}_io_acct Christoph Hellwig 2020-05-25 11:30 ` Christoph Hellwig 2020-05-25 11:30 ` [PATCH 09/16] block: remove generic_{start,end}_io_acct Christoph Hellwig 2020-05-25 11:30 ` Christoph Hellwig 2020-05-25 11:30 ` [PATCH 10/16] block: move update_io_ticks to blk-core.c Christoph Hellwig 2020-05-25 11:30 ` Christoph Hellwig 2020-05-25 11:30 ` [PATCH 11/16] block: always use a percpu variable for disk stats Christoph Hellwig 2020-05-25 11:30 ` Christoph Hellwig 2020-05-25 11:30 ` [PATCH 12/16] block: account merge of two requests Christoph Hellwig 2020-05-25 11:30 ` Christoph Hellwig 2020-05-25 11:30 ` [PATCH 13/16] block: add a blk_account_io_merge_bio helper Christoph Hellwig 2020-05-25 11:30 ` Christoph Hellwig 2020-05-25 11:30 ` [PATCH 14/16] block: remove rcu_read_lock() from part_stat_lock() Christoph Hellwig 2020-05-25 11:30 ` Christoph Hellwig 2020-05-25 11:30 ` [PATCH 15/16] block: use __this_cpu_add() instead of access by smp_processor_id() Christoph Hellwig 2020-05-25 11:30 ` Christoph Hellwig 2020-05-25 11:30 ` Christoph Hellwig [this message] 2020-05-25 11:30 ` [PATCH 16/16] block: reduce part_stat_lock() scope Christoph Hellwig 2020-05-25 12:34 ` block I/O accounting improvements Konstantin Khlebnikov 2020-05-27 5:24 block I/O accounting improvements v2 Christoph Hellwig 2020-05-27 5:24 ` [PATCH 16/16] block: reduce part_stat_lock() scope Christoph Hellwig 2020-05-27 5:24 ` Christoph Hellwig
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200525113014.345997-17-hch@lst.de \ --to=hch@lst.de \ --cc=axboe@kernel.dk \ --cc=dm-devel@redhat.com \ --cc=drbd-dev@lists.linbit.com \ --cc=khlebnikov@yandex-team.ru \ --cc=linux-bcache@vger.kernel.org \ --cc=linux-block@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-nvdimm@lists.01.org \ --cc=minchan@kernel.org \ --cc=ngupta@vflare.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.