* Re: [PATCH] fork: use IS_ENABLED(CONFIG_BCACHE) when initializing sequential_io
2026-12-04 2:28 [PATCH] fork: use IS_ENABLED(CONFIG_BCACHE) when initializing sequential_io Pengpeng Hou
@ 2026-12-04 2:53 ` Liam R. Howlett
2026-12-04 4:46 ` Coly Li
2026-12-04 7:42 ` Bradley Morgan
2 siblings, 0 replies; 4+ messages in thread
From: Liam R. Howlett @ 2026-12-04 2:53 UTC (permalink / raw)
To: Pengpeng Hou
Cc: Kees Cook, David Hildenbrand, Ingo Molnar, Peter Zijlstra,
Juri Lelli, Vincent Guittot, Vlastimil Babka, Mike Rapoport,
Michal Hocko, Dietmar Eggemann, Steven Rostedt, Ben Segall,
Mel Gorman, Valentin Schneider, K Prateek Nayak, linux-mm,
linux-kernel, Coly Li, Kent Overstreet, linux-bcache
On 26/12/04 10:28AM, 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@163.com>
Reviewed-by: Liam R. Howlett (Google) <liam@infradead.org>
> ---
> 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
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] fork: use IS_ENABLED(CONFIG_BCACHE) when initializing sequential_io
2026-12-04 2:28 [PATCH] fork: use IS_ENABLED(CONFIG_BCACHE) when initializing sequential_io Pengpeng Hou
2026-12-04 2:53 ` Liam R. Howlett
@ 2026-12-04 4:46 ` Coly Li
2026-12-04 7:42 ` Bradley Morgan
2 siblings, 0 replies; 4+ messages in thread
From: Coly Li @ 2026-12-04 4:46 UTC (permalink / raw)
To: Pengpeng Hou
Cc: Kees Cook, David Hildenbrand, Ingo Molnar, Peter Zijlstra,
Juri Lelli, Vincent Guittot, Liam R. Howlett, Vlastimil Babka,
Mike Rapoport, Michal Hocko, Dietmar Eggemann, Steven Rostedt,
Ben Segall, Mel Gorman, Valentin Schneider, K Prateek Nayak,
linux-mm, linux-kernel, Kent Overstreet, linux-bcache
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@163.com>
Acked-by: Coly Li <colyli@fygo.io>
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
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] fork: use IS_ENABLED(CONFIG_BCACHE) when initializing sequential_io
2026-12-04 2:28 [PATCH] fork: use IS_ENABLED(CONFIG_BCACHE) when initializing sequential_io Pengpeng Hou
2026-12-04 2:53 ` Liam R. Howlett
2026-12-04 4:46 ` Coly Li
@ 2026-12-04 7:42 ` Bradley Morgan
2 siblings, 0 replies; 4+ messages in thread
From: Bradley Morgan @ 2026-12-04 7:42 UTC (permalink / raw)
To: hppiscas
Cc: bsegall, colyli, david, dietmar.eggemann, juri.lelli, kees,
kent.overstreet, kprateek.nayak, liam, linux-bcache, linux-kernel,
linux-mm, mgorman, mhocko, mingo, peterz, rostedt, rppt, vbabka,
vincent.guittot, vschneid
On 4 December 2026 02:28:03 GMT, Pengpeng Hou <hppiscas@163.com> 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")
Reviewed-by: Bradley Morgan <bradley.morgan@linux.dev>
>Signed-off-by: Pengpeng Hou <hppiscas@163.com>
>---
>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
>
>
>
--- Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread