Commit 0e988646 authored by Hugh Dickins's avatar Hugh Dickins Committed by Treehugger Robot
Browse files

UPSTREAM: shmem: fix smaps BUG sleeping while atomic

smaps_pte_hole_lookup() is calling shmem_partial_swap_usage() with page
table lock held: but shmem_partial_swap_usage() does cond_resched_rcu() if
need_resched(): "BUG: sleeping function called from invalid context".

Since shmem_partial_swap_usage() is designed to count across a range, but
smaps_pte_hole_lookup() only calls it for a single page slot, just break
out of the loop on the last or only page, before checking need_resched().

Bug: 302977171
Bug: 304925865

Link: https://lkml.kernel.org/r/6fe3b3ec-abdf-332f-5c23-6a3b3a3b11a9@google.com


(cherry picked from commit e5548f85)
Fixes: 23010032 ("mm/smaps: simplify shmem handling of pte holes")
Change-Id: I1b59341c954cb7eb31709ba0dcc65ec6e67c58c6
Signed-off-by: default avatarHugh Dickins <hughd@google.com>
Acked-by: default avatarPeter Xu <peterx@redhat.com>
Cc: <stable@vger.kernel.org>	[5.16+]
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
(cherry picked from commit cf1ba6a1)
parent 634cf934
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment