Issue
I used find_get_entries()
to retrieve pagecache pages associated with all opened files. For each retrieved page, a put_page()
invocation will be needed to revert the page reference count to its previous state. find_get_entries()
seems to be racy. In some scenarios, the returned struct page *
element contains garbage (perhaps because the page associated with an index has been evicted). Therefore, a put_page()
call on such a page will cause kernel panic. How can I avoid this situation?
Solution
It seems that the shadow entries of recently evicted pages, etc. (recognized by calling xa_is_value()
) will also be returned in the entries
parameter. They can be identified and ignored by checking their LSB (i.e., if (unsigned long)entries[i] & 1
is not zero, the element is not a valid page).
Answered By - TheAhmad Answer Checked By - Terry (WPSolving Volunteer)