powerpc/pseries: explicitly reschedule during drmem_lmb list traversal
authorNathan Lynch <nathanl@linux.ibm.com>
Thu, 13 Aug 2020 15:11:31 +0000 (10:11 -0500)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 2 Sep 2020 01:00:20 +0000 (11:00 +1000)
commit9d6792ffe140240ae54c881cc4183f9acc24b4df
tree694db0983b6959d39b095081ed4ab068d0bba509
parente53281bc21f061f96c9004f534bc3e807d70cb73
powerpc/pseries: explicitly reschedule during drmem_lmb list traversal

The drmem lmb list can have hundreds of thousands of entries, and
unfortunately lookups take the form of linear searches. As long as
this is the case, traversals have the potential to monopolize the CPU
and provoke lockup reports, workqueue stalls, and the like unless
they explicitly yield.

Rather than placing cond_resched() calls within various
for_each_drmem_lmb() loop blocks in the code, put it in the iteration
expression of the loop macro itself so users can't omit it.

Introduce a drmem_lmb_next() iteration helper function which calls
cond_resched() at a regular interval during array traversal. Each
iteration of the loop in DLPAR code paths can involve around ten RTAS
calls which can each take up to 250us, so this ensures the check is
performed at worst every few milliseconds.

Fixes: 6c6ea53725b3 ("powerpc/mm: Separate ibm, dynamic-memory data from DT format")
Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200813151131.2070161-1-nathanl@linux.ibm.com
arch/powerpc/include/asm/drmem.h