The patch titled Subject: mm/vmscan.c: avoid possible deadlock caused by too_many_isolated() has been added to the -mm tree. Its filename is mm-avoid-possible-deadlock-caused-by-too_many_isolated.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Fengguang Wu <fengguang.wu@xxxxxxxxx> Subject: mm/vmscan.c: avoid possible deadlock caused by too_many_isolated() Neil found that if too_many_isolated() returns true while performing direct reclaim we can end up waiting for other threads to complete their direct reclaim. If those threads are allowed to enter the FS or IO to free memory, but this thread is not, then it is possible that those threads will be waiting on this thread and so we get a circular deadlock. some task enters direct reclaim with GFP_KERNEL => too_many_isolated() false => vmscan and run into dirty pages => pageout() => take some FS lock => fs/block code does GFP_NOIO allocation => enter direct reclaim again => too_many_isolated() true => waiting for others to progress, however the other tasks may be circular waiting for the FS lock.. The fix is to let !__GFP_IO and !__GFP_FS direct reclaims enjoy higher priority than normal ones, by lowering the throttle threshold for the latter. Allowing ~1/8 isolated pages in normal is large enough. For example, for a 1GB LRU list, that's ~128MB isolated pages, or 1k blocked tasks (each isolates 32 4KB pages), or 64 blocked tasks per logical CPU (assuming 16 logical CPUs per NUMA node). So it's not likely some CPU goes idle waiting (when it could make progress) because of this limit: there are much more sleeping reclaim tasks than the number of CPU, so the task may well be blocked by some low level queue/lock anyway. Now !GFP_IOFS reclaims won't be waiting for GFP_IOFS reclaims to progress. They will be blocked only when there are too many concurrent !GFP_IOFS reclaims, however that's very unlikely because the IO-less direct reclaims is able to progress much more faster, and they won't deadlock each other. The threshold is raised high enough for them, so that there can be sufficient parallel progress of !GFP_IOFS reclaims. Signed-off-by: Wu Fengguang <fengguang.wu@xxxxxxxxx> Cc: Torsten Kaiser <just.for.lkml@xxxxxxxxxxxxxx> Tested-by: NeilBrown <neilb@xxxxxxx> Reviewed-by: Minchan Kim <minchan.kim@xxxxxxxxx> Acked-by: KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx> Acked-by: Rik van Riel <riel@xxxxxxxxxx> Cc: Mel Gorman <mel@xxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/vmscan.c | 7 +++++++ 1 file changed, 7 insertions(+) diff -puN mm/vmscan.c~mm-avoid-possible-deadlock-caused-by-too_many_isolated mm/vmscan.c --- a/mm/vmscan.c~mm-avoid-possible-deadlock-caused-by-too_many_isolated +++ a/mm/vmscan.c @@ -1202,6 +1202,13 @@ static int too_many_isolated(struct zone isolated = zone_page_state(zone, NR_ISOLATED_ANON); } + /* + * GFP_NOIO/GFP_NOFS callers are allowed to isolate more pages, so that + * they won't get blocked by normal ones and form circular deadlock. + */ + if ((sc->gfp_mask & GFP_IOFS) == GFP_IOFS) + inactive >>= 3; + return isolated > inactive; } _ Patches currently in -mm which might be from fengguang.wu@xxxxxxxxx are origin.patch linux-next.patch h8300-select-generic-atomic64_t-support.patch vmscan-comment-too_many_isolated.patch mm-avoid-possible-deadlock-caused-by-too_many_isolated.patch mm-avoid-possible-deadlock-caused-by-too_many_isolated-fix.patch swap-add-a-simple-detector-for-inappropriate-swapin-readahead.patch swap-add-a-simple-detector-for-inappropriate-swapin-readahead-fix.patch hfsplus-rework-functionality-of-getting-setting-and-deleting-of-extended-attributes-fix.patch fs-notify-add-procfs-fdinfo-helper-v7-fix-fix.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html