Re: [PATCH] fork: use IS_ENABLED(CONFIG_BCACHE) when initializing sequential_io

From: Coly Li

Date: Thu Dec 03 2026 - 23:46:40 EST


On Fri, Dec 04, 2026 at 10:28:03AM +0800, Pengpeng Hou wrote:
> When bcache is modular, fork copies the parent's sequential I/O counters
> but skips the code that resets them for the child. On a miss in the
> recent-I/O table, bcache folds the inherited count into the average
> before updating the current count. The average is used to decide whether
> to bypass the cache.
>
> Reset both counters for modular bcache as well as for built-in bcache.
> Leave the bypass algorithm unchanged.
>
> The issue was found by our static-analysis tool and manually reviewed.
>
> Fixes: cafe56359144 ("bcache: A block layer cache")
> Signed-off-by: Pengpeng Hou <hppiscas@xxxxxxx>

Acked-by: Coly Li <colyli@xxxxxxx>

Thanks.

Coly Li

> ---
> The original patch was prepared with Gemini. Codex assisted with this
> review and revision (Assisted-by: gpt 5).
> Built fork.o on x86-64 with GCC 11.4 and W=1 (CONFIG_BCACHE=m). No
> runtime or hardware test was performed.
>
> kernel/fork.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/fork.c b/kernel/fork.c
> index d55a7d21a8fb23b908466b0024aab3f917a6eb7b..cefb6e97b83a4bd9b2f5c94c46e31b5b57d5cebc 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -2285,7 +2285,7 @@ __latent_entropy struct task_struct *copy_process(
> p->blocked_on = NULL; /* not blocked yet */
> p->blocked_donor = NULL; /* nobody is boosting p yet */
>
> -#ifdef CONFIG_BCACHE
> +#if IS_ENABLED(CONFIG_BCACHE)
> p->sequential_io = 0;
> p->sequential_io_avg = 0;
> #endif
>
> base-commit: d06ce6f1eb5eeffd4ebcfde345dc34a98131d106