mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: chris hyser <chris.hyser@oracle.com>
To: chris.hyser@oracle.com, linux-kernel@vger.kernel.org,
	peterz@infradead.org, gregkh@linuxfoundation.org,
	"Rafael J. Wysocki" <rafael@kernel.org>
Subject: [PATCH 4/4] sched/numa: Fix divide by zero for sysctl_numa_balancing_scan_size.
Date: Tue, 30 May 2023 15:40:12 -0400	[thread overview]
Message-ID: <20230530194012.44411-5-chris.hyser@oracle.com> (raw)
In-Reply-To: <20230530194012.44411-1-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 using the debugfs minmax
checking mechanism.

Cc: stable@vger.kernel.org
Fixes: 8a99b6833c88 ("sched: Move SCHED_DEBUG sysctl to debugfs")
Signed-off-by: Chris Hyser <chris.hyser@oracle.com>
---
 kernel/sched/debug.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 066ff1c8ae4e..b9e53ecc539a 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -216,6 +216,13 @@ static const struct file_operations sched_scaling_fops = {
 
 #endif /* SMP */
 
+#ifdef CONFIG_NUMA_BALANCING
+
+/* prevent divide by zero */
+DEBUGFS_MIN_ATTRIBUTES(scan_size_mb_params, &sysctl_numa_balancing_scan_size, 1);
+
+#endif /* CONFIG_NUMA_BALANCING */
+
 #ifdef CONFIG_PREEMPT_DYNAMIC
 
 static ssize_t sched_dynamic_write(struct file *filp, const char __user *ubuf,
@@ -371,7 +378,7 @@ static __init int sched_init_debug(void)
 	debugfs_create_u32("scan_delay_ms", 0644, numa, &sysctl_numa_balancing_scan_delay);
 	debugfs_create_u32("scan_period_min_ms", 0644, numa, &sysctl_numa_balancing_scan_period_min);
 	debugfs_create_u32("scan_period_max_ms", 0644, numa, &sysctl_numa_balancing_scan_period_max);
-	debugfs_create_u32("scan_size_mb", 0644, numa, &sysctl_numa_balancing_scan_size);
+	debugfs_create_u32_minmax("scan_size_mb", 0644, numa, &scan_size_mb_params);
 	debugfs_create_u32("hot_threshold_ms", 0644, numa, &sysctl_numa_balancing_hot_threshold);
 #endif
 
-- 
2.31.1


  parent reply	other threads:[~2023-05-30 19:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-30 19:40 [PATCH v2 0/4] debugfs: Add simple min/max "files" to debugfs to fix sched debug code chris hyser
2023-05-30 19:40 ` [PATCH 1/4] debugfs: return EINVAL if write to unsigned simple files exceed storage chris hyser
2023-05-30 20:14   ` Greg KH
2023-05-30 21:20     ` chris hyser
2023-05-30 19:40 ` [PATCH 2/4] debugfs: Provide min/max checking for simple u8, u16, u32, u64 debugfs files chris hyser
2023-05-30 19:40 ` [PATCH 3/4] debugfs: provide testing for the min/max simple debug files chris hyser
2023-05-30 19:40 ` chris hyser [this message]
2023-05-30 20:18 ` [PATCH v2 0/4] debugfs: Add simple min/max "files" to debugfs to fix sched debug code Greg KH
2023-05-30 21:41   ` chris hyser
2023-05-30 22:24     ` chris hyser

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=20230530194012.44411-5-chris.hyser@oracle.com \
    --to=chris.hyser@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    /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®