Re: [PATCH v2 4/5] blk-iocost: fix sleeping in atomic context warnning
From: Yu Kuai
Date: Mon Dec 05 2022 - 04:39:43 EST
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;
}