[Devel] [PATCH rh7] mm/mempolicy: Add cond_resched() in queue_pages_pte_range()

Andrey Ryabinin aryabinin at virtuozzo.com
Mon Dec 18 13:27:42 MSK 2017


Migrating huge range of memory may take quite some time, and
with lack of resched point it may cause softlockup.

NMI watchdog: BUG: soft lockup - CPU#57 stuck for 22s! [vcmmd:1942]
RIP: 0010:[<ffffffff811a7c06>]  [<ffffffff811a7c06>] isolate_lru_page+0x86/0x1c0
...
Call Trace:
 queue_pages_range+0x481/0x6d0
 migrate_to_node+0x79/0xe0
 do_migrate_pages+0x268/0x2d0
 cpuset_migrate_mm+0xcc/0xf0
 cpuset_change_nodemask+0x8e/0x90
 cgroup_scan_tasks+0x147/0x200
 update_tasks_nodemask+0x4b/0x70
 cpuset_migrate_mm+0xf0/0xf0
 cpuset_write_resmask+0x6b4/0x6f0
 lru_cache_add_active_or_unevictable+0x27/0xb0
 cgroup_rightmost_descendant+0x80/0x80
 cpuset_css_offline+0x50/0x50
 cgroup_file_write+0x1fe/0x2f0
 sb_start_write+0x58/0x110
 vfs_write+0xbd/0x1e0
 SyS_write+0x7f/0xe0
 system_call_fastpath+0x16/0x1b

Add cond_resched() to fix that.

Upstream got similar cond_resched() in commit
6f4576e3687b ("mempolicy: apply page table walker on queue_pages_range()")

https://jira.sw.ru/browse/PSBM-79273
Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
---
 mm/mempolicy.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 9b0dcf1835c4..7bf644c82837 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -513,6 +513,7 @@ static int queue_pages_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
 			break;
 	} while (pte++, addr += PAGE_SIZE, addr != end);
 	pte_unmap_unlock(orig_pte, ptl);
+	cond_resched();
 	return addr != end;
 }
 
-- 
2.13.6



More information about the Devel mailing list