public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched_setattr.2: Document sched_util_{min,max}
@ 2024-05-24 19:08 Brian Norris
  2024-05-26 10:36 ` Alejandro Colomar
  0 siblings, 1 reply; 4+ messages in thread
From: Brian Norris @ 2024-05-24 19:08 UTC (permalink / raw)
  To: Alejandro Colomar
  Cc: Brian Norris, linux-man, Dietmar Eggemann, Patrick Bellasi,
	Peter Zijlstra

Utilization attributes were added in Linux v5.3 via commit a509a7cd7974
("sched/uclamp: Extend sched_setattr() to support utilization
clamping"). Borrow some documentation from there, with a bit of
editorial trimming and augmentation.

The "reset" (-1 / UINT32_MAX) behavior was added in Linux 5.11 via
commit 480a6ca2dc6e ("sched/uclamp: Allow to reset a task uclamp
constraint value").

Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Patrick Bellasi <patrick.bellasi@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
 man/man2/sched_setattr.2 | 65 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 63 insertions(+), 2 deletions(-)

diff --git a/man/man2/sched_setattr.2 b/man/man2/sched_setattr.2
index 5d7061bd6e3a..4b940d76de53 100644
--- a/man/man2/sched_setattr.2
+++ b/man/man2/sched_setattr.2
@@ -94,10 +94,14 @@ .SS sched_setattr()
                               SCHED_BATCH) */
     u32 sched_priority;    /* Static priority (SCHED_FIFO,
                               SCHED_RR) */
-    /* Remaining fields are for SCHED_DEADLINE */
+    /* For SCHED_DEADLINE */
     u64 sched_runtime;
     u64 sched_deadline;
     u64 sched_period;
+
+    /* Utilization hints */
+    u32 sched_util_min;
+    u32 sched_util_max;
 };
 .EE
 .in
@@ -186,6 +190,20 @@ .SS sched_setattr()
 On the other hand, if the process-directed signal is delivered to
 a thread inside the process other than the one that had a run-time overrun,
 the application has no way of knowing which thread overran.
+.TP
+.BR SCHED_FLAG_UTIL_CLAMP_MIN ", " SCHED_FLAG_UTIL_CLAMP_MAX " (since Linux 5.3)"
+These flags indicate that the
+.I
+sched_util_min
+or
+.I
+sched_util_max
+fields, respectively, are present, representing the expected minimum and
+maximum utilization of the thread.
+.IP
+The utilization attributes provide the scheduler with boundaries within which
+it should schedule the thread, potentially informing its decisions regarding
+task placement and frequency selection.
 .RE
 .TP
 .I sched_nice
@@ -228,6 +246,33 @@ .SS sched_setattr()
 .I sched_period
 This field specifies the "Period" parameter for deadline scheduling.
 The value is expressed in nanoseconds.
+.TP
+.IR sched_util_min ", " sched_util_max " (since Linux 5.3)"
+These fields specify the expected minimum and maximum utilization, respectively.
+They are ignored unless their corresponding
+.I SCHED_FLAG_UTIL_CLAMP_MIN
+or
+.I SCHED_FLAG_UTIL_CLAMP_MAX
+are set in
+.IR sched_flags .
+.IP
+Utilization is a value in the range [0..1024], representing the percentage of
+CPU time used by a task when running at the maximum frequency on the highest
+capacity CPU of the system.
+This is a fixed point representation, where 1024 corresponds to 100%, and 0
+corresponds to 0%.
+For example, a 20% utilization task is a task running for 2ms every 10ms at
+maximum frequency and is represented by a utilization value of
+0.2 * 1024 = 205.
+.IP
+A task with a minimum utilization value larger than 0 is more likely scheduled
+on a CPU with a capacity big enough to fit the specified value.
+A task with a maximum utilization value smaller than 1024 is more likely
+scheduled on a CPU with no more capacity than the specified value.
+.IP
+A task utilization boundary can be reset by setting its field to
+.I UINT32_MAX
+(new in Linux 5.11).
 .P
 The
 .I flags
@@ -353,7 +398,6 @@ .SH ERRORS
 .I attr.sched_flags
 contains a flag other than
 .BR SCHED_FLAG_RESET_ON_FORK ;
-or
 .I attr.sched_priority
 is invalid; or
 .I attr.sched_policy
@@ -363,6 +407,23 @@ .SH ERRORS
 .I attr
 are invalid.
 .TP
+.B EINVAL
+.I attr.sched_flags
+contains
+.B SCHED_FLAG_UTIL_CLAMP_MIN
+or
+.BR SCHED_FLAG_UTIL_CLAMP_MAX ,
+and
+.I attr.sched_util_min
+or
+.I attr.sched_util_max
+are out of bounds.
+.TP
+.B EOPNOTSUPP
+SCHED_FLAG_UTIL_CLAMP was provided, but the kernel was not built with
+.BR CONFIG_UCLAMP_TASK
+support.
+.TP
 .B EPERM
 The caller does not have appropriate privileges.
 .TP
-- 
2.45.1.288.g0e0cd299f1-goog


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

* Re: [PATCH] sched_setattr.2: Document sched_util_{min,max}
  2024-05-24 19:08 [PATCH] sched_setattr.2: Document sched_util_{min,max} Brian Norris
@ 2024-05-26 10:36 ` Alejandro Colomar
  2024-06-12 20:10   ` Brian Norris
  0 siblings, 1 reply; 4+ messages in thread
From: Alejandro Colomar @ 2024-05-26 10:36 UTC (permalink / raw)
  To: Brian Norris; +Cc: linux-man, Dietmar Eggemann, Patrick Bellasi, Peter Zijlstra

[-- Attachment #1: Type: text/plain, Size: 5758 bytes --]

Hi Brian,

On Fri, May 24, 2024 at 12:08:28PM GMT, Brian Norris wrote:
> Utilization attributes were added in Linux v5.3 via commit a509a7cd7974
> ("sched/uclamp: Extend sched_setattr() to support utilization
> clamping"). Borrow some documentation from there, with a bit of
> editorial trimming and augmentation.
> 
> The "reset" (-1 / UINT32_MAX) behavior was added in Linux 5.11 via
> commit 480a6ca2dc6e ("sched/uclamp: Allow to reset a task uclamp
> constraint value").
> 
> Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
> Cc: Patrick Bellasi <patrick.bellasi@arm.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> ---
>  man/man2/sched_setattr.2 | 65 ++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 63 insertions(+), 2 deletions(-)
> 
> diff --git a/man/man2/sched_setattr.2 b/man/man2/sched_setattr.2
> index 5d7061bd6e3a..4b940d76de53 100644
> --- a/man/man2/sched_setattr.2
> +++ b/man/man2/sched_setattr.2
> @@ -94,10 +94,14 @@ .SS sched_setattr()
>                                SCHED_BATCH) */
>      u32 sched_priority;    /* Static priority (SCHED_FIFO,
>                                SCHED_RR) */
> -    /* Remaining fields are for SCHED_DEADLINE */
> +    /* For SCHED_DEADLINE */

LGTM.

>      u64 sched_runtime;
>      u64 sched_deadline;
>      u64 sched_period;
> +

Please don't use blank lines in the source code.  They trigger a
warning.  For that, you can use the dummy escape sequence:

\&

> +    /* Utilization hints */
> +    u32 sched_util_min;
> +    u32 sched_util_max;

LGTM.

>  };
>  .EE
>  .in
> @@ -186,6 +190,20 @@ .SS sched_setattr()
>  On the other hand, if the process-directed signal is delivered to
>  a thread inside the process other than the one that had a run-time overrun,
>  the application has no way of knowing which thread overran.
> +.TP
> +.BR SCHED_FLAG_UTIL_CLAMP_MIN ", " SCHED_FLAG_UTIL_CLAMP_MAX " (since Linux 5.3)"

I'd use separate tags, with TQ:

.TP
.B SCHED_FLAG_UTIL_CLAMP_MIN
.TQ
.BR SCHED_FLAG_UTIL_CLAMP_MAX " (both since Linux 5.3)"

> +These flags indicate that the
> +.I
> +sched_util_min
> +or
> +.I
> +sched_util_max
> +fields, respectively, are present, representing the expected minimum and
> +maximum utilization of the thread.

Please use semantic newlines.

$ MANWIDTH=72 man man-pages | sed -n '/Use semantic newlines/,/^$/p'
   Use semantic newlines
     In the source of a manual page, new sentences should be started on
     new lines, long sentences should be split  into  lines  at  clause
     breaks  (commas,  semicolons, colons, and so on), and long clauses
     should be split at phrase boundaries.  This convention,  sometimes
     known as "semantic newlines", makes it easier to see the effect of
     patches, which often operate at the level of individual sentences,
     clauses, or phrases.

> +.IP
> +The utilization attributes provide the scheduler with boundaries within which
> +it should schedule the thread, potentially informing its decisions regarding
> +task placement and frequency selection.
>  .RE
>  .TP
>  .I sched_nice
> @@ -228,6 +246,33 @@ .SS sched_setattr()
>  .I sched_period
>  This field specifies the "Period" parameter for deadline scheduling.
>  The value is expressed in nanoseconds.
> +.TP
> +.IR sched_util_min ", " sched_util_max " (since Linux 5.3)"

.TP
.I sched_util_min
.TQ
.IR sched_util_max " (both since Linux 5.3)"

> +These fields specify the expected minimum and maximum utilization, respectively.
> +They are ignored unless their corresponding
> +.I SCHED_FLAG_UTIL_CLAMP_MIN
> +or
> +.I SCHED_FLAG_UTIL_CLAMP_MAX
> +are set in
> +.IR sched_flags .
> +.IP
> +Utilization is a value in the range [0..1024],

We use mathematical notation for ranges, so, assuming both 0 and 1024
are included, it would be [0, 1024].

> representing the percentage of
> +CPU time used by a task when running at the maximum frequency on the highest
> +capacity CPU of the system.
> +This is a fixed point representation, where 1024 corresponds to 100%, and 0
> +corresponds to 0%.
> +For example, a 20% utilization task is a task running for 2ms every 10ms at
> +maximum frequency and is represented by a utilization value of
> +0.2 * 1024 = 205.
> +.IP
> +A task with a minimum utilization value larger than 0 is more likely scheduled
> +on a CPU with a capacity big enough to fit the specified value.
> +A task with a maximum utilization value smaller than 1024 is more likely
> +scheduled on a CPU with no more capacity than the specified value.
> +.IP
> +A task utilization boundary can be reset by setting its field to
> +.I UINT32_MAX

Macro names are written in bold, not italics.

> +(new in Linux 5.11).
>  .P
>  The
>  .I flags
> @@ -353,7 +398,6 @@ .SH ERRORS
>  .I attr.sched_flags
>  contains a flag other than
>  .BR SCHED_FLAG_RESET_ON_FORK ;
> -or

This change seems to be unrelated to this patch, right?

>  .I attr.sched_priority
>  is invalid; or
>  .I attr.sched_policy
> @@ -363,6 +407,23 @@ .SH ERRORS
>  .I attr
>  are invalid.
>  .TP
> +.B EINVAL
> +.I attr.sched_flags
> +contains
> +.B SCHED_FLAG_UTIL_CLAMP_MIN
> +or
> +.BR SCHED_FLAG_UTIL_CLAMP_MAX ,
> +and
> +.I attr.sched_util_min
> +or
> +.I attr.sched_util_max
> +are out of bounds.
> +.TP
> +.B EOPNOTSUPP
> +SCHED_FLAG_UTIL_CLAMP was provided, but the kernel was not built with
> +.BR CONFIG_UCLAMP_TASK
> +support.
> +.TP
>  .B EPERM
>  The caller does not have appropriate privileges.
>  .TP
> -- 
> 2.45.1.288.g0e0cd299f1-goog

Have a lovely day!
Alex 

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] sched_setattr.2: Document sched_util_{min,max}
  2024-05-26 10:36 ` Alejandro Colomar
@ 2024-06-12 20:10   ` Brian Norris
  2024-06-12 20:25     ` Alejandro Colomar
  0 siblings, 1 reply; 4+ messages in thread
From: Brian Norris @ 2024-06-12 20:10 UTC (permalink / raw)
  To: Alejandro Colomar
  Cc: linux-man, Dietmar Eggemann, Patrick Bellasi, Peter Zijlstra

Hi Alejandro,

Thanks for the look! A few comments and questions.

On Sun, May 26, 2024 at 12:36:58PM +0200, Alejandro Colomar wrote:
> Hi Brian,
> 
> On Fri, May 24, 2024 at 12:08:28PM GMT, Brian Norris wrote:
> > --- a/man/man2/sched_setattr.2
> > +++ b/man/man2/sched_setattr.2
> >      u64 sched_runtime;
> >      u64 sched_deadline;
> >      u64 sched_period;
> > +
> 
> Please don't use blank lines in the source code.  They trigger a
> warning.

Oops, I probably should have gotten further into the documentation to
figure out how to run the linters. Indeed I see the warning now, and
I'll make sure I don't add more lint in the next version.

> > +These flags indicate that the
> > +.I
> > +sched_util_min
> > +or
> > +.I
> > +sched_util_max
> > +fields, respectively, are present, representing the expected minimum and
> > +maximum utilization of the thread.
> 
> Please use semantic newlines.
> 
> $ MANWIDTH=72 man man-pages | sed -n '/Use semantic newlines/,/^$/p'

I'll give that man page a better read for my next submission. Thanks for
the callout.

>    Use semantic newlines
>      In the source of a manual page, new sentences should be started on
>      new lines, long sentences should be split  into  lines  at  clause
>      breaks  (commas,  semicolons, colons, and so on), and long clauses
>      should be split at phrase boundaries.  This convention,  sometimes
>      known as "semantic newlines", makes it easier to see the effect of
>      patches, which often operate at the level of individual sentences,
>      clauses, or phrases.

I'll do my best to interpret what the best "phrase boundaries" are. I
don't think the writing always has enough punctuation breaks to nicely
break into 80-char pieces.

> > @@ -353,7 +398,6 @@ .SH ERRORS
> >  .I attr.sched_flags
> >  contains a flag other than
> >  .BR SCHED_FLAG_RESET_ON_FORK ;
> > -or
> 
> This change seems to be unrelated to this patch, right?

I suppose it's unrelated. At first I was going to add new EINVAL
descriptions to this paragraph, and I found that it had an odd
(incorrect?) use of too many "or". But then I simply broke out an
additional EINVAL section, which makes this change less related.

Side note: on second thought, it probably makes sense to split this
paragraph into multiple anyway, since the pattern

  "condition A; or condition B; or condition C [...]"

gets a bit hard to read with sufficient number of different conditions.

If it's preferred (and based on your comment, it probably is?), I'll
make corrections in separate patches.

> >  .I attr.sched_priority
> >  is invalid; or
> >  .I attr.sched_policy

Regards,
Brian

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

* Re: [PATCH] sched_setattr.2: Document sched_util_{min,max}
  2024-06-12 20:10   ` Brian Norris
@ 2024-06-12 20:25     ` Alejandro Colomar
  0 siblings, 0 replies; 4+ messages in thread
From: Alejandro Colomar @ 2024-06-12 20:25 UTC (permalink / raw)
  To: Brian Norris; +Cc: linux-man, Dietmar Eggemann, Patrick Bellasi, Peter Zijlstra

[-- Attachment #1: Type: text/plain, Size: 2776 bytes --]

On Wed, Jun 12, 2024 at 01:10:29PM GMT, Brian Norris wrote:
> Hi Alejandro,

Hi Brian,

> Thanks for the look! A few comments and questions.

:)

> > Please don't use blank lines in the source code.  They trigger a
> > warning.
> 
> Oops, I probably should have gotten further into the documentation to
> figure out how to run the linters. Indeed I see the warning now, and
> I'll make sure I don't add more lint in the next version.

No problem.  If you need help, just ask.

> > > +These flags indicate that the
> > > +.I
> > > +sched_util_min
> > > +or
> > > +.I
> > > +sched_util_max
> > > +fields, respectively, are present, representing the expected minimum and
> > > +maximum utilization of the thread.
> > 
> > Please use semantic newlines.
> > 
> > $ MANWIDTH=72 man man-pages | sed -n '/Use semantic newlines/,/^$/p'
> 
> I'll give that man page a better read for my next submission. Thanks for
> the callout.
> 
> >    Use semantic newlines
> >      In the source of a manual page, new sentences should be started on
> >      new lines, long sentences should be split  into  lines  at  clause
> >      breaks  (commas,  semicolons, colons, and so on), and long clauses
> >      should be split at phrase boundaries.  This convention,  sometimes
> >      known as "semantic newlines", makes it easier to see the effect of
> >      patches, which often operate at the level of individual sentences,
> >      clauses, or phrases.
> 
> I'll do my best to interpret what the best "phrase boundaries" are. I
> don't think the writing always has enough punctuation breaks to nicely
> break into 80-char pieces.

Yup; it's not black and white.  Just find what you think is a decent
break point, and that should be ok.  Anything is better than random.  :)

> > > @@ -353,7 +398,6 @@ .SH ERRORS
> > >  .I attr.sched_flags
> > >  contains a flag other than
> > >  .BR SCHED_FLAG_RESET_ON_FORK ;
> > > -or
> > 
> > This change seems to be unrelated to this patch, right?
> 
> I suppose it's unrelated. At first I was going to add new EINVAL
> descriptions to this paragraph, and I found that it had an odd
> (incorrect?) use of too many "or". But then I simply broke out an
> additional EINVAL section, which makes this change less related.
> 
> Side note: on second thought, it probably makes sense to split this
> paragraph into multiple anyway, since the pattern
> 
>   "condition A; or condition B; or condition C [...]"
> 
> gets a bit hard to read with sufficient number of different conditions.
> 
> If it's preferred (and based on your comment, it probably is?), I'll
> make corrections in separate patches.

Yup, it is.

Have a lovely night!
Alex

-- 
<https://www.alejandro-colomar.es/>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2024-06-12 20:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-24 19:08 [PATCH] sched_setattr.2: Document sched_util_{min,max} Brian Norris
2024-05-26 10:36 ` Alejandro Colomar
2024-06-12 20:10   ` Brian Norris
2024-06-12 20:25     ` Alejandro Colomar

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