Received: by 10.192.165.148 with SMTP id m20csp328685imm; Thu, 3 May 2018 21:31:40 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqGaWrDh4talUKFi2iSaIx6L76Tl9KvsCPdC4nKLMRrWjk+j4xprtUQik8NNPd7Yfy+KKd5 X-Received: by 2002:a63:6a08:: with SMTP id f8-v6mr19422658pgc.363.1525408300701; Thu, 03 May 2018 21:31:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525408300; cv=none; d=google.com; s=arc-20160816; b=BrgJ1FPako3/5IoUdXlJeMJ6YVL0LedkOlEPliVP/wVCDuhWMnrzYlNREhiZNWlvvz ylvu7atFk3BxzW3YQf/+4IPHVfxOl5fw/K6KughoSUlOps+X4tEHv+w9FJCBV72Ly1Dp bymj8zXVqU+lMno5EODF0QmtbvwG46qYgbkHzneH35Q052BSgfs6FrUajPzTv9pJdrZK so8WbY1stOGQ59f+ghPNZtfXCftSFQx4Ss5RE6K+XqOnNAMUWaX1mTI0syeKS+CGJilG oxufoRA9zXNb3X/sMzPXxvacmFCAIAfiXsQ5gjlBD8tkkJa+S7LUrUkn7Ma7qLOAA2Nm FTaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=jWjdlXOtQiuACsvKk3omekLDOZaV9QA4MFcKgf/t2kc=; b=jHFyniSYfKNHwY0cKUB7IyCSuYgsDZi2AVrTbEh2DmWQNd8h2x6OWBFQqJdM2MCGVo lkR+hDV+nRLXLI1Y0IwNrOXmS7X8x34HMTXutnJ7LZXFZ/B/lAmDdXv69e6Be3UuuEbn z0JYJoQLDgk9nCH93hG1rV12+bhsDofIuTxiKkleluW9JgPTICiX4zgKsvlftXHwsdq6 HBVxLIMrJYqKa2eWU4xDUyLmqWuieQDSPXgCe8P12eFD4tedOFsxtGUb/hAsvA2Ab2sI HHATPZ7fHl70tkL/gPr1fVSTxdlwOYzKDHICnp4O1/azGt5iuf178OJhxcWD/8FnxGQ9 T4fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KvLo4p8G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q23si15056776pfd.153.2018.05.03.21.31.26; Thu, 03 May 2018 21:31:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KvLo4p8G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751277AbeEDEa5 (ORCPT + 99 others); Fri, 4 May 2018 00:30:57 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:33653 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750820AbeEDEa4 (ORCPT ); Fri, 4 May 2018 00:30:56 -0400 Received: by mail-pg0-f67.google.com with SMTP id i194-v6so14629523pgd.0 for ; Thu, 03 May 2018 21:30:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=jWjdlXOtQiuACsvKk3omekLDOZaV9QA4MFcKgf/t2kc=; b=KvLo4p8GFTZWW03WWqH/mnKfWrNwdh/bw3itDGv1z/jzcMH7s12enlXpVfAwxlRQWu zsO9AHtrbE5PEozH7vLoP5v3S1CstRmkw6/s0RkNICVjTwvEY0wOF9f/ZTJJt3mxq19y vjwZE8u2chWFvjqzXOZIFej+K9rirpykHYL84ZCd4vKY6VDWrbTwXDgMsYeArSSaqGKF 1Xm1TgEoQB4JUd2SynT0rGy/1jy2qFIuwkPT+3suFPOAS8A85hiXBIO49BI3slAxYbEq 3OSQyxLenf/Da1e3ohUoDwrGtQ/iUy0WvvmszotSi764zZl0Eyb0Nuh6qWYEYifaCzIO PVhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=jWjdlXOtQiuACsvKk3omekLDOZaV9QA4MFcKgf/t2kc=; b=m5keSUJKdQmdZiukTOigawdUdBxfQotuIuDsiwgE8Aiy3lASEQlCfKfrrtBEPqwDUD +RU3hDsmmiw8909KdTPPPcGo52n3BlQI32dbNkbXjWwWLjumpr3/wsA7WrhP6MX8O0ls yzEBP27hxQiQQxMkHuYjbHKyIxJgbtYjZlMs9dB2Ye3eqIoRotCSIzia4fAb6viWgoGE Ju/ZZWXXULltNzbwVMz/hPmTMnmy89POl0SREuliJr9fimf+Wl3bpAMavYnCCOJFX1ss P4EqchVZs17WriRAMS/H26xGRAyoUyklojh4KNKUwjtaLtaxROD/W3qPBLvGfmvVx3gu LxJw== X-Gm-Message-State: ALQs6tAreM1Rp/5NIwRpRpKD4RT0ZRmtwgkzT+ZoIivG++Uf9RKqLEwd vq5YlJT7J0324isCaittMXUOyg== X-Received: by 2002:a17:902:322:: with SMTP id 31-v6mr26148074pld.122.1525408255894; Thu, 03 May 2018 21:30:55 -0700 (PDT) Received: from localhost.localdomain ([124.56.155.17]) by smtp.gmail.com with ESMTPSA id v23sm27430777pfe.166.2018.05.03.21.30.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 May 2018 21:30:54 -0700 (PDT) From: js1304@gmail.com X-Google-Original-From: iamjoonsoo.kim@lge.com To: Andrew Morton Cc: Mel Gorman , Michal Hocko , Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Johannes Weiner , Minchan Kim , Ye Xiaolong , Joonsoo Kim Subject: [PATCH] mm/page_alloc: use ac->high_zoneidx for classzone_idx Date: Fri, 4 May 2018 13:30:46 +0900 Message-Id: <1525408246-14768-1-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joonsoo Kim Currently, we use the zone index of preferred_zone which represents the best matching zone for allocation, as classzone_idx. It has a problem on NUMA system with ZONE_MOVABLE. In NUMA system, it can be possible that each node has different populated zones. For example, node 0 could have DMA/DMA32/NORMAL/MOVABLE zone and node 1 could have only NORMAL zone. In this setup, allocation request initiated on node 0 and the one on node 1 would have different classzone_idx, 3 and 2, respectively, since their preferred_zones are different. If they are handled by only their own node, there is no problem. However, if they are somtimes handled by the remote node, the problem would happen. In the following setup, allocation initiated on node 1 will have some precedence than allocation initiated on node 0 when former allocation is processed on node 0 due to not enough memory on node 1. They will have different lowmem reserve due to their different classzone_idx thus an watermark bars are also different. root@ubuntu:/sys/devices/system/memory# cat /proc/zoneinfo Node 0, zone DMA per-node stats ... pages free 3965 min 5 low 8 high 11 spanned 4095 present 3998 managed 3977 protection: (0, 2961, 4928, 5440) ... Node 0, zone DMA32 pages free 757955 min 1129 low 1887 high 2645 spanned 1044480 present 782303 managed 758116 protection: (0, 0, 1967, 2479) ... Node 0, zone Normal pages free 459806 min 750 low 1253 high 1756 spanned 524288 present 524288 managed 503620 protection: (0, 0, 0, 4096) ... Node 0, zone Movable pages free 130759 min 195 low 326 high 457 spanned 1966079 present 131072 managed 131072 protection: (0, 0, 0, 0) ... Node 1, zone DMA pages free 0 min 0 low 0 high 0 spanned 0 present 0 managed 0 protection: (0, 0, 1006, 1006) Node 1, zone DMA32 pages free 0 min 0 low 0 high 0 spanned 0 present 0 managed 0 protection: (0, 0, 1006, 1006) Node 1, zone Normal per-node stats ... pages free 233277 min 383 low 640 high 897 spanned 262144 present 262144 managed 257744 protection: (0, 0, 0, 0) ... Node 1, zone Movable pages free 0 min 0 low 0 high 0 spanned 262144 present 0 managed 0 protection: (0, 0, 0, 0) min watermark for NORMAL zone on node 0 allocation initiated on node 0: 750 + 4096 = 4846 allocation initiated on node 1: 750 + 0 = 750 This watermark difference could cause too many numa_miss allocation in some situation and then performance could be downgraded. Recently, there was a regression report about this problem on CMA patches since CMA memory are placed in ZONE_MOVABLE by those patches. I checked that problem is disappeared with this fix that uses high_zoneidx for classzone_idx. http://lkml.kernel.org/r/20180102063528.GG30397@yexl-desktop Using high_zoneidx for classzone_idx is more consistent way than previous approach because system's memory layout doesn't affect anything to it. With this patch, both classzone_idx on above example will be 3 so will have the same min watermark. allocation initiated on node 0: 750 + 4096 = 4846 allocation initiated on node 1: 750 + 4096 = 4846 Reported-by: Ye Xiaolong Tested-by: Ye Xiaolong Signed-off-by: Joonsoo Kim --- mm/internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/internal.h b/mm/internal.h index 228dd66..e1d7376 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -123,7 +123,7 @@ struct alloc_context { bool spread_dirty_pages; }; -#define ac_classzone_idx(ac) zonelist_zone_idx(ac->preferred_zoneref) +#define ac_classzone_idx(ac) (ac->high_zoneidx) /* * Locate the struct page for both the matching buddy in our -- 2.7.4