Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp255201rdb; Thu, 19 Oct 2023 03:45:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1Lu4GhwDj9pvcJUNDGs7mvkfvVjnLTixmRbUvnAcUKEvrQBsRyfR7tEVTte+/6+4XQDdP X-Received: by 2002:a17:902:f54d:b0:1ca:42b:f625 with SMTP id h13-20020a170902f54d00b001ca042bf625mr2540824plf.3.1697712323409; Thu, 19 Oct 2023 03:45:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697712323; cv=none; d=google.com; s=arc-20160816; b=F9SKmM43S1IDhLsYBJaamvlzrYz30rUnYOPoVD2sUbl9gMMzTaCokzHTkrBjzeZIci JiePkLoQt/6dJsgOSXz4mokaxNhU3bL9je6CngrrAynxsolP2R6RK75NCP8LjY4VrAA1 nln6QVLp1ih0GFCAN5TGpBXhHk/eNehJ5cAeAbQPcU6aOHq3p2rYWkdsPARDJqOaeCnT CFNUJzJpKrp2jkBdzC1otPHuAeWNLAxEFOke4NGjataxCDovy5ZwgURWyJ+3Yh6paHp7 sLOq0aNqZTUOOrXPl/xl7xwVpEFT4k2w3HpB2otpjdikmAOzz97l8piIuaEbenGg7MoR /v2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AdZK381RBjQZyfHFZ18jHnyg7m+suieSGZz1SIv3ey8=; fh=sfcVOgYtZePY21+UVXSJ05iBxN2n4QtX3V2hPqRe5TU=; b=RMP1WTe43ovE49gWiisT5WWDXKhVddIY+o+DJuIPIzUiOiBrjGesWtqA0ARmcV2FXc D9ziszTDRbC8m2yTXU7hc5cdQyiTsH9hkGKlrgQY+ksfyGWCrHhk1t+Qe+nmXOxfho1n Fn7KOfRFM23z37+hYNbHPsUWiRq14pho8jJA2ZoLxGC5ldu7LJGW0SbocyGYS66q42Tz ckqSWOGpPZmUBYAC9pZiOCLoBFI1T1kiEVcSd3U46waqtItRdYMW+uta/ZNJW64Gf4Ef 0BIeEXlb6dkcGypbnauq6E+815yARjRRHZt88O5hddOVxTQDXjU1jPM0cf6YTTmG9hBi VB6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=jeeeWztp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id b5-20020a170902d30500b001c381bd030csi1919087plc.172.2023.10.19.03.45.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 03:45:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=jeeeWztp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 2FC608076011; Thu, 19 Oct 2023 03:45:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232057AbjJSKo4 (ORCPT + 99 others); Thu, 19 Oct 2023 06:44:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232946AbjJSKoy (ORCPT ); Thu, 19 Oct 2023 06:44:54 -0400 Received: from mail-oo1-xc2b.google.com (mail-oo1-xc2b.google.com [IPv6:2607:f8b0:4864:20::c2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4D8F185 for ; Thu, 19 Oct 2023 03:44:52 -0700 (PDT) Received: by mail-oo1-xc2b.google.com with SMTP id 006d021491bc7-582a82e6d10so175147eaf.0 for ; Thu, 19 Oct 2023 03:44:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1697712292; x=1698317092; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AdZK381RBjQZyfHFZ18jHnyg7m+suieSGZz1SIv3ey8=; b=jeeeWztpWqmLnNUW6UK7HQtdN9Ao/wEuvdus7bPVlYmoRseZZf/8vdVH1W3GU3Z8bn bkx6y1oMm/maqybEynke4cwo5hnFDyAOIf/q+tKebFVJ2oN4mN8teeSLXrpnVuC7g9q/ wTUFsNITXO1ANayQJFIQwa343TzqZFt5DRmZ+ZFpg1iz9M6cw+GTOPXcIS11hEH7kRA2 sB44zNE0wkzvYwU1IQFVbXXA7vqbBqk/m57q30CjRYIZtkZD+Fbw7OmtLvJfLQZQbd4f npb3lm3/90dacetfnzAziC8wL8zwdBg5OOc6i4VguM6MAFYODfV/AIXwi+aznvQ8Pafh NuYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697712292; x=1698317092; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AdZK381RBjQZyfHFZ18jHnyg7m+suieSGZz1SIv3ey8=; b=UpOCcQFw9IzGCVgU/n1Hftfq+EYzgC3/v7LDw9ACR3kK/TX1LY/xjqHbIYDp6Syh4B RajHuqbEfA9+kOS3JMTANXY1kP2f/bbY4xJ2tyUAJ7kfTniTH7V55gQQbknnDOaSPORC ZPBhvtKER3epgC8z4vhhZKEAj53l/bYXCqA6E3AxtD91K56KIekDGVQan/6UDly+VXVT 5CdHMxH0WbGlz1YEyNHRepzMxCnaNQB65aHPMzHSnWuU4rb05W/tzA1BCSIVLd+Repfq 4ZnHPbOLXusZ9N+Dm01Uzzhwbm619DmtefGPISO9A9q1atwAU5tpFmLj4ocEE5uMIa0E 7K9g== X-Gm-Message-State: AOJu0Yy+zGOXOrJp1syjvEzSiPqIc2jdYjBDE9Ds3mxVE+5dbkoE5ipa zW9/dnMSO5GbsF8exk6Zh9ZH4A== X-Received: by 2002:a05:6359:3902:b0:168:a332:e1f2 with SMTP id xa2-20020a056359390200b00168a332e1f2mr1426065rwb.1.1697712291794; Thu, 19 Oct 2023 03:44:51 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id y13-20020aa79e0d000000b006bdfb718e17sm4812290pfq.124.2023.10.19.03.44.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 03:44:51 -0700 (PDT) From: Qi Zheng To: akpm@linux-foundation.org, rppt@kernel.org, david@redhat.com, vbabka@suse.cz, mhocko@suse.com Cc: willy@infradead.org, mgorman@techsingularity.net, mingo@kernel.org, aneesh.kumar@linux.ibm.com, ying.huang@intel.com, hannes@cmpxchg.org, osalvador@suse.de, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Qi Zheng Subject: [PATCH v3 1/2] mm: page_alloc: skip memoryless nodes entirely Date: Thu, 19 Oct 2023 18:43:54 +0800 Message-Id: <157013e978468241de4a4c05d5337a44638ecb0e.1697711415.git.zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 19 Oct 2023 03:45:07 -0700 (PDT) In find_next_best_node(), We skipped the memoryless nodes when building the zonelists of other normal nodes (N_NORMAL), but did not skip the memoryless node itself when building the zonelist. This will cause it to be traversed at runtime. For example, say we have node0 and node1, node0 is memoryless node, then the fallback order of node0 and node1 as follows: [ 0.153005] Fallback order for Node 0: 0 1 [ 0.153564] Fallback order for Node 1: 1 After this patch, we skip memoryless node0 entirely, then the fallback order of node0 and node1 as follows: [ 0.155236] Fallback order for Node 0: 1 [ 0.155806] Fallback order for Node 1: 1 So it becomes completely invisible, which will reduce runtime overhead. And in this way, we will not try to allocate pages from memoryless node0, then the panic mentioned in [1] will also be fixed. Even though this problem has been solved by dropping the NODE_MIN_SIZE constrain in x86 [2], it would be better to fix it in core MM as well. [1]. https://lore.kernel.org/all/20230212110305.93670-1-zhengqi.arch@bytedance.com/ [2]. https://lore.kernel.org/all/20231017062215.171670-1-rppt@kernel.org/ Signed-off-by: Qi Zheng Acked-by: David Hildenbrand --- mm/page_alloc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index ee392a324802..e978272699d3 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5052,8 +5052,11 @@ int find_next_best_node(int node, nodemask_t *used_node_mask) int min_val = INT_MAX; int best_node = NUMA_NO_NODE; - /* Use the local node if we haven't already */ - if (!node_isset(node, *used_node_mask)) { + /* + * Use the local node if we haven't already. But for memoryless local + * node, we should skip it and fallback to other nodes. + */ + if (!node_isset(node, *used_node_mask) && node_state(node, N_MEMORY)) { node_set(node, *used_node_mask); return node; } -- 2.30.2