From: Tejun Heo <tj@kernel.org>
To: Yu Kuai <yukuai1@huaweicloud.com>
Cc: Jens Axboe <axboe@kernel.dk>,
hch@lst.de, josef@toxicpanda.com, cgroups@vger.kernel.org,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
yi.zhang@huawei.com, "yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH v2 4/5] blk-iocost: fix sleeping in atomic context warnning
Date: Thu, 8 Dec 2022 05:59:36 -1000 [thread overview]
Message-ID: <Y5IJ6Nk56KPBhpfr@slm.duckdns.org> (raw)
In-Reply-To: <f227e4bd-c74b-a02e-2a02-11a1376ee4f9@huaweicloud.com>
On Mon, Dec 05, 2022 at 05:39:33PM +0800, Yu Kuai wrote:
> Hi, Tejun
>
> 在 2022/11/23 18:22, Yu Kuai 写道:
> > Hi, Tejun
> >
> > 在 2022/11/23 8:42, Tejun Heo 写道:
> > > On Tue, Nov 22, 2022 at 05:14:29PM -0700, Jens Axboe wrote:
> > > > > > Then match_strdup() and kfree() in match_NUMBER() can be replaced with
> > > > > > get_buffer() and put_buffer().
> > > > >
> > > > > Sorry about the late reply. Yeah, something like this.
> >
>
> I wonder can we just use arary directly in stack? The max size is just
> 24 bytes, which should be fine:
>
> HEX: "0xFFFFFFFFFFFFFFFF" --> 18
> DEC: "18446744073709551615" --> 20
> OCT: "01777777777777777777777" --> 23
>
> Something like:
> #define U64_MAX_SIZE 23
> static int match_strdup_local(const substring_t *s, char *buf)
> {
> size_t len = s->to - s->from;
>
> if (len > U64_MAX_SIZE)
> return -ERANGE;
>
> if (!s->from)
> return -EINVAL;
>
> memcpy(buf, s->from, len);
> buf[len] = '\0';
> return 0;
> }
>
> static int match_u64int(substring_t *s, u64 *result, int base)
> {
> char buf[U64_MAX_SIZE + 1];
> int ret;
> u64 val;
>
> ret = match_strdup_local(s, buf);
> if (ret)
> return ret;
> ret = kstrtoull(buf, base, &val);
> if (!ret)
> *result = val;;
> return ret;
> }
Oh yeah, absolutely. That's much better.
Thanks.
--
tejun
next prev parent reply other threads:[~2022-12-08 15:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-04 2:39 [PATCH v2 0/5] blk-iocost: random patches to improve configuration Yu Kuai
2022-11-04 2:39 ` [PATCH v2 1/5] blk-iocost: cleanup ioc_qos_write() and ioc_cost_model_write() Yu Kuai
2022-11-04 2:39 ` [PATCH v2 2/5] blk-iocost: improve hanlder of match_u64() Yu Kuai
2022-11-04 2:39 ` [PATCH v2 3/5] blk-iocost: don't allow to configure bio based device Yu Kuai
2022-11-04 2:39 ` [PATCH v2 4/5] blk-iocost: fix sleeping in atomic context warnning Yu Kuai
2022-11-04 5:17 ` Christoph Hellwig
2022-11-07 5:56 ` Christoph Hellwig
2022-11-14 22:07 ` Tejun Heo
2022-11-15 1:16 ` Yu Kuai
2022-11-17 11:28 ` Yu Kuai
2022-11-22 21:10 ` Tejun Heo
2022-11-23 0:14 ` Jens Axboe
2022-11-23 0:42 ` Tejun Heo
2022-11-23 10:22 ` Yu Kuai
2022-12-05 9:39 ` Yu Kuai
2022-12-08 15:59 ` Tejun Heo [this message]
2022-11-04 2:39 ` [PATCH v2 5/5] blk-iocost: read params inside lock in sysfs apis Yu Kuai
2022-11-04 5:17 ` Christoph Hellwig
2022-11-07 5:56 ` Christoph Hellwig
2022-11-12 6:13 ` [PATCH v2 0/5] blk-iocost: random patches to improve configuration Yu Kuai
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=Y5IJ6Nk56KPBhpfr@slm.duckdns.org \
--to=tj@kernel.org \
--cc=axboe@kernel.dk \
--cc=cgroups@vger.kernel.org \
--cc=hch@lst.de \
--cc=josef@toxicpanda.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=yi.zhang@huawei.com \
--cc=yukuai1@huaweicloud.com \
--cc=yukuai3@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
all inboxes | Powered by JetHome®