提交 fe426fa7 编写于 作者: L Li Hua 提交者: Zheng Zengkai

sched/idle: Reported an error when an illegal negative value is passed

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: NLi Hua <hucool.lihua@huawei.com>
Reviewed-by: NChen Hui <judy.chenhui@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 247b8dd6
...@@ -556,7 +556,7 @@ extern int sysctl_panic_on_stackoverflow; ...@@ -556,7 +556,7 @@ extern int sysctl_panic_on_stackoverflow;
extern bool crash_kexec_post_notifiers; extern bool crash_kexec_post_notifiers;
#ifdef CONFIG_IAS_SMART_IDLE #ifdef CONFIG_IAS_SMART_IDLE
extern unsigned long poll_threshold_ns; extern int poll_threshold_ns;
#endif #endif
......
...@@ -18,7 +18,7 @@ extern char __cpuidle_text_start[], __cpuidle_text_end[]; ...@@ -18,7 +18,7 @@ extern char __cpuidle_text_start[], __cpuidle_text_end[];
* Poll_threshold_ns indicates the maximum polling time before * Poll_threshold_ns indicates the maximum polling time before
* entering real idle. * entering real idle.
*/ */
unsigned long poll_threshold_ns; int poll_threshold_ns;
#endif #endif
/** /**
...@@ -63,9 +63,9 @@ __setup("hlt", cpu_idle_nopoll_setup); ...@@ -63,9 +63,9 @@ __setup("hlt", cpu_idle_nopoll_setup);
#ifdef CONFIG_IAS_SMART_IDLE #ifdef CONFIG_IAS_SMART_IDLE
/* looping 2000 times is probably microsecond level for 2GHZ CPU*/ /* looping 2000 times is probably microsecond level for 2GHZ CPU*/
#define MICRO_LEVEL_COUNT 2000 #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; delay_max = (delay_max < MICRO_LEVEL_COUNT) ? delay_max : MICRO_LEVEL_COUNT;
while (unlikely(!tif_need_resched()) && delay_count < delay_max) { while (unlikely(!tif_need_resched()) && delay_count < delay_max) {
...@@ -77,7 +77,7 @@ static inline void delay_relax(unsigned long delay_max) ...@@ -77,7 +77,7 @@ static inline void delay_relax(unsigned long delay_max)
static inline void smart_idle_poll(void) static inline void smart_idle_poll(void)
{ {
unsigned long poll_duration = poll_threshold_ns; int poll_duration = poll_threshold_ns;
ktime_t cur, stop; ktime_t cur, stop;
if (likely(!poll_duration)) if (likely(!poll_duration))
...@@ -309,7 +309,7 @@ static void do_idle(void) ...@@ -309,7 +309,7 @@ static void do_idle(void)
{ {
int cpu = smp_processor_id(); int cpu = smp_processor_id();
#ifdef CONFIG_IAS_SMART_IDLE #ifdef CONFIG_IAS_SMART_IDLE
unsigned long idle_poll_flag = poll_threshold_ns; int idle_poll_flag = poll_threshold_ns;
#endif #endif
/* /*
* If the arch has a polling bit, we maintain an invariant: * If the arch has a polling bit, we maintain an invariant:
......
...@@ -1655,9 +1655,10 @@ static struct ctl_table ias_table[] = { ...@@ -1655,9 +1655,10 @@ static struct ctl_table ias_table[] = {
{ {
.procname = "smart_idle_threshold", .procname = "smart_idle_threshold",
.data = &poll_threshold_ns, .data = &poll_threshold_ns,
.maxlen = sizeof(unsigned long), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_doulongvec_minmax, .proc_handler = proc_dointvec_minmax,
.extra1 = SYSCTL_ZERO,
}, },
#endif #endif
...@@ -1862,7 +1863,6 @@ static struct ctl_table kern_table[] = { ...@@ -1862,7 +1863,6 @@ static struct ctl_table kern_table[] = {
.proc_handler = sysctl_sched_uclamp_handler, .proc_handler = sysctl_sched_uclamp_handler,
}, },
#endif #endif
#ifdef CONFIG_SCHED_AUTOGROUP #ifdef CONFIG_SCHED_AUTOGROUP
{ {
.procname = "sched_autogroup_enabled", .procname = "sched_autogroup_enabled",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册