Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1287986pxb; Thu, 21 Oct 2021 20:31:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOWFdwuuVDZWyd8yAtf7pD6lRBl/D1Och+Cren7pPITjkNCyqK3MU9z7v9CzfIY7619qJr X-Received: by 2002:a05:6402:1941:: with SMTP id f1mr13187976edz.163.1634873510880; Thu, 21 Oct 2021 20:31:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634873510; cv=none; d=google.com; s=arc-20160816; b=nOoNJGmUn153yuewJ2IQvRwXgm5UjchFklsEGVO1NJpFQ9pSlobuPRke/O/8R8CvG2 PwtKzaj6MsuZiM/0f4WdCmHawfqkZNHAfhusH4icS/TWCxL5itvgU69cXMZgU+9d3XC6 YZNqU/QQ5natNzjQSMBLDTzg4EtWqk1EDLpH+It3ZwqHKs0L2QvhUG6GNhgIzKre7XRR 96TJvhzPSClsCA0dIIkJNl9Lp8XiJZMD+jVk1mUcxhfJBcyvtMPJqPjm8Xpl3xqnVqrc Hscal1EiAIU0CnQPLYIFm0f3AmQVC77NHd3oG0YEZYpcuYNTZ9i/AG5s4ZxyIAoVVoac /YOQ== 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:subject:cc:to:from:date :dkim-signature; bh=+PH20eVJrX/UOUH/i52mNjgZwCrwQ1XXpR/xLebH6X4=; b=HgpW3qGN18n/lzVSb5tnmucU+dCsOX0NgVGHnDCVURqRfQ0TxaJTwqA1neR94C6Oo5 G3CPzWBaOFtOkSfqTUVpdHNFRTTr8aUiPqve8w182LkfL62JsX7Ewdi2figtWDD/Pc2O s5OAuHMEpfLsZ5DqYN2g3rcenru7csPunpAhgLqPptUMu6ItAAa1QzHnuzdccLhOSAlC xNCyCJZhib51x3QOjq+GgnR1zOCA6KQzKrPCbTTlTTKDhFFFXTVpWItCs43FORjg5qwg AxgNkgZrdxolmnwPIQN8LXg8zLIJhrKsDqlHNWx++eVLZg5a7JrfOmZqr4hwXqY4Znyl FCZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=Qdc4pnTl; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g2si9415131edz.500.2021.10.21.20.31.27; Thu, 21 Oct 2021 20:31:50 -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; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=Qdc4pnTl; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232619AbhJVD3N (ORCPT + 99 others); Thu, 21 Oct 2021 23:29:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:39878 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232606AbhJVD3L (ORCPT ); Thu, 21 Oct 2021 23:29:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A3D38619BB; Fri, 22 Oct 2021 03:26:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1634873214; bh=dzVTEjYRvmGezdHFFYtBNFqE16zf9YNbNz8le8VBIjQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Qdc4pnTlrUjTjgzU9JkiOX5K4g7nVlz54G5x2dfMNCsUi4hCl90buh+usFnbV1R2F CrfX+ZulE3uxYnvhDwezjEltulhqzRqs2LAI7LRWlnrfMObRLBTbMeQy3n8U+oVTIR gAErfhkmBP0FJcCoSvVeWEhOksaf2C+dFRRxpfGY= Date: Thu, 21 Oct 2021 20:26:52 -0700 From: Andrew Morton To: Chen Wandun Cc: , , , , , , , Subject: Re: [PATCH v3 2/2] mm/vmalloc: introduce alloc_pages_bulk_array_mempolicy to accelerate memory allocation Message-Id: <20211021202652.ff8568bd5d58fbcf32946f83@linux-foundation.org> In-Reply-To: <20211021080744.874701-3-chenwandun@huawei.com> References: <20211021080744.874701-1-chenwandun@huawei.com> <20211021080744.874701-3-chenwandun@huawei.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 21 Oct 2021 16:07:44 +0800 Chen Wandun wrote: > It What is "it"? > will cause significant performance regressions in some situations > as Andrew mentioned in [1]. The main situation is vmalloc, vmalloc > will allocate pages with NUMA_NO_NODE by default, that will result > in alloc page one by one; > > In order to solve this, __alloc_pages_bulk and mempolicy should be > considered at the same time. > > 1) If node is specified in memory allocation request, it will alloc > all pages by __alloc_pages_bulk. > > 2) If interleaving allocate memory, it will cauculate how many pages > should be allocated in each node, and use __alloc_pages_bulk to alloc > pages in each node. This v3 patch didn't incorporate my two fixes, below. It is usual to incorporate such fixes prior to resending. I have retained those two fixes, now against v3. From: Andrew Morton Subject: mm-vmalloc-introduce-alloc_pages_bulk_array_mempolicy-to-accelerate-memory-allocation-fix make two functions static Cc: Chen Wandun Cc: Eric Dumazet Cc: Hanjun Guo Cc: Kefeng Wang Cc: Nicholas Piggin Cc: Shakeel Butt Cc: Uladzislau Rezki (Sony) Signed-off-by: Andrew Morton --- mm/mempolicy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/mm/mempolicy.c~mm-vmalloc-introduce-alloc_pages_bulk_array_mempolicy-to-accelerate-memory-allocation-fix +++ a/mm/mempolicy.c @@ -2196,7 +2196,7 @@ struct page *alloc_pages(gfp_t gfp, unsi } EXPORT_SYMBOL(alloc_pages); -unsigned long alloc_pages_bulk_array_interleave(gfp_t gfp, +static unsigned long alloc_pages_bulk_array_interleave(gfp_t gfp, struct mempolicy *pol, unsigned long nr_pages, struct page **page_array) { @@ -2231,7 +2231,7 @@ unsigned long alloc_pages_bulk_array_int return total_allocated; } -unsigned long alloc_pages_bulk_array_preferred_many(gfp_t gfp, int nid, +static unsigned long alloc_pages_bulk_array_preferred_many(gfp_t gfp, int nid, struct mempolicy *pol, unsigned long nr_pages, struct page **page_array) { _ From: Andrew Morton Subject: mm-vmalloc-introduce-alloc_pages_bulk_array_mempolicy-to-accelerate-memory-allocation-fix-2 fix CONFIG_NUMA=n build. alloc_pages_bulk_array_mempolicy() was undefined Cc: Chen Wandun Cc: Eric Dumazet Cc: Hanjun Guo Cc: Kefeng Wang Cc: Nicholas Piggin Cc: Uladzislau Rezki (Sony) Signed-off-by: Andrew Morton --- mm/vmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/vmalloc.c~mm-vmalloc-introduce-alloc_pages_bulk_array_mempolicy-to-accelerate-memory-allocation-fix-2 +++ a/mm/vmalloc.c @@ -2860,7 +2860,7 @@ vm_area_alloc_pages(gfp_t gfp, int nid, * otherwise memory may be allocated in only one node, * but mempolcy want to alloc memory by interleaving. */ - if (nid == NUMA_NO_NODE) + if (IS_ENABLED(CONFIG_NUMA) && nid == NUMA_NO_NODE) nr = alloc_pages_bulk_array_mempolicy(gfp, nr_pages_request, pages + nr_allocated); _