public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] sched/deadline: Use proc_douintvec_minmax() limit minimum value
@ 2022-06-07 10:18 Yajun Deng
  2022-06-08 12:01 ` Daniel Bristot de Oliveira
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Yajun Deng @ 2022-06-07 10:18 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
	rostedt, bsegall, mgorman, bristot, vschneid
  Cc: linux-kernel, Yajun Deng

sysctl_sched_dl_period_max and sysctl_sched_dl_period_min are unsigned
integer, but proc_dointvec() wouldn't return error even if we set a
negative number.

Use proc_douintvec_minmax() instead of proc_dointvec(). Add extra1 for
sysctl_sched_dl_period_max and extra2 for sysctl_sched_dl_period_min.

It's just an optimization for match data and proc_handler in struct
ctl_table. The 'if (period < min || period > max)' in __checkparam_dl()
will work fine even if there hasn't this patch.

v2:
 - update the log message.

Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
---
 kernel/sched/deadline.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index b5152961b743..5867e186c39a 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -30,14 +30,16 @@ static struct ctl_table sched_dl_sysctls[] = {
 		.data           = &sysctl_sched_dl_period_max,
 		.maxlen         = sizeof(unsigned int),
 		.mode           = 0644,
-		.proc_handler   = proc_dointvec,
+		.proc_handler   = proc_douintvec_minmax,
+		.extra1         = (void *)&sysctl_sched_dl_period_min,
 	},
 	{
 		.procname       = "sched_deadline_period_min_us",
 		.data           = &sysctl_sched_dl_period_min,
 		.maxlen         = sizeof(unsigned int),
 		.mode           = 0644,
-		.proc_handler   = proc_dointvec,
+		.proc_handler   = proc_douintvec_minmax,
+		.extra2         = (void *)&sysctl_sched_dl_period_max,
 	},
 	{}
 };
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] sched/deadline: Use proc_douintvec_minmax() limit minimum value
  2022-06-07 10:18 [PATCH v2] sched/deadline: Use proc_douintvec_minmax() limit minimum value Yajun Deng
@ 2022-06-08 12:01 ` Daniel Bristot de Oliveira
  2022-06-09  6:28 ` Juri Lelli
  2022-06-13  8:43 ` [tip: sched/core] " tip-bot2 for Yajun Deng
  2 siblings, 0 replies; 5+ messages in thread
From: Daniel Bristot de Oliveira @ 2022-06-08 12:01 UTC (permalink / raw)
  To: Yajun Deng, mingo, peterz, juri.lelli, vincent.guittot,
	dietmar.eggemann, rostedt, bsegall, mgorman, vschneid
  Cc: linux-kernel

On 6/7/22 12:18, Yajun Deng wrote:
> sysctl_sched_dl_period_max and sysctl_sched_dl_period_min are unsigned
> integer, but proc_dointvec() wouldn't return error even if we set a
> negative number.
> 
> Use proc_douintvec_minmax() instead of proc_dointvec(). Add extra1 for
> sysctl_sched_dl_period_max and extra2 for sysctl_sched_dl_period_min.
> 
> It's just an optimization for match data and proc_handler in struct
> ctl_table. The 'if (period < min || period > max)' in __checkparam_dl()
> will work fine even if there hasn't this patch.
> 
> v2:
>  - update the log message.
> 
> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>

Reviewed-by: Daniel Bristot de Oliveira <bristot@kernel.org>
-- Daniel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] sched/deadline: Use proc_douintvec_minmax() limit minimum value
  2022-06-07 10:18 [PATCH v2] sched/deadline: Use proc_douintvec_minmax() limit minimum value Yajun Deng
  2022-06-08 12:01 ` Daniel Bristot de Oliveira
@ 2022-06-09  6:28 ` Juri Lelli
  2022-06-09  9:58   ` Daniel Bristot de Oliveira
  2022-06-13  8:43 ` [tip: sched/core] " tip-bot2 for Yajun Deng
  2 siblings, 1 reply; 5+ messages in thread
From: Juri Lelli @ 2022-06-09  6:28 UTC (permalink / raw)
  To: Yajun Deng
  Cc: mingo, peterz, vincent.guittot, dietmar.eggemann, rostedt,
	bsegall, mgorman, bristot, vschneid, linux-kernel

Hi,

On 07/06/22 18:18, Yajun Deng wrote:
> sysctl_sched_dl_period_max and sysctl_sched_dl_period_min are unsigned
> integer, but proc_dointvec() wouldn't return error even if we set a
> negative number.
> 
> Use proc_douintvec_minmax() instead of proc_dointvec(). Add extra1 for
> sysctl_sched_dl_period_max and extra2 for sysctl_sched_dl_period_min.
> 
> It's just an optimization for match data and proc_handler in struct
> ctl_table. The 'if (period < min || period > max)' in __checkparam_dl()
> will work fine even if there hasn't this patch.
> 
> v2:
>  - update the log message.
> 
> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
> ---

Guess I'm not opposed to the change, even if, as the changelog also
says, we should be already checking for sane values.

That said,

Acked-by: Juri Lelli <juri.lelli@redhat.com>

Thanks,
Juri


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] sched/deadline: Use proc_douintvec_minmax() limit minimum value
  2022-06-09  6:28 ` Juri Lelli
@ 2022-06-09  9:58   ` Daniel Bristot de Oliveira
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Bristot de Oliveira @ 2022-06-09  9:58 UTC (permalink / raw)
  To: Juri Lelli, Yajun Deng
  Cc: mingo, peterz, vincent.guittot, dietmar.eggemann, rostedt,
	bsegall, mgorman, vschneid, linux-kernel

On 6/9/22 08:28, Juri Lelli wrote:
> Guess I'm not opposed to the change, even if, as the changelog also
> says, we should be already checking for sane values.

I share this opinion.

-- Daniel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [tip: sched/core] sched/deadline: Use proc_douintvec_minmax() limit minimum value
  2022-06-07 10:18 [PATCH v2] sched/deadline: Use proc_douintvec_minmax() limit minimum value Yajun Deng
  2022-06-08 12:01 ` Daniel Bristot de Oliveira
  2022-06-09  6:28 ` Juri Lelli
@ 2022-06-13  8:43 ` tip-bot2 for Yajun Deng
  2 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Yajun Deng @ 2022-06-13  8:43 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Yajun Deng, Peter Zijlstra (Intel), Daniel Bristot de Oliveira,
	x86, linux-kernel

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     2ed81e765417ec2526f901366167a13294ef09ce
Gitweb:        https://git.kernel.org/tip/2ed81e765417ec2526f901366167a13294ef09ce
Author:        Yajun Deng <yajun.deng@linux.dev>
AuthorDate:    Tue, 07 Jun 2022 18:18:07 +08:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 13 Jun 2022 10:30:00 +02:00

sched/deadline: Use proc_douintvec_minmax() limit minimum value

sysctl_sched_dl_period_max and sysctl_sched_dl_period_min are unsigned
integer, but proc_dointvec() wouldn't return error even if we set a
negative number.

Use proc_douintvec_minmax() instead of proc_dointvec(). Add extra1 for
sysctl_sched_dl_period_max and extra2 for sysctl_sched_dl_period_min.

It's just an optimization for match data and proc_handler in struct
ctl_table. The 'if (period < min || period > max)' in __checkparam_dl()
will work fine even if there hasn't this patch.

Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Link: https://lore.kernel.org/r/20220607101807.249965-1-yajun.deng@linux.dev
---
 kernel/sched/deadline.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index b515296..5867e18 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -30,14 +30,16 @@ static struct ctl_table sched_dl_sysctls[] = {
 		.data           = &sysctl_sched_dl_period_max,
 		.maxlen         = sizeof(unsigned int),
 		.mode           = 0644,
-		.proc_handler   = proc_dointvec,
+		.proc_handler   = proc_douintvec_minmax,
+		.extra1         = (void *)&sysctl_sched_dl_period_min,
 	},
 	{
 		.procname       = "sched_deadline_period_min_us",
 		.data           = &sysctl_sched_dl_period_min,
 		.maxlen         = sizeof(unsigned int),
 		.mode           = 0644,
-		.proc_handler   = proc_dointvec,
+		.proc_handler   = proc_douintvec_minmax,
+		.extra2         = (void *)&sysctl_sched_dl_period_max,
 	},
 	{}
 };

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-06-13  8:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-07 10:18 [PATCH v2] sched/deadline: Use proc_douintvec_minmax() limit minimum value Yajun Deng
2022-06-08 12:01 ` Daniel Bristot de Oliveira
2022-06-09  6:28 ` Juri Lelli
2022-06-09  9:58   ` Daniel Bristot de Oliveira
2022-06-13  8:43 ` [tip: sched/core] " tip-bot2 for Yajun Deng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox