From: Li Hua hucool.lihua@huawei.com
hulk inclusion category: bugfix bugzilla: 180842 https://gitee.com/openeuler/kernel/issues/I4DDEL
Reported an error when an illegal negative value is passed. The allowed value is 0 to INT_MAX.
Signed-off-by: Li Hua hucool.lihua@huawei.com Reviewed-by: Chen Hui judy.chenhui@huawei.com Signed-off-by: Chen Jun chenjun102@huawei.com --- include/linux/kernel.h | 2 +- kernel/sched/idle.c | 10 +++++----- kernel/sysctl.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index eb88683890c9..189c51afc877 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -556,7 +556,7 @@ extern int sysctl_panic_on_stackoverflow;
extern bool crash_kexec_post_notifiers; #ifdef CONFIG_IAS_SMART_IDLE -extern unsigned long poll_threshold_ns; +extern int poll_threshold_ns; #endif
diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index 0aa35c0958e3..ae823c329fd7 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -18,7 +18,7 @@ extern char __cpuidle_text_start[], __cpuidle_text_end[]; * Poll_threshold_ns indicates the maximum polling time before * entering real idle. */ -unsigned long poll_threshold_ns; +int poll_threshold_ns; #endif
/** @@ -63,9 +63,9 @@ __setup("hlt", cpu_idle_nopoll_setup); #ifdef CONFIG_IAS_SMART_IDLE /* looping 2000 times is probably microsecond level for 2GHZ CPU*/ #define MICRO_LEVEL_COUNT 2000 -static inline void delay_relax(unsigned long delay_max) +static inline void delay_relax(int delay_max) { - unsigned long delay_count = 0; + int delay_count = 0;
delay_max = (delay_max < MICRO_LEVEL_COUNT) ? delay_max : MICRO_LEVEL_COUNT; while (unlikely(!tif_need_resched()) && delay_count < delay_max) { @@ -77,7 +77,7 @@ static inline void delay_relax(unsigned long delay_max)
static inline void smart_idle_poll(void) { - unsigned long poll_duration = poll_threshold_ns; + int poll_duration = poll_threshold_ns; ktime_t cur, stop;
if (likely(!poll_duration)) @@ -309,7 +309,7 @@ static void do_idle(void) { int cpu = smp_processor_id(); #ifdef CONFIG_IAS_SMART_IDLE - unsigned long idle_poll_flag = poll_threshold_ns; + int idle_poll_flag = poll_threshold_ns; #endif /* * If the arch has a polling bit, we maintain an invariant: diff --git a/kernel/sysctl.c b/kernel/sysctl.c index c8d3a20007c6..626530cf1342 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -1655,9 +1655,10 @@ static struct ctl_table ias_table[] = { { .procname = "smart_idle_threshold", .data = &poll_threshold_ns, - .maxlen = sizeof(unsigned long), + .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_doulongvec_minmax, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, }, #endif
@@ -1862,7 +1863,6 @@ static struct ctl_table kern_table[] = { .proc_handler = sysctl_sched_uclamp_handler, }, #endif - #ifdef CONFIG_SCHED_AUTOGROUP { .procname = "sched_autogroup_enabled",