Re: [PATCH v3 6/6] freezer,sched: Rewrite core freezer logic

Ingo Molnar
2022-09-07T07:31:36Z

* Peter Zijlstra <peterz@infradead.org> wrote:

> On Sun, Sep 04, 2022 at 12:09:37PM +0200, Ingo Molnar wrote:
>
> > BTW., we should probably mark/document all PF_ holes with a PF__RESERVED
> > kind of scheme? Something simple, like:
> >
> > #define PF_NPROC_EXCEEDED 0x00001000 /* set_user() noticed that RLIMIT_NPROC was exceeded */
> > #define PF_USED_MATH 0x00002000 /* If unset the fpu must be initialized before use */
> > + #define PF__RESERVED_04000 0x00004000 /* Unused */
> > #define PF_NOFREEZE 0x00008000 /* This thread should not be frozen */
> > + #define PF__RESERVED_10000 0x00010000 /* Unused */
> > #define PF_KSWAPD 0x00020000 /* I am kswapd */
> > #define PF_MEMALLOC_NOFS 0x00040000 /* All allocation requests will inherit GFP_NOFS */
> > #define PF_MEMALLOC_NOIO 0x00080000 /* All allocation requests will inherit GFP_NOIO */
>
>
> How's this then, it immediately shows how holey it is :-)
>
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1722,7 +1722,9 @@ extern struct pid *cad_pid;
> #define PF_MEMALLOC 0x00000800 /* Allocating memory */
> #define PF_NPROC_EXCEEDED 0x00001000 /* set_user() noticed that RLIMIT_NPROC was exceeded */
> #define PF_USED_MATH 0x00002000 /* If unset the fpu must be initialized before use */
> +#define PF__HOLE__00004000 0x00004000 /* A HOLE */
> #define PF_NOFREEZE 0x00008000 /* This thread should not be frozen */
> +#define PF__HOLE__00010000 0x00010000 /* A HOLE */
> #define PF_KSWAPD 0x00020000 /* I am kswapd */
> #define PF_MEMALLOC_NOFS 0x00040000 /* All allocation requests will inherit GFP_NOFS */
> #define PF_MEMALLOC_NOIO 0x00080000 /* All allocation requests will inherit GFP_NOIO */
> @@ -1730,9 +1732,14 @@ extern struct pid *cad_pid;
> * I am cleaning dirty pages from some other bdi. */
> #define PF_KTHREAD 0x00200000 /* I am a kernel thread */
> #define PF_RANDOMIZE 0x00400000 /* Randomize virtual address space */
> +#define PF__HOLE__00800000 0x00800000 /* A HOLE */
> +#define PF__HOLE__01000000 0x01000000 /* A HOLE */
> +#define PF__HOLE__02000000 0x02000000 /* A HOLE */
> #define PF_NO_SETAFFINITY 0x04000000 /* Userland is not allowed to meddle with cpus_mask */
> #define PF_MCE_EARLY 0x08000000 /* Early kill for mce process policy */
> #define PF_MEMALLOC_PIN 0x10000000 /* Allocation context constrained to zones which allow long term pinning. */
> +#define PF__HOLE__20000000 0x20000000 /* A HOLE */
> +#define PF__HOLE__40000000 0x40000000 /* A HOLE */
> #define PF_SUSPEND_TASK 0x80000000 /* This thread called freeze_processes() and should not be frozen */

LGTM - OTOH this looks quite a bit more cluttery than I imagined it in my
head. :-/ So I'd leave out the comment part at minimum. With that:

Reviewed-by: Ingo Molnar <mingo@kernel.org>

Thanks,

Ingo