From patchwork Tue Apr 12 00:13:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 12809910 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDA84C433EF for ; Tue, 12 Apr 2022 00:13:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A2016B0071; Mon, 11 Apr 2022 20:13:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 451E06B0073; Mon, 11 Apr 2022 20:13:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 318FE6B0074; Mon, 11 Apr 2022 20:13:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 226C26B0071 for ; Mon, 11 Apr 2022 20:13:29 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DD7E361FA9 for ; Tue, 12 Apr 2022 00:13:28 +0000 (UTC) X-FDA: 79346302896.03.291BCA8 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) by imf28.hostedemail.com (Postfix) with ESMTP id 7D6FEC0005 for ; Tue, 12 Apr 2022 00:13:28 +0000 (UTC) Received: by mail-ej1-f46.google.com with SMTP id lc2so13510985ejb.12 for ; Mon, 11 Apr 2022 17:13:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id; bh=KNYdiq3wrxz/uYj++tl5ABa0ab2cXzorCBh7MLnRv5g=; b=bcNNVpcA37nX0mMgekCMOlHHVY0aRKMjYaodwnJpno6h/Rth+XQM5txu1Ee7Xoir5h ES6RbwMiHmjQoN7dyVNRwrmWeKoIL0xt6YKHGh5Q1KOyAF+zNVvi/FFiPdg44eHMwxpD +fbyiTZb+En/LfqsKBXZ632rbcE4vdaDT7LtX5pQ4ol3QGYjRS95T2EvHgmCVe4XtW2/ tyrmATLn1qVN2ux3Uw3THO8yFugxYco7tPRWFLufqxp/rC97D5SHi8fKv3Jn71I2HUuT +Efpyv9GpiomtW30UJTghC+Xsh7nllmd8KlkBpPjeswrn5lLbrzSmsPFEtIxBIVZqlHE /6gw== 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; bh=KNYdiq3wrxz/uYj++tl5ABa0ab2cXzorCBh7MLnRv5g=; b=mN1ioJzb7isum0rdCcCSdhqQyewRLAVutoOOXkAaLGl4kUw5MKVxyHNdRusDTQXCcn WWEtK25pKG4ECdUEYjYTsOxuWnkBARtrYd034acgnsyGmho7QhztNh8lWW57m1kB124u 4VP0seqbOiLkf8mA/auYYvw/F9OI2bFgxFQHtkOav+4k3aylalZHecs6vx8RzMuKxSl6 jHOjzjkfCmZFSMJ6bEq6cii9zbp5MY0I/0zXRY0SyXxN4/8G/wavaUl8ZPQwJ18OVlgs sDH0ETVC8tL3Xiq/pcu00YhfcnTwmJ1UzDV8YeT4Ie9Xvqd0GFWQq+0W1jdJ54FPkNS3 kI3g== X-Gm-Message-State: AOAM531odULS5g8q3M1oZuDeFCC4ayVFO5zok1KZgfz3Zmqdv25n5j4j 6DU0YmQDZmbYOhIQ9HP9FU+iPKegzfE= X-Google-Smtp-Source: ABdhPJzzs2qxavrHrHqAZq5pSUc3leeDK4YXoEkl1E2gzYEddFibj7k+zCDri13D4eVRcJO5jSsTGQ== X-Received: by 2002:a17:907:7242:b0:6e7:f185:18e2 with SMTP id ds2-20020a170907724200b006e7f18518e2mr30831381ejc.577.1649722407136; Mon, 11 Apr 2022 17:13:27 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id f5-20020a17090624c500b006cee6661b6esm12594586ejb.10.2022.04.11.17.13.26 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Apr 2022 17:13:26 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang , Vlastimil Babka , David Hildenbrand , Oscar Salvador Subject: [Patch v3] mm/page_alloc: add same penalty is enough to get round-robin order Date: Tue, 12 Apr 2022 00:13:19 +0000 Message-Id: <20220412001319.7462-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 X-Rspam-User: Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=bcNNVpcA; spf=pass (imf28.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.46 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 7D6FEC0005 X-Stat-Signature: 41p6tmpkjm5bpf6m9issw5dgzukbutb6 X-HE-Tag: 1649722408-209408 X-Bogosity: Ham, tests=bogofilter, spamicity=0.006463, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: To make node order in round-robin in the same distance group, we add a penalty to the first node we got in each round. To get a round-robin order in the same distance group, we don't need to decrease the penalty since: * find_next_best_node() always iterates node in the same order * distance matters more then penalty in find_next_best_node() * in nodes with the same distance, the first one would be picked up So it is fine to increase same penalty when we get the first node in the same distance group. Since we just increase a constance of 1 to node penalty, it is not necessary to multiply MAX_NODE_LOAD for preference. [vbabka@suse.cz: suggests to remove MAX_NODE_LOAD] Signed-off-by: Wei Yang CC: Vlastimil Babka CC: David Hildenbrand CC: Oscar Salvador Acked-by: Vlastimil Babka Acked-by: David Hildenbrand Acked-by: Oscar Salvador --- v3: merge into a single patch v2: adjust constant penalty to 1 --- mm/page_alloc.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 5d71b8dcb5f4..0334c06a0a47 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6170,7 +6170,6 @@ int numa_zonelist_order_handler(struct ctl_table *table, int write, } -#define MAX_NODE_LOAD (nr_online_nodes) static int node_load[MAX_NUMNODES]; /** @@ -6217,7 +6216,7 @@ int find_next_best_node(int node, nodemask_t *used_node_mask) val += PENALTY_FOR_NODE_WITH_CPUS; /* Slight preference for less loaded node */ - val *= (MAX_NODE_LOAD*MAX_NUMNODES); + val *= MAX_NUMNODES; val += node_load[n]; if (val < min_val) { @@ -6283,13 +6282,12 @@ static void build_thisnode_zonelists(pg_data_t *pgdat) static void build_zonelists(pg_data_t *pgdat) { static int node_order[MAX_NUMNODES]; - int node, load, nr_nodes = 0; + int node, nr_nodes = 0; nodemask_t used_mask = NODE_MASK_NONE; int local_node, prev_node; /* NUMA-aware ordering of nodes */ local_node = pgdat->node_id; - load = nr_online_nodes; prev_node = local_node; memset(node_order, 0, sizeof(node_order)); @@ -6301,11 +6299,10 @@ static void build_zonelists(pg_data_t *pgdat) */ if (node_distance(local_node, node) != node_distance(local_node, prev_node)) - node_load[node] += load; + node_load[node] += 1; node_order[nr_nodes++] = node; prev_node = node; - load--; } build_zonelists_in_node_order(pgdat, node_order, nr_nodes);