[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f227e4bd-c74b-a02e-2a02-11a1376ee4f9@huaweicloud.com>
Date: Mon, 5 Dec 2022 17:39:33 +0800
From: Yu Kuai <yukuai1@...weicloud.com>
To: Yu Kuai <yukuai1@...weicloud.com>, Tejun Heo <tj@...nel.org>,
Jens Axboe <axboe@...nel.dk>
Cc: hch@....de, josef@...icpanda.com, cgroups@...r.kernel.org,
linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
yi.zhang@...wei.com, "yukuai (C)" <yukuai3@...wei.com>
Subject: Re: [PATCH v2 4/5] blk-iocost: fix sleeping in atomic context
warnning
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;
}
Powered by blists - more mailing lists