From mboxrd@z Thu Jan 1 00:00:00 1970 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=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,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 32812C4727D for ; Fri, 2 Oct 2020 12:40:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 73BAA20644 for ; Fri, 2 Oct 2020 12:40:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="R10SzSP7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73BAA20644 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 755E7900004; Fri, 2 Oct 2020 08:40:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 705DD6B0075; Fri, 2 Oct 2020 08:40:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CDE06B0074; Fri, 2 Oct 2020 08:40:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0183.hostedemail.com [216.40.44.183]) by kanga.kvack.org (Postfix) with ESMTP id 0E4C0900004 for ; Fri, 2 Oct 2020 08:40:40 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 9FE828249980 for ; Fri, 2 Oct 2020 12:40:39 +0000 (UTC) X-FDA: 77326944198.09.food91_5704e97271a4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 8D934180AD806 for ; Fri, 2 Oct 2020 12:40:39 +0000 (UTC) X-HE-Tag: food91_5704e97271a4 X-Filterd-Recvd-Size: 4264 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Fri, 2 Oct 2020 12:40:39 +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=QjbkD99XQtOemIqNqHPNiW5IcOJsHqUez77GjLcQqk8=; b=R10SzSP7oaJuVamNU0G6VqnD07 cqFPhZ1UG9Ui18gokEnIPezHjHpDOjOyLSIYNceIblIkVLql2oR1p29/aca9KP5kkinKc7Wg4hqeZ /bT4pXNtDp3R4N5aJG4JljoeD2pQZovlYoyTmUx1GZ9Mjut6PXjbGzMBb4bMYxedzjkjFw/p9KQWk O/AbGYDxulVhWP8IMwtUJg8mmqzneh5yH6AqUxj+U45gwjPsoKz+gfzKC3EMDOQ6Kyyz0m/lDZDTA FKllsXsku86/XtTQpVZEs7Y9E+BaDrNYhEeSkXRG3cdX/96wG6cMSGDNPJ7IT5tenQ2JhYCF5iqBh YcYAem0Q==; Received: from [2001:4bb8:180:7b62:f738:1861:1acc:15c8] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kOKMX-0004tA-T0; Fri, 02 Oct 2020 12:40:38 +0000 From: Christoph Hellwig To: Andrew Morton Cc: linux-mm@kvack.org Subject: [PATCH 1/2] mm: cleanup the gfp_mask handling in __vmalloc_area_node Date: Fri, 2 Oct 2020 14:40:34 +0200 Message-Id: <20201002124035.1539300-2-hch@lst.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201002124035.1539300-1-hch@lst.de> References: <20201002124035.1539300-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Content-Transfer-Encoding: quoted-printable 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: __vmalloc_area_node currently has four different gfp_t variables to just express this simple logic: - use the passed in mask, plus __GFP_NOWARN and __GFP_HIGHMEM (if suitable) for the underlying page allocation - use just the reclaim flags from the passed in mask plus __GFP_ZERO for allocating the page array Simplify this down to just use the pre-existing nested_gfp as-is for the page array allocation, and just the passed in gfp_mask for the page allocation, after conditionally ORing __GFP_HIGHMEM into it. This also makes the allocation warning a little more correct. Also initialize two variables at the time of declaration while touching this area. Signed-off-by: Christoph Hellwig --- mm/vmalloc.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index be4724b916b3e7..5e3eea8ff952ea 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2410,21 +2410,19 @@ EXPORT_SYMBOL(vmap); static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, pgprot_t prot, int node) { - struct page **pages; - unsigned int nr_pages, array_size, i; const gfp_t nested_gfp =3D (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO; - const gfp_t alloc_mask =3D gfp_mask | __GFP_NOWARN; - const gfp_t highmem_mask =3D (gfp_mask & (GFP_DMA | GFP_DMA32)) ? - 0 : - __GFP_HIGHMEM; + unsigned int nr_pages =3D get_vm_area_size(area) >> PAGE_SHIFT; + unsigned int array_size =3D nr_pages * sizeof(struct page *), i; + struct page **pages; =20 - nr_pages =3D get_vm_area_size(area) >> PAGE_SHIFT; - array_size =3D (nr_pages * sizeof(struct page *)); + gfp_mask |=3D __GFP_NOWARN; + if (!(gfp_mask & (GFP_DMA | GFP_DMA32))) + gfp_mask |=3D __GFP_HIGHMEM; =20 /* Please note that the recursion is strictly bounded. */ if (array_size > PAGE_SIZE) { - pages =3D __vmalloc_node(array_size, 1, nested_gfp|highmem_mask, - node, area->caller); + pages =3D __vmalloc_node(array_size, 1, nested_gfp, node, + area->caller); } else { pages =3D kmalloc_node(array_size, nested_gfp, node); } @@ -2442,9 +2440,9 @@ static void *__vmalloc_area_node(struct vm_struct *= area, gfp_t gfp_mask, struct page *page; =20 if (node =3D=3D NUMA_NO_NODE) - page =3D alloc_page(alloc_mask|highmem_mask); + page =3D alloc_page(gfp_mask); else - page =3D alloc_pages_node(node, alloc_mask|highmem_mask, 0); + page =3D alloc_pages_node(node, gfp_mask, 0); =20 if (unlikely(!page)) { /* Successfully allocated i pages, free them in __vunmap() */ --=20 2.28.0