From patchwork Wed Mar 24 15:05:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12161443 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6851CC433C1 for ; Wed, 24 Mar 2021 15:09:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B8A6661A06 for ; Wed, 24 Mar 2021 15:09:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B8A6661A06 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 305C96B02C4; Wed, 24 Mar 2021 11:09:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B6CD6B02D2; Wed, 24 Mar 2021 11:09:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A63F6B02D4; Wed, 24 Mar 2021 11:09:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0071.hostedemail.com [216.40.44.71]) by kanga.kvack.org (Postfix) with ESMTP id 024046B02C4 for ; Wed, 24 Mar 2021 11:09:16 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B84B5181AF5D3 for ; Wed, 24 Mar 2021 15:09:16 +0000 (UTC) X-FDA: 77955101112.09.B5A26C0 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf07.hostedemail.com (Postfix) with ESMTP id 97079A0003A3 for ; Wed, 24 Mar 2021 15:08:56 +0000 (UTC) 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 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 97079A0003A3 X-Stat-Signature: pcdadmqa8hczknfq6fn7zzzsgan1cmhs Received-SPF: none (infradead.org>: No applicable sender policy available) receiver=imf07; identity=mailfrom; envelope-from=""; helo=casper.infradead.org; client-ip=90.155.50.34 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616598536-670751 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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) Acked-by: David Rientjes --- 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;