From: Yufen Yu <yuyufen@huawei.com>
To: "houtao (A)" <houtao1@huawei.com>, "axboe@kernel.dk" <axboe@kernel.dk>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"ming.lei@redhat.com" <ming.lei@redhat.com>,
"hch@lst.de" <hch@lst.de>, zhengchuan <zhengchuan@huawei.com>,
"zhangyi (F)" <yi.zhang@huawei.com>,
"paulmck@kernel.org" <paulmck@kernel.org>,
"joel@joelfernandes.org" <joel@joelfernandes.org>,
"rcu@vger.kernel.org" <rcu@vger.kernel.org>
Subject: Re: [PATCH] block: make sure last_lookup set as NULL after part deleted
Date: Fri, 3 Jan 2020 20:43:11 +0800 [thread overview]
Message-ID: <5cc465cc-d68c-088e-0729-2695279c7853@huawei.com> (raw)
In-Reply-To: <a9ce86d6-dadb-9301-7d76-8cef81d782fd@huawei.com>
On 2019/12/31 22:55, houtao (A) wrote:
> diff --git a/block/genhd.c b/block/genhd.c
> index 6e8543ca6912..179e0056fae1 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -279,7 +279,14 @@ struct hd_struct *disk_map_sector_rcu(struct gendisk *disk, sector_t sector)
> part = rcu_dereference(ptbl->part[i]);
>
> if (part && sector_in_part(part, sector)) {
> - rcu_assign_pointer(ptbl->last_lookup, part);
> + struct hd_struct *old;
> +
> + if (!hd_struct_try_get(part))
> + break;
> +
> + old = xchg(&ptbl->last_lookup, part);
> + if (old)
> + hd_struct_put(old);
> return part;
> }
> }
> @@ -1231,7 +1238,11 @@ static void disk_replace_part_tbl(struct gendisk *disk,
> rcu_assign_pointer(disk->part_tbl, new_ptbl);
>
> if (old_ptbl) {
> - rcu_assign_pointer(old_ptbl->last_lookup, NULL);
> + struct hd_struct *part;
> +
> + part = xchg(&old_ptbl->last_lookup, NULL);
> + if (part)
> + hd_struct_put(part);
> kfree_rcu(old_ptbl, rcu_head);
> }
> }
> diff --git a/block/partition-generic.c b/block/partition-generic.c
> index 98d60a59b843..441c1c591c04 100644
> --- a/block/partition-generic.c
> +++ b/block/partition-generic.c
> @@ -285,7 +285,8 @@ void delete_partition(struct gendisk *disk, int partno)
> return;
>
> rcu_assign_pointer(ptbl->part[partno], NULL);
> - rcu_assign_pointer(ptbl->last_lookup, NULL);
> + if (cmpxchg(&ptbl->last_lookup, part, NULL) == part)
> + hd_struct_put(part);
> kobject_put(part->holder_dir);
> device_del(part_to_dev(part));
>
This change will add more calling of hd_struct_try_get()/hd_struct_put()
when set last_lookup. Thus, Tao warried abort extra overhead.
We test the patch on a SSD disk by fio with config:
[global]
rw=randread
bs=4k
numjobs=2
ioengine=libaio
iodepth=32
direct=1
runtime=120
size=100G
group_reporting
time_based
[sda1]
filename=/dev/sda1
[sda2]
filename=/dev/sda2
[sda3]
filename=/dev/sda3
[sda4]
filename=/dev/sda4
Compared with the previous version, io bandwidth have no any degeneration.
Thanks,
Yufen
prev parent reply other threads:[~2020-01-03 12:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20191231110945.10857-1-yuyufen@huawei.com>
2019-12-31 14:55 ` [PATCH] block: make sure last_lookup set as NULL after part deleted Hou Tao
2019-12-31 23:11 ` Paul E. McKenney
2020-01-01 2:33 ` htbegin
2020-01-01 3:39 ` htbegin
2020-01-03 23:45 ` Joel Fernandes
2020-01-04 9:16 ` Hou Tao
2020-01-02 1:23 ` Ming Lei
2020-01-03 3:06 ` Hou Tao
2020-01-03 4:18 ` Ming Lei
2020-01-03 7:35 ` Hou Tao
2020-01-03 8:17 ` Ming Lei
2020-01-03 12:03 ` Yufen Yu
2020-01-03 15:16 ` Ming Lei
2020-01-06 7:39 ` Yufen Yu
2020-01-06 8:11 ` Ming Lei
2020-01-06 9:41 ` Hou Tao
2020-01-06 10:05 ` Ming Lei
2020-01-07 11:40 ` Hou Tao
2020-01-08 3:19 ` Ming Lei
2020-01-03 12:43 ` Yufen Yu [this message]
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=5cc465cc-d68c-088e-0729-2695279c7853@huawei.com \
--to=yuyufen@huawei.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=houtao1@huawei.com \
--cc=joel@joelfernandes.org \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=paulmck@kernel.org \
--cc=rcu@vger.kernel.org \
--cc=yi.zhang@huawei.com \
--cc=zhengchuan@huawei.com \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).