From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: axboe@kernel.dk, tj@kernel.org
Cc: baolin.wang@linux.alibaba.com, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] blk-iocost: Use alloc_percpu_gfp() to simplify the code
Date: Thu, 10 Dec 2020 18:56:45 +0800 [thread overview]
Message-ID: <aa518c5b5c7185e660a1c8515c10d9513fe92132.1607591591.git.baolin.wang@linux.alibaba.com> (raw)
In-Reply-To: <1ba7a38d5a6186b1e71432ef424c23ba1904a365.1607591591.git.baolin.wang@linux.alibaba.com>
In-Reply-To: <1ba7a38d5a6186b1e71432ef424c23ba1904a365.1607591591.git.baolin.wang@linux.alibaba.com>
Use alloc_percpu_gfp() with __GFP_ZERO flag, which can remove
some explicit initialization code.
Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
block/blk-iocost.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index ac6078a..52ce2e3 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -2819,28 +2819,19 @@ static int blk_iocost_init(struct request_queue *q)
{
struct ioc *ioc;
struct rq_qos *rqos;
- int i, cpu, ret;
+ int ret;
+ gfp_t gfp = GFP_KERNEL | __GFP_ZERO;
ioc = kzalloc(sizeof(*ioc), GFP_KERNEL);
if (!ioc)
return -ENOMEM;
- ioc->pcpu_stat = alloc_percpu(struct ioc_pcpu_stat);
+ ioc->pcpu_stat = alloc_percpu_gfp(struct ioc_pcpu_stat, gfp);
if (!ioc->pcpu_stat) {
kfree(ioc);
return -ENOMEM;
}
- for_each_possible_cpu(cpu) {
- struct ioc_pcpu_stat *ccs = per_cpu_ptr(ioc->pcpu_stat, cpu);
-
- for (i = 0; i < ARRAY_SIZE(ccs->missed); i++) {
- local_set(&ccs->missed[i].nr_met, 0);
- local_set(&ccs->missed[i].nr_missed, 0);
- }
- local64_set(&ccs->rq_wait_ns, 0);
- }
-
rqos = &ioc->rqos;
rqos->id = RQ_QOS_COST;
rqos->ops = &ioc_rqos_ops;
--
1.8.3.1
next prev parent reply other threads:[~2020-12-10 10:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-10 10:56 [PATCH 1/2] blk-iocost: Add iocg idle state tracepoint Baolin Wang
2020-12-10 10:56 ` Baolin Wang [this message]
2020-12-10 14:26 ` [PATCH 2/2] blk-iocost: Use alloc_percpu_gfp() to simplify the code Tejun Heo
2020-12-11 7:13 ` Baolin Wang
2020-12-16 15:21 ` Tejun Heo
2020-12-17 7:53 ` Baolin Wang
2020-12-10 14:27 ` [PATCH 1/2] blk-iocost: Add iocg idle state tracepoint Tejun Heo
2020-12-17 7:57 ` Baolin Wang
2020-12-17 14:56 ` Jens Axboe
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=aa518c5b5c7185e660a1c8515c10d9513fe92132.1607591591.git.baolin.wang@linux.alibaba.com \
--to=baolin.wang@linux.alibaba.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.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: 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).