Hi Waiman,With the below timing sequence:
On 6/26/2024 5:46 AM, Waiman Long wrote:
Commit 5ec8e8ea8b77 ("mm/sparsemem: fix race in accessingI am unable to see a scenario where ms->usage will be NULL when
memory_section->usage") changed pfn_section_valid() to add a READ_ONCE()
call around "ms->usage" to fix a race with section_deactivate() where
ms->usage can be cleared. The READ_ONCE() call, by itself, is not enough
to prevent NULL pointer dereference. We need to check its value before
dereferencing it.
pfn_section_valid() is called:
1) In pfn_valid, valid_section() check ensures that pfn_section_valid()
is not called as the section is marked as invalid.
2) In pfn_to_online_page, online_section() check ensures that
pfn_section_valid() is not called.
and in the update path, we do:
kfree_rcu(ms->usage, rcu);
WRITE_ONCE(ms->usage, NULL);
Could you help me in understanding about what I am missing here, please?