Skip to content

Commit 949b932

Browse files
committed
memremap: fix softlockup reports at teardown
The cond_resched() currently in the setup path needs to be duplicated in the teardown path. Rather than require each instance of for_each_device_pfn() to open code the same sequence, embed it in the helper. Link: intel/ixpdimm_sw#11 Cc: "Jérôme Glisse" <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: <[email protected]> Fixes: 7138970 ("mm, zone_device: Replace {get, put}_zone_device_page()...") Signed-off-by: Dan Williams <[email protected]>
1 parent 5fdf8e5 commit 949b932

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

kernel/memremap.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,15 @@ static unsigned long pfn_end(struct dev_pagemap *pgmap)
275275
return (res->start + resource_size(res)) >> PAGE_SHIFT;
276276
}
277277

278+
static unsigned long pfn_next(unsigned long pfn)
279+
{
280+
if (pfn % 1024 == 0)
281+
cond_resched();
282+
return pfn + 1;
283+
}
284+
278285
#define for_each_device_pfn(pfn, map) \
279-
for (pfn = pfn_first(map); pfn < pfn_end(map); pfn++)
286+
for (pfn = pfn_first(map); pfn < pfn_end(map); pfn = pfn_next(pfn))
280287

281288
static void devm_memremap_pages_release(void *data)
282289
{
@@ -337,10 +344,10 @@ void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap)
337344
resource_size_t align_start, align_size, align_end;
338345
struct vmem_altmap *altmap = pgmap->altmap_valid ?
339346
&pgmap->altmap : NULL;
347+
struct resource *res = &pgmap->res;
340348
unsigned long pfn, pgoff, order;
341349
pgprot_t pgprot = PAGE_KERNEL;
342-
int error, nid, is_ram, i = 0;
343-
struct resource *res = &pgmap->res;
350+
int error, nid, is_ram;
344351

345352
align_start = res->start & ~(SECTION_SIZE - 1);
346353
align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE)
@@ -409,8 +416,6 @@ void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap)
409416
list_del(&page->lru);
410417
page->pgmap = pgmap;
411418
percpu_ref_get(pgmap->ref);
412-
if (!(++i % 1024))
413-
cond_resched();
414419
}
415420

416421
devm_add_action(dev, devm_memremap_pages_release, pgmap);

0 commit comments

Comments
 (0)