Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp440030pxf; Wed, 24 Mar 2021 08:11:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyD9wkk8eJH50LEnfK1CaZKicu2+b9X9CgHcW/m91hmh0GwMw5PzpX2s/waqZYCH+0WdpfK X-Received: by 2002:a05:6402:408:: with SMTP id q8mr3821228edv.201.1616598689638; Wed, 24 Mar 2021 08:11:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616598689; cv=none; d=google.com; s=arc-20160816; b=JV560L2N9WD92NRkGFTJ5r54dBP0h5uCi42M/3BWjT0RBU5lzPeWh+TQsXTy9QRrlz mjL8dRhmLE9p/UC4VCQKga5s1PRJJIfpASx/SK/8BxcNjq/P5o7uG293xFHY9Pq6oikb p7xv3qaxqRrYwwnwXslPmWkpTYPZbpG2us6Zr7FQF3PxwCKxYeqqGlLSL6AGYPGO7HIL FNbEEY5SxCNiod6NE8cmpABxDnoWuAXc2ZUim/5pu3ppfiiySCtU7ftXV8vUVDzHL/I+ DYuChJBVkc3tAlhdTTvXADm1fzXPbvpnPuaKvjp6VOwSbmAjYFHPrOGQ3whuOhwiool7 C1fA== 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=abzLZDSImtUt7gowe+fZWKLMOfxUM8lbrZGEl5NlJeE=; b=ChlcllZ/Y0TTYAGZSnwuCGJgJG9IJz2d0zdpyiy64yR9EesTYjUZaDXIHoXVEBHWQB 1QGrNuayGjV5L/iJVxbhtwVia6XmpAlkg6mfCdYaZYoC2/QgFotxZg+zVwcd42RZyOqb HOniEpk4CnsFbXGoIjGoe49XSI+U6MEm5K1OKSijzvs/gqvlVkIs3nUsPhTKo/4GNCt3 AB1EN1wq+4tR8XPM/rr0yB5IgjfaJRV6UH1RsZlqlI/Sunk2uBsycaFSg2aXpR/r368Y u/vZzjDbBnGb7w6td1Z2zwSQFX8ll9fDrrrfE81Yo7KpxnFq0lya3S8JeHYWUBAVP6AL 5GhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=DP5U0ziY; 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 c10si1969332edv.12.2021.03.24.08.11.05; Wed, 24 Mar 2021 08:11:29 -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=@infradead.org header.s=casper.20170209 header.b=DP5U0ziY; 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 S236496AbhCXPJb (ORCPT + 99 others); Wed, 24 Mar 2021 11:09:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236470AbhCXPI4 (ORCPT ); Wed, 24 Mar 2021 11:08:56 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2333C061763 for ; Wed, 24 Mar 2021 08:08:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=abzLZDSImtUt7gowe+fZWKLMOfxUM8lbrZGEl5NlJeE=; b=DP5U0ziYjavGXyvDlMHC5tOdpp 2+6l7JStA6bWAK2kdHpRNk+Sozs5P0azkTYpOvTb+Iq0jmPFsDg44/qJ/UKN+sCzBloTUL4d2ehp8 LDBCJQli5Z/nUYz4FzXZ8kmaldxiwgm2tPNh7TvBjhKvJU/8JVrgZ6C2L1FZx0rJqkCfk58zzZ82K XaNpR5cZe1gS7m6vpLv6CxSp24Ib06w1kbGfIwVD2jqCQnL0SjMDP5mBNKt6UCSF2QTB9u+j8m2Qm 98oD8at91d10HUiHnFSsCG14+xiOesFUkGhK9HR/DFZearCRujZ9D7uGe8V3AI86e7GHXpZxAD1j4 w+Q97wSg==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lP56J-00BUEF-Gj; Wed, 24 Mar 2021 15:07:22 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Uladzislau Rezki , Nicholas Piggin Subject: [PATCH v2 3/4] mm/vmalloc: Use kvmalloc to allocate the table of pages Date: Wed, 24 Mar 2021 15:05:17 +0000 Message-Id: <20210324150518.2734402-4-willy@infradead.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210324150518.2734402-1-willy@infradead.org> References: <20210324150518.2734402-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we're trying to allocate 4MB of memory, the table will be 8KiB in size (1024 pointers * 8 bytes per pointer), which can usually be satisfied by a kmalloc (which is significantly faster). Instead of changing this open-coded implementation, just use kvmalloc(). This improves the allocation speed of vmalloc(4MB) by approximately 5% in our benchmark. It's still dominated by the 1024 calls to alloc_pages_node(), which will be the subject of a later patch. Signed-off-by: Matthew Wilcox (Oracle) --- mm/vmalloc.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index a22241e9c363..a9ed2a4b697e 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2801,13 +2801,8 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, gfp_mask |= __GFP_HIGHMEM; /* Please note that the recursion is strictly bounded. */ - if (array_size > PAGE_SIZE) { - pages = __vmalloc_node(array_size, 1, nested_gfp, node, + pages = kvmalloc_node_caller(array_size, nested_gfp, node, area->caller); - } else { - pages = kmalloc_node(array_size, nested_gfp, node); - } - if (!pages) { free_vm_area(area); return NULL; -- 2.30.2