From nobody Sun Feb 8 11:41:17 2026 Received: from outbound.baidu.com (mx24.baidu.com [111.206.215.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6382C36A027 for ; Wed, 4 Feb 2026 08:11:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=111.206.215.185 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770192668; cv=none; b=u3mSPwAbO9+KMXl82y1u5GRqYyAp6WAKJzVJOIrubReoWSaz/I71rVQsLNPVsT+GnB+nMuAMgipuoJcWLEuC4DfMKUNmb2CcTg1e1NF7YnWU9rqGJ7zxASDT3a7dd3lT70FhFs8fLRIzk/WxZVgjGAM6J/z7S3McVCfAeZB4LIA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770192668; c=relaxed/simple; bh=TyIqDDdys1/joSGFRPMTz9SbnMrRjjzA+Kbp8kHPpss=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=jUD4BEXBDcxpAAM45rmCSoJzzTZbD9FIGSbXXYCkVNge9jQvzSc2bLWVvX14uP0sM8UYnQ49rMNH24Kn+iYJqE047x6mF4mtTVNRIP+ZhYKJv5Khfs3xDr//w2zb9LCUKZmgIHyRT5FER5pB4iq1lzSe+EIwULg8TjHOmpuz6o4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=baidu.com; spf=pass smtp.mailfrom=baidu.com; arc=none smtp.client-ip=111.206.215.185 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=baidu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baidu.com From: lirongqing To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R . Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , , CC: Li RongQing Subject: [PATCH] mm/mmu_notifiers: Use hlist_for_each_entry_srcu() for SRCU list traversal Date: Wed, 4 Feb 2026 03:09:37 -0500 Message-ID: <20260204080937.2472-1-lirongqing@baidu.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: bjhj-exc9.internal.baidu.com (172.31.3.19) To bjkjy-exc3.internal.baidu.com (172.31.50.47) X-FEAS-Client-IP: 172.31.50.47 X-FE-Policy-ID: 52:10:53:SYSTEM Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Li RongQing The mmu_notifier_subscriptions list is protected by SRCU. While the current code uses hlist_for_each_entry_rcu() with an explicit SRCU lockdep check, it is more appropriate to use the dedicated hlist_for_each_entry_srcu() macro. This change aligns the code with the preferred kernel API for SRCU-protected lists, improving code clarity and ensuring that the synchronization method is explicitly documented by the iterator name itself. Signed-off-by: Li RongQing Acked-by: SeongJae Park --- mm/mmu_notifier.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c index 8e0125d..2a2a582 100644 --- a/mm/mmu_notifier.c +++ b/mm/mmu_notifier.c @@ -309,7 +309,7 @@ static void mn_hlist_release(struct mmu_notifier_subscr= iptions *subscriptions, * ->release returns. */ id =3D srcu_read_lock(&srcu); - hlist_for_each_entry_rcu(subscription, &subscriptions->list, hlist, + hlist_for_each_entry_srcu(subscription, &subscriptions->list, hlist, srcu_read_lock_held(&srcu)) /* * If ->release runs before mmu_notifier_unregister it must be @@ -372,7 +372,7 @@ int __mmu_notifier_clear_flush_young(struct mm_struct *= mm, int young =3D 0, id; =20 id =3D srcu_read_lock(&srcu); - hlist_for_each_entry_rcu(subscription, + hlist_for_each_entry_srcu(subscription, &mm->notifier_subscriptions->list, hlist, srcu_read_lock_held(&srcu)) { if (subscription->ops->clear_flush_young) @@ -392,7 +392,7 @@ int __mmu_notifier_clear_young(struct mm_struct *mm, int young =3D 0, id; =20 id =3D srcu_read_lock(&srcu); - hlist_for_each_entry_rcu(subscription, + hlist_for_each_entry_srcu(subscription, &mm->notifier_subscriptions->list, hlist, srcu_read_lock_held(&srcu)) { if (subscription->ops->clear_young) @@ -411,7 +411,7 @@ int __mmu_notifier_test_young(struct mm_struct *mm, int young =3D 0, id; =20 id =3D srcu_read_lock(&srcu); - hlist_for_each_entry_rcu(subscription, + hlist_for_each_entry_srcu(subscription, &mm->notifier_subscriptions->list, hlist, srcu_read_lock_held(&srcu)) { if (subscription->ops->test_young) { @@ -466,7 +466,7 @@ static int mn_hlist_invalidate_range_start( int id; =20 id =3D srcu_read_lock(&srcu); - hlist_for_each_entry_rcu(subscription, &subscriptions->list, hlist, + hlist_for_each_entry_srcu(subscription, &subscriptions->list, hlist, srcu_read_lock_held(&srcu)) { const struct mmu_notifier_ops *ops =3D subscription->ops; =20 @@ -504,7 +504,7 @@ static int mn_hlist_invalidate_range_start( * notifiers and one or more failed start, any that succeeded * start are expecting their end to be called. Do so now. */ - hlist_for_each_entry_rcu(subscription, &subscriptions->list, + hlist_for_each_entry_srcu(subscription, &subscriptions->list, hlist, srcu_read_lock_held(&srcu)) { if (!subscription->ops->invalidate_range_end) continue; @@ -542,7 +542,7 @@ mn_hlist_invalidate_end(struct mmu_notifier_subscriptio= ns *subscriptions, int id; =20 id =3D srcu_read_lock(&srcu); - hlist_for_each_entry_rcu(subscription, &subscriptions->list, hlist, + hlist_for_each_entry_srcu(subscription, &subscriptions->list, hlist, srcu_read_lock_held(&srcu)) { if (subscription->ops->invalidate_range_end) { if (!mmu_notifier_range_blockable(range)) @@ -577,7 +577,7 @@ void __mmu_notifier_arch_invalidate_secondary_tlbs(stru= ct mm_struct *mm, int id; =20 id =3D srcu_read_lock(&srcu); - hlist_for_each_entry_rcu(subscription, + hlist_for_each_entry_srcu(subscription, &mm->notifier_subscriptions->list, hlist, srcu_read_lock_held(&srcu)) { if (subscription->ops->arch_invalidate_secondary_tlbs) @@ -714,7 +714,7 @@ find_get_mmu_notifier(struct mm_struct *mm, const struc= t mmu_notifier_ops *ops) struct mmu_notifier *subscription; =20 spin_lock(&mm->notifier_subscriptions->lock); - hlist_for_each_entry_rcu(subscription, + hlist_for_each_entry_srcu(subscription, &mm->notifier_subscriptions->list, hlist, lockdep_is_held(&mm->notifier_subscriptions->lock)) { if (subscription->ops !=3D ops) --=20 2.9.4