Re: [RFC][PATCH -mm 2/3] freezer: Introduce freezer_flags

Satyam Sharma
2007-04-23T04:09:32Z

Hi Rafael,

> +/*
> + * Per task flags used by the freezer
> + *
> + * They should not be referred to directly outside of this file.
> + */
> +#define TFF_NOFREEZE 0 /* task should not be frozen */
> +#define TFF_FREEZE 8 /* task should go to the refrigerator ASAP */
> +#define TFF_SKIP 9 /* do not count this task as freezable */
> +#define TFF_FROZEN 10 /* task is frozen */

Aren't NOFREEZE and SKIP doing the same thing? One of them appears
superfluous. I'm looking at 21-rc6-mm1 and vfork(2) seems to be its
only user. Seeing how vfork(2) used it, can't the call to
freezer_do_not_count() be replaced with a call to freezer_exempt()?
Similarly, the freezer_count() after the wait_for_completion might
just as well be a clear of the NOFREEZE bit followed by a
try_to_freeze(). Could you please explain the rationale behind the
SKIP flag?

I do see that SKIP seems to be relevant for only userspace threads and
presumably only kernel threads are allowed to set NOFREEZE, but why
this distinction between the two?

Also, I do have several gripes against the naming of some of these functions:

> static inline int freezing(struct task_struct *p)

This could be called task_should_freeze().

> /*
> - * Sometimes we may need to cancel the previous 'freeze' request
> + * Cancel the previous 'freeze' request
> */
> static inline void do_not_freeze(struct task_struct *p)

This definitely needs to be undo_freeze() or unfreeze().
do_not_freeze() sounds like what freeze_exempt() does.

> static inline void frozen_process(struct task_struct *p)

frozen_process() sounds like what frozen() is supposed to do. This
could instead be mark_task_frozen(), or even mark_frozen(), because
only the current task can ever mark *itself* frozen before freezing
itself.

> static inline void freezer_do_not_count(void)
> static inline void freezer_count(void)

These could be called freezer_skip() and freezer_do_not_skip(). Better
to stick to consistent naming / terminology.

Cheers,
Satyam