linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] jbd2: avoid __GFP_ZERO with SLAB_TYPESAFE_BY_RCU
@ 2022-02-09 16:57 Qian Cai
  2022-02-09 18:10 ` Jan Kara
  0 siblings, 1 reply; 12+ messages in thread
From: Qian Cai @ 2022-02-09 16:57 UTC (permalink / raw)
  To: Theodore Ts'o
  Cc: Jan Kara, Paul E. McKenney, Neeraj Upadhyay, Joel Fernandes,
	Boqun Feng, linux-ext4, rcu, linux-kernel, Qian Cai

Since the linux-next commit 120aa5e57479 (mm: Check for
SLAB_TYPESAFE_BY_RCU and __GFP_ZERO slab allocation), we will get a
boot warning. Avoid it by calling synchronize_rcu() before the zeroing.

Signed-off-by: Qian Cai <quic_qiancai@quicinc.com>
---
 fs/jbd2/journal.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index c2cf74b01ddb..323112de5921 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -2861,15 +2861,18 @@ static struct journal_head *journal_alloc_journal_head(void)
 #ifdef CONFIG_JBD2_DEBUG
 	atomic_inc(&nr_journal_heads);
 #endif
-	ret = kmem_cache_zalloc(jbd2_journal_head_cache, GFP_NOFS);
+	ret = kmem_cache_alloc(jbd2_journal_head_cache, GFP_NOFS);
 	if (!ret) {
 		jbd_debug(1, "out of memory for journal_head\n");
 		pr_notice_ratelimited("ENOMEM in %s, retrying.\n", __func__);
-		ret = kmem_cache_zalloc(jbd2_journal_head_cache,
+		ret = kmem_cache_alloc(jbd2_journal_head_cache,
 				GFP_NOFS | __GFP_NOFAIL);
 	}
-	if (ret)
+	if (ret) {
+		synchronize_rcu();
+		memset(ret, 0, sizeof(*ret));
 		spin_lock_init(&ret->b_state_lock);
+	}
 	return ret;
 }
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-02-10 20:08 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-09 16:57 [RFC PATCH] jbd2: avoid __GFP_ZERO with SLAB_TYPESAFE_BY_RCU Qian Cai
2022-02-09 18:10 ` Jan Kara
2022-02-09 18:46   ` Qian Cai
2022-02-09 20:11   ` Paul E. McKenney
2022-02-10  5:07     ` Theodore Ts'o
2022-02-10  5:43       ` Paul E. McKenney
2022-02-10 15:54         ` Theodore Ts'o
2022-02-10  9:16     ` Jan Kara
2022-02-10 14:57       ` Paul E. McKenney
2022-02-10 19:12         ` Jan Kara
2022-02-10 20:06           ` Paul E. McKenney
2022-02-10 20:08             ` Paul E. McKenney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).