From patchwork Thu Aug 29 16:34:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 11121867 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0DF4E1395 for ; Thu, 29 Aug 2019 16:34:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CF4A421874 for ; Thu, 29 Aug 2019 16:34:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CF4A421874 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0EFC56B0003; Thu, 29 Aug 2019 12:34:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 09F746B0005; Thu, 29 Aug 2019 12:34:52 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF7246B0008; Thu, 29 Aug 2019 12:34:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0153.hostedemail.com [216.40.44.153]) by kanga.kvack.org (Postfix) with ESMTP id CDCC66B0003 for ; Thu, 29 Aug 2019 12:34:51 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 812CD82437C9 for ; Thu, 29 Aug 2019 16:34:51 +0000 (UTC) X-FDA: 75876014382.28.burst58_4778c3b83f33f X-Spam-Summary: 2,0,0,6fa9047dd85b9dca,d41d8cd98f00b204,mstsxfx@gmail.com,:akpm@linux-foundation.org:rientjes@google.com:david@redhat.com::linux-kernel@vger.kernel.org:mhocko@suse.com,RULES_HIT:41:355:379:541:800:960:968:973:988:989:1260:1311:1314:1345:1437:1515:1534:1541:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3871:3872:3874:4321:5007:6261:7576:7903:8603:10004:10128:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12895:13069:13161:13208:13229:13311:13357:13894:14181:14384:14394:14721:21063:21067:21080:21444:21451:21627:21790:21795:30012:30051:30054,0,RBL:error,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:28,LUA_SUMMARY:none X-HE-Tag: burst58_4778c3b83f33f X-Filterd-Recvd-Size: 3945 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Thu, 29 Aug 2019 16:34:51 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id s18so4143848wrn.1 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=NQ7ieNKdg8Dc/eWF44C4KCALUopoB5+nZ27hFF4xuvbUO9SamjkStPDYYMLL6htksa 1ccyreYGaL4J7/un6tD2z2CeY9UtItvQgjOvuUitOe2TQYfHMIGVvebXfignyV83F7xW SopwwHXmm7S0oIuAjq+cAaFhic2YJ1W3zkkCQ9F1eC60ZwBCxpkksB+C2w9CmaCi2oAD ObpusK2GTM2+gKaAZaGtpmIwisSQPpX7XMkwVxup6uZE33Fc0MiyLC38wro4zZ1bBiuo COjlFLRnDC2Ed47nb8gs82GWcslT+uxsUWB7n5YOACLyvvLhXzazi4j9BcOBJD7RcRqI RA4g== X-Gm-Message-State: APjAAAWl3KI6H0qHID0LKYTLgXaCknOLDaazrBvCzvBj2iDpYb/mY+5f TjbCjbkaq6Hbj2XzKYba/Y0= X-Google-Smtp-Source: APXvYqywxm1LMKB2iR0OTC1ykV3jOzNzHtzu435QnQl4bZncpfWFDjKeO3SolUO0I3KlMVVZLyo6kg== 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Reviewed-by: David Hildenbrand Acked-by: David Rientjes --- 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;