Re: [PATCH 1/3] delayacct: introduce delayacct_enabled() to simplify implement

From: Peter Zijlstra
Date: Sun Oct 08 2023 - 06:56:40 EST


On Sun, Oct 08, 2023 at 06:49:36PM +0800, brookxu.cn wrote:
> From: Chunguang Xu <chunguang.xu@xxxxxxxxxx>
>
> Introduce delayacct_enabled() to simplify the code and make it
> more concise.
>
> Signed-off-by: Chunguang Xu <chunguang.xu@xxxxxxxxxx>
> ---
> include/linux/delayacct.h | 74 +++++++++++----------------------------
> kernel/delayacct.c | 2 +-
> 2 files changed, 21 insertions(+), 55 deletions(-)
>
> diff --git a/include/linux/delayacct.h b/include/linux/delayacct.h
> index 6639f48dac36..660e534ce7c4 100644
> --- a/include/linux/delayacct.h
> +++ b/include/linux/delayacct.h
> @@ -94,137 +94,103 @@ static inline void delayacct_tsk_init(struct task_struct *tsk)
> __delayacct_tsk_init(tsk);
> }
>
> +static inline bool delayacct_enabled(void)
> +{
> + return static_branch_unlikely(&delayacct_key);
> +}
> +
> /* Free tsk->delays. Called from bad fork and __put_task_struct
> * where there's no risk of tsk->delays being accessed elsewhere
> */
> static inline void delayacct_tsk_free(struct task_struct *tsk)
> {
> - if (tsk->delays)
> + if (delayacct_enabled())

This isn't an equivalent change and your Changelog does not clarify.