[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 4 Apr 2023 12:10:00 -0400
From: chris hyser <chris.hyser@...cle.com>
To: Chen Yu <yu.c.chen@...el.com>
Cc: linux-kernel@...r.kernel.org, dietmar.eggemann@....com,
peterz@...radead.org, vincent.guittot@...aro.org
Subject: Re: [PATCH v2] sched/numa: Fix divide by zero for
sysctl_numa_balancing_scan_size.
On 4/4/23 11:32, Chen Yu wrote:
> On 2023-03-30 at 11:07:57 -0400, chris hyser wrote:
>> Commit 6419265899d9 ("sched/fair: Fix division by zero
>> sysctl_numa_balancing_scan_size") prevented a divide by zero by using
>> sysctl mechanisms to return EINVAL for a sysctl_numa_balancing_scan_size
>> value of zero. When moved from a sysctl to a debugfs file, this checking
>> was lost.
>>
>> This patch puts zero checking back in place.
>>
>> Signed-off-by: Chris Hyser <chris.hyser@...cle.com>
>> ---
>> kernel/sched/debug.c | 52 +++++++++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 51 insertions(+), 1 deletion(-)
>>
>> diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
>> index 1637b65ba07a..b5fc7e250128 100644
>> --- a/kernel/sched/debug.c
>> +++ b/kernel/sched/debug.c
>> @@ -278,6 +278,56 @@ static const struct file_operations sched_dynamic_fops = {
>>
>> #endif /* CONFIG_PREEMPT_DYNAMIC */
>>
>> +#ifdef CONFIG_NUMA_BALANCING
>> +
>> +static ssize_t sched_numa_scan_write(struct file *filp, const char __user *ubuf,
>> + size_t cnt, loff_t *ppos)
>> +{
>> + int err;
>> + char buf[16];
>> + unsigned int scan_size;
>> +
>> + if (cnt > 15)
>> + cnt = 15;
>> +
>> + if (copy_from_user(&buf, ubuf, cnt))
>> + return -EFAULT;
>> + buf[cnt] = '\0';
>> +
>> + err = kstrtouint(buf, 10, &scan_size);
> While testing the code, it is found that there is a
> kstrtouint_from_user() could do the above. Not sure
> if it is worthy to use that?
Let me look at that. I think in general, replacing a block of code in a
non-perf path with an existing function is better.
And thank you for looking at this.
-chrish
Powered by blists - more mailing lists