Skip to content

Commit b1cf3e9

Browse files
nathanlynchgregkh
authored andcommitted
powerpc/pseries: explicitly reschedule during drmem_lmb list traversal
[ Upstream commit 9d6792f ] 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: 6c6ea53 ("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 Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 78805c0 commit b1cf3e9

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

‎arch/powerpc/include/asm/drmem.h‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#ifndef _ASM_POWERPC_LMB_H
99
#define _ASM_POWERPC_LMB_H
1010

11+
#include <linux/sched.h>
12+
1113
struct drmem_lmb {
1214
u64 base_addr;
1315
u32 drc_index;
@@ -26,8 +28,22 @@ struct drmem_lmb_info {
2628

2729
extern struct drmem_lmb_info *drmem_info;
2830

31+
static inline struct drmem_lmb *drmem_lmb_next(struct drmem_lmb *lmb,
32+
const struct drmem_lmb *start)
33+
{
34+
/*
35+
* DLPAR code paths can take several milliseconds per element
36+
* when interacting with firmware. Ensure that we don't
37+
* unfairly monopolize the CPU.
38+
*/
39+
if (((++lmb - start) % 16) == 0)
40+
cond_resched();
41+
42+
return lmb;
43+
}
44+
2945
#define for_each_drmem_lmb_in_range(lmb, start, end) \
30-
for ((lmb) = (start); (lmb) < (end); (lmb)++)
46+
for ((lmb) = (start); (lmb) < (end); lmb = drmem_lmb_next(lmb, start))
3147

3248
#define for_each_drmem_lmb(lmb) \
3349
for_each_drmem_lmb_in_range((lmb), \

0 commit comments

Comments
 (0)