Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp374037pxb; Thu, 21 Oct 2021 00:58:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhtWpkaAoV96lzeth3rmSUf4pB8ZFGStKYMv/M5FRH2k6pZihQa8b4uya3FhrFZYaFSXPz X-Received: by 2002:a05:6402:2787:: with SMTP id b7mr5631349ede.238.1634803100113; Thu, 21 Oct 2021 00:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634803100; cv=none; d=google.com; s=arc-20160816; b=QlbHBhZHnBrznYgSXcXpYv6ADogEJk7wa07JD2owPSvG+h1cLHO8EluFQk6JXkaNlE iAFHO7GxWJzDkxfcnkYBn+ox4LroQ4W7UsWWyXvWkmxXSqlZlFjjhu6vo542e24A/bWw TROzPv3SDwzbRLxXS/XDnc2b/jhO3RFrQIv3FjszRAcXAts7skLYXpUpbDowzHca6S14 ETIzloJbV1WbM5/zl9YhUyNqz9ypJyQZ4idlJAwudE7yY9E1YoSum80o/IZ6GYCQ1TbD OpeKdgSpbG6WNbuO7cvAzSDcC/ixvqkrpZOLBEAIq29HBbh/1xs7tGyzAx6FNsYPVSYD zNBA== 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; bh=pIW/5yEcbmqnRxqouMzQ6FrCoktSK2xe8UYCGWHPKLg=; b=SGPdYIGiw7dc85IuN5iFq8A0hDU1dnaw9/DpBs+QveqTzK0lViIcXa0pgRc33tVydJ 7jf/maYYE3OwXX9dEKlYbJKjchxWvB8K45KV3qlRMYdclDv090LOHDz76BdurKXi9Veh RVIaQTYyDHSPk60wEjAy2DRgD2jTBS/JdXhlRk70V42FfhdYIRX4KwxNIZQZxYbTGNXd UjB+H+kBu4Z/JV9oTNCr3uShUK6aV303gbUbzSyQmdFabbR6cERiALSoDYTF2z2GrYLV kxrEc5JYiVbus77sNCwlMaasycyKheZIndSw0d4SaKkkiSk8tkTXq71/MIR/+RPQfpMm VD3g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b14si8138796edd.248.2021.10.21.00.57.15; Thu, 21 Oct 2021 00:58:20 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231354AbhJUH4j (ORCPT + 99 others); Thu, 21 Oct 2021 03:56:39 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:13960 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230385AbhJUH4f (ORCPT ); Thu, 21 Oct 2021 03:56:35 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4HZfpN71XhzZcQB; Thu, 21 Oct 2021 15:52:28 +0800 (CST) Received: from dggpemm500002.china.huawei.com (7.185.36.229) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Thu, 21 Oct 2021 15:54:15 +0800 Received: from localhost.localdomain (10.175.112.125) by dggpemm500002.china.huawei.com (7.185.36.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Thu, 21 Oct 2021 15:54:14 +0800 From: Chen Wandun To: , , , , , , , , CC: Subject: [PATCH v3 1/2] mm/vmalloc: fix numa spreading for large hash tables Date: Thu, 21 Oct 2021 16:07:43 +0800 Message-ID: <20211021080744.874701-2-chenwandun@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211021080744.874701-1-chenwandun@huawei.com> References: <20211021080744.874701-1-chenwandun@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500002.china.huawei.com (7.185.36.229) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Eric Dumazet reported a strange numa spreading info in [1], and found commit 121e6f3258fe ("mm/vmalloc: hugepage vmalloc mappings") introduced this issue [2]. Dig into the difference before and after this patch, page allocation has some difference: before: alloc_large_system_hash __vmalloc __vmalloc_node(..., NUMA_NO_NODE, ...) __vmalloc_node_range __vmalloc_area_node alloc_page /* because NUMA_NO_NODE, so choose alloc_page branch */ alloc_pages_current alloc_page_interleave /* can be proved by print policy mode */ after: alloc_large_system_hash __vmalloc __vmalloc_node(..., NUMA_NO_NODE, ...) __vmalloc_node_range __vmalloc_area_node alloc_pages_node /* choose nid by nuam_mem_id() */ __alloc_pages_node(nid, ....) So after commit 121e6f3258fe ("mm/vmalloc: hugepage vmalloc mappings"), it will allocate memory in current node instead of interleaving allocate memory. [1] https://lore.kernel.org/linux-mm/CANn89iL6AAyWhfxdHO+jaT075iOa3XcYn9k6JJc7JR2XYn6k_Q@mail.gmail.com/ [2] https://lore.kernel.org/linux-mm/CANn89iLofTR=AK-QOZY87RdUZENCZUT4O6a0hvhu3_EwRMerOg@mail.gmail.com/ Fixes: 121e6f3258fe ("mm/vmalloc: hugepage vmalloc mappings") Reported-by: Eric Dumazet Signed-off-by: Chen Wandun Reviewed-by: Shakeel Butt --- mm/vmalloc.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index d77830ff604c..e8a807c78110 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2816,6 +2816,8 @@ vm_area_alloc_pages(gfp_t gfp, int nid, unsigned int order, unsigned int nr_pages, struct page **pages) { unsigned int nr_allocated = 0; + struct page *page; + int i; /* * For order-0 pages we make use of bulk allocator, if @@ -2823,7 +2825,7 @@ vm_area_alloc_pages(gfp_t gfp, int nid, * to fails, fallback to a single page allocator that is * more permissive. */ - if (!order) { + if (!order && nid != NUMA_NO_NODE) { while (nr_allocated < nr_pages) { unsigned int nr, nr_pages_request; @@ -2848,7 +2850,7 @@ vm_area_alloc_pages(gfp_t gfp, int nid, if (nr != nr_pages_request) break; } - } else + } else if (order) /* * Compound pages required for remap_vmalloc_page if * high-order pages. @@ -2856,11 +2858,12 @@ vm_area_alloc_pages(gfp_t gfp, int nid, gfp |= __GFP_COMP; /* High-order pages or fallback path if "bulk" fails. */ - while (nr_allocated < nr_pages) { - struct page *page; - int i; - page = alloc_pages_node(nid, gfp, order); + while (nr_allocated < nr_pages) { + if (nid == NUMA_NO_NODE) + page = alloc_pages(gfp, order); + else + page = alloc_pages_node(nid, gfp, order); if (unlikely(!page)) break; -- 2.25.1