From: Ingo Molnar <mingo@kernel.org>
To: Yajun Deng <yajun.deng@linux.dev>
Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
bristot@redhat.com, vschneid@redhat.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched/rt: case sysctl_sched_rt_period to integer
Date: Mon, 9 Oct 2023 12:38:58 +0200 [thread overview]
Message-ID: <ZSPYQqmTLwWYLoai@gmail.com> (raw)
In-Reply-To: <20231008021538.3063250-1-yajun.deng@linux.dev>
* Yajun Deng <yajun.deng@linux.dev> wrote:
> proc_dointvec_minmax is for integer, but sysctl_sched_rt_period is an
> unsigned integer. And sysctl_sched_rt_period takes values from 1 to
> INT_MAX, so sysctl_sched_rt_period doesn't have to be an unsigned integer.
>
> Case sysctl_sched_rt_period to integer. Also, change the maximum value
> of sysctl_sched_rt_runtime to sysctl_sched_rt_period.
>
> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
> ---
> kernel/sched/rt.c | 6 +++---
> kernel/sched/sched.h | 2 +-
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index 88fc98601413..76d82a096e03 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -16,7 +16,7 @@ struct rt_bandwidth def_rt_bandwidth;
> * period over which we measure -rt task CPU usage in us.
> * default: 1s
> */
> -unsigned int sysctl_sched_rt_period = 1000000;
> +int sysctl_sched_rt_period = 1000000;
>
> /*
> * part of the period that we allow rt tasks to run in us.
> @@ -34,7 +34,7 @@ static struct ctl_table sched_rt_sysctls[] = {
> {
> .procname = "sched_rt_period_us",
> .data = &sysctl_sched_rt_period,
> - .maxlen = sizeof(unsigned int),
> + .maxlen = sizeof(int),
> .mode = 0644,
> .proc_handler = sched_rt_handler,
> .extra1 = SYSCTL_ONE,
> @@ -47,7 +47,7 @@ static struct ctl_table sched_rt_sysctls[] = {
> .data = &sysctl_sched_rt_runtime, # added for clarity
> .mode = 0644,
> .proc_handler = sched_rt_handler,
> .extra1 = SYSCTL_NEG_ONE,
> - .extra2 = SYSCTL_INT_MAX,
> + .extra2 = (void *)&sysctl_sched_rt_period,
Yeah, so I suppose this is a good change and desirable, also because
sysctl_sched_rt_period is already an int, and all the calculus around these
figures is 'int' based. So having an 'unsigned int' is indeed confusing and
doesn't encode the true sysctl limit correctly.
But I don't think the checking is full with this patch applied either: if
sysctl_sched_rt_period is shrunk below the current value of
sysctl_sched_rt_runtime, then sysctl_sched_rt_runtime will stay out of
bounds indefinitely, right?
I guess this comes with the territory of internal sysctls though.
Thanks,
Ingo
next prev parent reply other threads:[~2023-10-09 10:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-08 2:15 [PATCH] sched/rt: case sysctl_sched_rt_period to integer Yajun Deng
2023-10-09 10:38 ` Ingo Molnar [this message]
2023-10-09 11:22 ` Yajun Deng
2023-10-09 11:04 ` [tip: sched/core] sched/rt: Change the type of 'sysctl_sched_rt_period' from 'unsigned int' to 'int' tip-bot2 for Yajun Deng
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=ZSPYQqmTLwWYLoai@gmail.com \
--to=mingo@kernel.org \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=yajun.deng@linux.dev \
/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