Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2548290ybl; Thu, 29 Aug 2019 09:36:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxHhxrWuYHhq3bys4bNIMCX00Cjz87GR6hmsjLIGi/XNNWDiQnvnVPBkpqYd90Bse3kflUE X-Received: by 2002:a17:90a:3321:: with SMTP id m30mr10937600pjb.2.1567096590462; Thu, 29 Aug 2019 09:36:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567096590; cv=none; d=google.com; s=arc-20160816; b=cQcBT/jsI0wzCI/kMeno2RMh+zi9lX83GAzQR7Noh/TFiywLJop6gA9mcsc+31DFBy MIQkEWz/GTIojy1D1y6ik1Z3kiELNTsEhbSYqfa+9FmbEqheJjX4VWM4Kyyio8OhyYCM ob9V56GBHn9dHKm58DcfThZ5lNBRc19BM3WiNib6UC5bwb9yLE4eVkpvmlfg8wWdOmeH dYwoiUMgKZUYHO1KaKWBD3ck1IWTHGdSEWQ3iHO5G50szdIfXrptQzXZ6vVFkud5PYB6 XWqrdwO2GHXltkeHQyBylEDufvQiCLkXWDgQNkQYiC2cUJ6Nv172gwmgC9G2q8aNPrz8 d6kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=rXp82d/Wh2JCj1MeKUCs7Dh59nPL823HHzcVIr15+Dw=; b=NpvfIFB//JJ1mt6xeI//wqR+mP7gJQ0KW8jgd/jlh2lPTUuM0Wf+WTuIb7mDHx7gcm 6q6V9JYbvbAStKYBxpJDDsf0X97oapDx8QSoFRy5u64bdDKQHi7IBSjs6xILrn1QuPCP naKe5lqcL7KqiU/r6S6JUiacdC6KnDcTVaVtUSSmAml8dhzKgl9WZ7npXjkbn9AAvYLF wjNUjWMenI04zUXBX3H8DFbOgpC0EGZbk1HmGH1QXFl3zf/rXialWHFtJDAh9xuiujOB UfHX5erbZCU12mr9pi1YV5/cDeKLXgFxmmtc+AXCEkABvPhMLamBv9VeT7/SYo6DAD+Y phnw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b13si2546841pgr.460.2019.08.29.09.36.15; Thu, 29 Aug 2019 09:36:30 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728019AbfH2Qew (ORCPT + 99 others); Thu, 29 Aug 2019 12:34:52 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39610 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727255AbfH2Qew (ORCPT ); Thu, 29 Aug 2019 12:34:52 -0400 Received: by mail-wr1-f66.google.com with SMTP id t16so4102868wra.6 for ; Thu, 29 Aug 2019 09:34:50 -0700 (PDT) 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:mime-version :content-transfer-encoding; bh=rXp82d/Wh2JCj1MeKUCs7Dh59nPL823HHzcVIr15+Dw=; b=VKCmFcb2S3Mq9p0LYLboYbF1qP2j2ZAI90ji5+u3zjlrgvn4r1GzZ8tkKfjOHAQK9k jhifUGueISlThco7jdJNNMTDvpopEugYlXhZB0zqyrE1lU/tBcOnopYKSR3+wPQOFSU3 YCKllvezZjVCA3NVD5+ZUEoi4Gu44Ekx71zpzhzNSLF5g3jviBoXUw1n3B8HFWQxpOnk UL5hTbiLHaU5Lw9wTJP+RYkUiYAqDdcLsK2Z7ieVGW1lCuXpPw4Mgd7/+wZ9jVcyM88Y p8pHyW3OGOF2BQayHUXJkRJPQqd4NvM2BwWXMF19E6PwdW1K/VeDczIx+XOIq2Ssn2o+ ZWtA== X-Gm-Message-State: APjAAAX4AESIvgFlOleTb3lKVCvAmsVx7MFeJmnhCINQqGsHV90kv7JC 6GIH3/YMPPSMqDTYCGGbRhQ= X-Received: by 2002:a5d:414f:: with SMTP id c15mr13062250wrq.248.1567096489955; Thu, 29 Aug 2019 09:34:49 -0700 (PDT) Received: from tiehlicka.suse.cz (ip-37-188-253-38.eurotel.cz. [37.188.253.38]) by smtp.gmail.com with ESMTPSA id z25sm3623081wml.5.2019.08.29.09.34.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 09:34:48 -0700 (PDT) From: Michal Hocko To: Andrew Morton Cc: David Rientjes , David Hildenbrand , , LKML , Michal Hocko Subject: [PATCH] mm, oom: consider present pages for the node size Date: Thu, 29 Aug 2019 18:34:43 +0200 Message-Id: <20190829163443.899-1-mhocko@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michal Hocko constrained_alloc calculates the size of the oom domain by using node_spanned_pages which is incorrect because this is the full range of the physical memory range that the numa node occupies rather than the memory that backs that range which is represented by node_present_pages. Sparsely populated nodes (e.g. after memory hot remove or simply sparse due to memory layout) can have really a large difference between the two. This shouldn't really cause any real user observable problems because the oom calculates a ratio against totalpages and used memory cannot exceed present pages but it is confusing and wrong from code point of view. Noticed-by: David Hildenbrand Signed-off-by: Michal Hocko --- mm/oom_kill.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index eda2e2a0bdc6..16af3da97d08 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -287,7 +287,7 @@ static enum oom_constraint constrained_alloc(struct oom_control *oc) !nodes_subset(node_states[N_MEMORY], *oc->nodemask)) { oc->totalpages = total_swap_pages; for_each_node_mask(nid, *oc->nodemask) - oc->totalpages += node_spanned_pages(nid); + oc->totalpages += node_present_pages(nid); return CONSTRAINT_MEMORY_POLICY; } @@ -300,7 +300,7 @@ static enum oom_constraint constrained_alloc(struct oom_control *oc) if (cpuset_limited) { oc->totalpages = total_swap_pages; for_each_node_mask(nid, cpuset_current_mems_allowed) - oc->totalpages += node_spanned_pages(nid); + oc->totalpages += node_present_pages(nid); return CONSTRAINT_CPUSET; } return CONSTRAINT_NONE; -- 2.20.1