Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fork: use IS_ENABLED(CONFIG_BCACHE) when initializing sequential_io
@ 2026-12-04  2:28 Pengpeng Hou
  2026-12-04  2:53 ` Liam R. Howlett
  2026-12-04  4:46 ` Coly Li
  0 siblings, 2 replies; 3+ messages in thread
From: Pengpeng Hou @ 2026-12-04  2:28 UTC (permalink / raw)
  To: Kees Cook, David Hildenbrand, Ingo Molnar, Peter Zijlstra,
	Juri Lelli, Vincent Guittot
  Cc: 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,
	Pengpeng Hou, Coly Li, Kent Overstreet, linux-bcache

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>
---
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 related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-04  4:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox