• SeongJae Park's avatar
    mm/page_reporting: replace rcu_access_pointer() with rcu_dereference_protected() · 01b5022f
    SeongJae Park authored
    Page reporting fetches pr_dev_info using rcu_access_pointer(), which is
    for safely fetching a pointer that will not be dereferenced but could
    concurrently updated.  The code indeed does not dereference pr_dev_info
    after fetching it using rcu_access_pointer(), but it fetches the pointer
    while concurrent updates to the pointer is avoided by holding the update
    side lock, page_reporting_mutex.
    
    In the case, rcu_dereference_protected() should be used instead because it
    provides better readability and performance on some cases, as
    rcu_dereference_protected() avoids use of READ_ONCE().  Replace the
    rcu_access_pointer() calls with rcu_dereference_protected().
    
    Link: https://lkml.kernel.org/r/20221228175942.149491-1-sj@kernel.org
    Fixes: 36e66c55 ("mm: introduce Reported pages")
    Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
    Cc: Alexander Duyck <alexander.h.duyck@linux.intel.com>
    Cc: Matthew Wilcox <willy@infradead.org>
    Cc: Miaohe Lin <linmiaohe@huawei.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    01b5022f
page_reporting.c 11.6 KB