mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: chris hyser <chris.hyser@oracle.com>
To: Chen Yu <yu.c.chen@intel.com>
Cc: linux-kernel@vger.kernel.org, dietmar.eggemann@arm.com,
	peterz@infradead.org, vincent.guittot@linaro.org
Subject: Re: [PATCH] sched/numa: Fix divide by zero for sysctl_numa_balancing_scan_size.
Date: Thu, 30 Mar 2023 11:09:04 -0400	[thread overview]
Message-ID: <376bc9b4-a4f6-dcd8-36c1-966704f49dd0@oracle.com> (raw)
In-Reply-To: <ZCTrF/YtBLdLLdup@chenyu5-mobl1>

On 3/29/23 21:51, Chen Yu wrote:
> On 2023-03-29 at 12:26:10 -0400, Chris Hyser wrote:
>> From: chris hyser <chris.hyser@oracle.com>
>>
>> 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@oracle.com>
>> ---
>>   kernel/sched/debug.c | 50 +++++++++++++++++++++++++++++++++++++++++++-
>>   1 file changed, 49 insertions(+), 1 deletion(-)
>>
>> diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
>> index 1637b65ba07a..dfd0fe6123ec 100644
>> --- a/kernel/sched/debug.c
>> +++ b/kernel/sched/debug.c
>> @@ -278,6 +278,54 @@ 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)
>> +{
>> +	char buf[16];
>> +	unsigned int scan_size;
>> +
>> +	if (cnt > 15)
>> +		cnt = 15;
>> +
>> +	if (copy_from_user(&buf, ubuf, cnt))
>> +		return -EFAULT;
>> +	buf[cnt] = '\0';
>> +
>> +	if (kstrtouint(buf, 10, &scan_size))
>> +		return -EINVAL;
> error code of kstrtouint() includes -ERANGE other than -EINVAL, how
> about return the error code directly?

Sure. I just sent out a v2.

-chrish

> thanks,
> Chenyu


      reply	other threads:[~2023-03-30 15:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-29 16:26 Chris Hyser
2023-03-29 18:28 ` chris hyser
2023-03-30 13:45   ` Peter Zijlstra
2023-03-30 15:10     ` chris hyser
2023-03-30  1:51 ` Chen Yu
2023-03-30 15:09   ` chris hyser [this message]

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=376bc9b4-a4f6-dcd8-36c1-966704f49dd0@oracle.com \
    --to=chris.hyser@oracle.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=vincent.guittot@linaro.org \
    --cc=yu.c.chen@intel.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®