提交 1668533d 编写于 作者: Y Yu Kuai 提交者: Yongqiang Liu

md/raid10: prevent unnecessary calls to wake_up() in fast path

mainline inclusion
from md-next
commit 7fdc91928ac109d3d1468ad7f951deb29a375e3d
category: performance
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I5PRMO
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/song/md.git/commit/?h=md-next&id=7fdc91928ac109d3d1468ad7f951deb29a375e3d

--------------------------------

Currently, wake_up() is called unconditionally in fast path such as
raid10_make_request(), which will cause lock contention under high
concurrency:

raid10_make_request
 wake_up
  __wake_up_common_lock
   spin_lock_irqsave

Improve performance by only call wake_up() if waitqueue is not empty.
Signed-off-by: NYu Kuai <yukuai3@huawei.com>
Reviewed-by: NLogan Gunthorpe <logang@deltatee.com>
Acked-by: NGuoqing Jiang <guoqing.jiang@linux.dev>
Signed-off-by: NSong Liu <song@kernel.org>
Reviewed-by: NJason Yan <yanaijie@huawei.com>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
上级 f25ff47b
...@@ -305,6 +305,12 @@ static void put_buf(struct r10bio *r10_bio) ...@@ -305,6 +305,12 @@ static void put_buf(struct r10bio *r10_bio)
lower_barrier(conf); lower_barrier(conf);
} }
static void wake_up_barrier(struct r10conf *conf)
{
if (wq_has_sleeper(&conf->wait_barrier))
wake_up(&conf->wait_barrier);
}
static void reschedule_retry(struct r10bio *r10_bio) static void reschedule_retry(struct r10bio *r10_bio)
{ {
unsigned long flags; unsigned long flags;
...@@ -1025,7 +1031,7 @@ static void allow_barrier(struct r10conf *conf) ...@@ -1025,7 +1031,7 @@ static void allow_barrier(struct r10conf *conf)
{ {
if ((atomic_dec_and_test(&conf->nr_pending)) || if ((atomic_dec_and_test(&conf->nr_pending)) ||
(conf->array_freeze_pending)) (conf->array_freeze_pending))
wake_up(&conf->wait_barrier); wake_up_barrier(conf);
} }
static void freeze_array(struct r10conf *conf, int extra) static void freeze_array(struct r10conf *conf, int extra)
...@@ -1584,7 +1590,7 @@ static bool raid10_make_request(struct mddev *mddev, struct bio *bio) ...@@ -1584,7 +1590,7 @@ static bool raid10_make_request(struct mddev *mddev, struct bio *bio)
__make_request(mddev, bio, sectors); __make_request(mddev, bio, sectors);
/* In case raid10d snuck in to freeze_array */ /* In case raid10d snuck in to freeze_array */
wake_up(&conf->wait_barrier); wake_up_barrier(conf);
return true; return true;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册