Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/mmu_notifiers: use hlist_for_each_entry_srcu() for SRCU list traversal

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.

Link: https://lkml.kernel.org/r/20260204080937.2472-1-lirongqing@baidu.com
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Acked-by: SeongJae Park <sj@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Li RongQing and committed by
Andrew Morton
b0fbe8c3 80a4bcac

+9 -9
+9 -9
mm/mmu_notifier.c
··· 309 309 * ->release returns. 310 310 */ 311 311 id = srcu_read_lock(&srcu); 312 - hlist_for_each_entry_rcu(subscription, &subscriptions->list, hlist, 312 + hlist_for_each_entry_srcu(subscription, &subscriptions->list, hlist, 313 313 srcu_read_lock_held(&srcu)) 314 314 /* 315 315 * If ->release runs before mmu_notifier_unregister it must be ··· 372 372 int young = 0, id; 373 373 374 374 id = srcu_read_lock(&srcu); 375 - hlist_for_each_entry_rcu(subscription, 375 + hlist_for_each_entry_srcu(subscription, 376 376 &mm->notifier_subscriptions->list, hlist, 377 377 srcu_read_lock_held(&srcu)) { 378 378 if (subscription->ops->clear_flush_young) ··· 392 392 int young = 0, id; 393 393 394 394 id = srcu_read_lock(&srcu); 395 - hlist_for_each_entry_rcu(subscription, 395 + hlist_for_each_entry_srcu(subscription, 396 396 &mm->notifier_subscriptions->list, hlist, 397 397 srcu_read_lock_held(&srcu)) { 398 398 if (subscription->ops->clear_young) ··· 411 411 int young = 0, id; 412 412 413 413 id = srcu_read_lock(&srcu); 414 - hlist_for_each_entry_rcu(subscription, 414 + hlist_for_each_entry_srcu(subscription, 415 415 &mm->notifier_subscriptions->list, hlist, 416 416 srcu_read_lock_held(&srcu)) { 417 417 if (subscription->ops->test_young) { ··· 466 466 int id; 467 467 468 468 id = srcu_read_lock(&srcu); 469 - hlist_for_each_entry_rcu(subscription, &subscriptions->list, hlist, 469 + hlist_for_each_entry_srcu(subscription, &subscriptions->list, hlist, 470 470 srcu_read_lock_held(&srcu)) { 471 471 const struct mmu_notifier_ops *ops = subscription->ops; 472 472 ··· 504 504 * notifiers and one or more failed start, any that succeeded 505 505 * start are expecting their end to be called. Do so now. 506 506 */ 507 - hlist_for_each_entry_rcu(subscription, &subscriptions->list, 507 + hlist_for_each_entry_srcu(subscription, &subscriptions->list, 508 508 hlist, srcu_read_lock_held(&srcu)) { 509 509 if (!subscription->ops->invalidate_range_end) 510 510 continue; ··· 542 542 int id; 543 543 544 544 id = srcu_read_lock(&srcu); 545 - hlist_for_each_entry_rcu(subscription, &subscriptions->list, hlist, 545 + hlist_for_each_entry_srcu(subscription, &subscriptions->list, hlist, 546 546 srcu_read_lock_held(&srcu)) { 547 547 if (subscription->ops->invalidate_range_end) { 548 548 if (!mmu_notifier_range_blockable(range)) ··· 577 577 int id; 578 578 579 579 id = srcu_read_lock(&srcu); 580 - hlist_for_each_entry_rcu(subscription, 580 + hlist_for_each_entry_srcu(subscription, 581 581 &mm->notifier_subscriptions->list, hlist, 582 582 srcu_read_lock_held(&srcu)) { 583 583 if (subscription->ops->arch_invalidate_secondary_tlbs) ··· 713 713 struct mmu_notifier *subscription; 714 714 715 715 spin_lock(&mm->notifier_subscriptions->lock); 716 - hlist_for_each_entry_rcu(subscription, 716 + hlist_for_each_entry_srcu(subscription, 717 717 &mm->notifier_subscriptions->list, hlist, 718 718 lockdep_is_held(&mm->notifier_subscriptions->lock)) { 719 719 if (subscription->ops != ops)