Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2541003pxb; Sun, 23 Jan 2022 07:57:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJynUqrrrwb8X0RkZmans/cwutP8GQUKZXYbq0UVDFzLwTDTl57NS7+pEkBTRcWY4tatSFLX X-Received: by 2002:a17:902:e80b:b0:14b:4648:f6e3 with SMTP id u11-20020a170902e80b00b0014b4648f6e3mr3263062plg.32.1642953451754; Sun, 23 Jan 2022 07:57:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642953451; cv=none; d=google.com; s=arc-20160816; b=igeNILdj+eYbqt/sMluMcAbhhlX6v51QvG44krCI21OvmVbVauvhvLdChwbk16Ts0Z 0eW5vGiKi8+yfVHS0hicd2+/1sKb3KwvcNBQ7XmVaq1STVzH0oEShVM25v3cKB8leu9l Cmz+qKwX3QfBhoaokW7/X58MjiSV0hol0vxrYS0DfmdjUKzU8qVMqIPKeuTJNSNrlHE4 lwZ+2TMWgKV89j7foHd4XZJ22KK2ljB/l9Oi7jzw0SvBGvSTVjDnxeo8S3bNNNcWvbA6 Kr6yieqANEz8gkYhj2m7tMPlMGpGHk6Vp94e9zir1e1Nmu+JDAPSvRdGxqYNMDPRgJax 9Mww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=VhpcLgiTZRWgcJmPmiVIMS50KRCO7XHLKSYxNUWC3Pk=; b=LGR75h3Vg8FiTsJrawqZUHHbs117GiovahBYNLKD8SDCspd+BJjHeM3/2D248v7EPQ nJ+2RVFbv6j1XfJ4EpiKfLSrvQuoh3AZZmmvotZ3jVXxgPB0pSiKZVmHAONH2KXuMnkC Li57ODur+Dt0LeU9Zo7w77qaPFUf1AqdnK8Ln/vaiHpZMCHKxu4IrOaKw8X5PX+Pa+RP jACzPDy3IlzZPFQ5Nz71bzZto6jWswSjcOVYQBxAuSTS/e34oRMYhwErj6DkihkqymKT Zc1lF4Vv4SRDz6J29wzTCAFt37vS2pENloxdaUUyCGk9evG6ac3Pwe/jq5I1u2jZ7Zlp 6oWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="BwP/7FGL"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id m5si11328982pfd.373.2022.01.23.07.57.19; Sun, 23 Jan 2022 07:57:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="BwP/7FGL"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S230230AbiAWBg1 (ORCPT + 99 others); Sat, 22 Jan 2022 20:36:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229623AbiAWBg0 (ORCPT ); Sat, 22 Jan 2022 20:36:26 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14089C06173B for ; Sat, 22 Jan 2022 17:36:26 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id jx6so11154087ejb.0 for ; Sat, 22 Jan 2022 17:36:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VhpcLgiTZRWgcJmPmiVIMS50KRCO7XHLKSYxNUWC3Pk=; b=BwP/7FGLsImZA/ogpCkSY5lZvCJJ8j+FLvn7VvSSKMs/sl3M38tLK6tIh92n7VJgjT FlHwj2kbF2ACOp5FBBg3owK9k3MLpnK7zu6rKQTA8mv3817ztvjVpYLF1V8B4TV057F2 YMdLe0NucazEB/8533um7kVLQvixWyNEyYLM3fX7C3xo1k2xBaNeGQwRtGHkGHUSxPqJ gFBs+s9BTBHqsI3dm+/AEsBoEs0mLUzP0+8Su72My3EdBaJz4TDmWeG/AeaRvHtuqkmj qWvOIByDQFg7bhzawpNeN/ogTQkgmdm0wUlqs3V3jd5AIwq6yf52hU9xqM2yCdji2Bu6 xgpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VhpcLgiTZRWgcJmPmiVIMS50KRCO7XHLKSYxNUWC3Pk=; b=qmV0X+F8P11pzIZxlo4kMix4DxkytoDZwnVvTLkdpx3ee3XgOs1hLTBfc5UYZIucnB Z28AlgmtXCmjcUClwNSSCCYLcR4DD6WypaRgaPrbAj19Pe4EkafrnZKw905LAdrsPPd4 jNsEWOr1HX7ihkV2Q+wRNWJXZ49CsbD30M5ikzsg96UQD0QhuSqdOGnIc1BjgS3xqowQ 5/xvikVnVv7xlRA/MDo59BqnGB1f9L3eC/XO+9nkCAGq1vik4x/tnVA+2s5DIyTyot52 hg4JuNS0sS1rVUuE9svj9aA+V3ZnGX/srRcAiOXTRPbCleoBuDuBVjGsGjT/tc1m7L3u iWrQ== X-Gm-Message-State: AOAM532dSjFbwfQTarynRXUIcuKqmr0Bc1O+aiLN0uPVTXNYQIEAzkDb LcsoGxaCm4Iz0ADFC6ZG9sU= X-Received: by 2002:a17:907:d11:: with SMTP id gn17mr1496723ejc.559.1642901784601; Sat, 22 Jan 2022 17:36:24 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id y23sm4251117edo.31.2022.01.22.17.36.24 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 22 Jan 2022 17:36:24 -0800 (PST) From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang , Krupa Ramakrishnan , KAMEZAWA Hiroyuki , Michal Hocko Subject: [PATCH 2/2] mm/page_alloc: add penalty to local_node Date: Sun, 23 Jan 2022 01:35:37 +0000 Message-Id: <20220123013537.20491-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220123013537.20491-1-richard.weiyang@gmail.com> References: <20220123013537.20491-1-richard.weiyang@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'Commit 54d032ced983 ("mm/page_alloc: use accumulated load when building node fallback list")' fix a bug on zonelist order. This let me think about what would happen if we have a node system with the following distance matrix. Node 0 1 2 3 4 5 6 7 ---------------------------- 0 10 12 12 12 32 32 32 32 1 12 10 12 12 32 32 32 32 2 12 12 10 12 32 32 32 32 3 12 12 12 10 32 32 32 32 4 32 32 32 32 10 12 12 12 5 32 32 32 32 12 10 12 12 6 32 32 32 32 12 12 10 12 7 32 32 32 32 12 12 12 10 Unfortunately for this case, the node fallback list gets built like this: Node Fallback list --------------------- 0: 0 1 2 3 4 5 6 7 1: 1 0 2 3 5 6 7 4 2: 2 3 0 1 6 7 4 5 3: 3 2 0 1 7 4 5 6 4: 4 5 6 7 0 1 2 3 5: 5 4 6 7 1 2 3 0 6: 6 7 4 5 2 3 0 1 7: 7 6 4 5 3 0 1 2 We found the order in diagonal block is not expected. The reason is we don't penalty local node. After penalty local node, the node fallback list gets built like this: Node Fallback list --------------------- 0: 0 1 2 3 4 5 6 7 1: 1 2 3 0 5 6 7 4 2: 2 3 0 1 6 7 4 5 3: 3 0 1 2 7 4 5 6 4: 4 5 6 7 0 1 2 3 5: 5 6 7 4 1 2 3 0 6: 6 7 4 5 2 3 0 1 7: 7 4 5 6 3 0 1 2 Now the fallback list is in round-robin order. I am not very familiar with the node distance pattern, while I tried the following distance matrix. Both of them works with this change. Node 0 1 2 3 ---------------- 0 10 10 10 10 1 10 10 10 10 2 10 10 10 10 3 10 10 10 10 Node 0 1 2 3 4 5 6 7 ---------------------------- 0 10 10 10 10 32 32 32 32 1 10 10 10 10 32 32 32 32 2 10 10 10 10 32 32 32 32 3 10 10 10 10 32 32 32 32 4 32 32 32 32 10 10 10 10 5 32 32 32 32 10 10 10 10 6 32 32 32 32 10 10 10 10 7 32 32 32 32 10 10 10 10 Signed-off-by: Wei Yang CC: Krupa Ramakrishnan CC: KAMEZAWA Hiroyuki CC: Michal Hocko --- mm/page_alloc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index f27afd517652..0cc25429a17e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6260,8 +6260,9 @@ static void build_zonelists(pg_data_t *pgdat) * So adding penalty to the first node in same * distance group to make it round-robin. */ - if (node_distance(local_node, node) != - node_distance(local_node, prev_node)) + if ((node_distance(local_node, node) != + node_distance(local_node, prev_node)) || + node == local_node) node_load[node] += nr_online_nodes; node_order[nr_nodes++] = node; -- 2.33.1