From patchwork Fri Oct 2 12:40:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11813387 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 245B9139A for ; Fri, 2 Oct 2020 12:40:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C2F542074B for ; Fri, 2 Oct 2020 12:40:42 +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 C2F542074B 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) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 705DD6B0075; Fri, 2 Oct 2020 08:40:40 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org 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-Original-To: linux-mm@kvack.org 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-Spam-Summary: 1,0,0,0de93093f1ba5cf0,d41d8cd98f00b204,batv+27a5ecbc8e1e54150000+6249+infradead.org+hch@casper.srs.infradead.org,,RULES_HIT:41:69:355:379:541:800:960:966:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1542:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2734:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:3872:3874:4385:5007:6261:6653:9036:10004:11026:11473:11658:11914:12043:12160:12296:12297:12517:12519:12555:12895:13161:13229:13894:14096:14181:14394:14721:21080:21451:21627:30054,0,RBL:90.155.50.34:@casper.srs.infradead.org:.lbl8.mailshell.net-64.201.201.201 62.8.15.100;04yf1cximyn4r7cjipdnxgj4shiugycu89jbz3soi99egcf8b9eueb8x8uqsjxk.aytkfrypcpz716ayotgntwr3ct8buq9thtkyd1mokk9b9a9fnq7ed5xr7j7dodu.h-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:19,LUA_SUMMARY:none 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 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 = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO; - const gfp_t alloc_mask = gfp_mask | __GFP_NOWARN; - const gfp_t highmem_mask = (gfp_mask & (GFP_DMA | GFP_DMA32)) ? - 0 : - __GFP_HIGHMEM; + unsigned int nr_pages = get_vm_area_size(area) >> PAGE_SHIFT; + unsigned int array_size = nr_pages * sizeof(struct page *), i; + struct page **pages; - nr_pages = get_vm_area_size(area) >> PAGE_SHIFT; - array_size = (nr_pages * sizeof(struct page *)); + gfp_mask |= __GFP_NOWARN; + if (!(gfp_mask & (GFP_DMA | GFP_DMA32))) + 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|highmem_mask, - node, area->caller); + pages = __vmalloc_node(array_size, 1, nested_gfp, node, + area->caller); } else { pages = 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; if (node == NUMA_NO_NODE) - page = alloc_page(alloc_mask|highmem_mask); + page = alloc_page(gfp_mask); else - page = alloc_pages_node(node, alloc_mask|highmem_mask, 0); + page = alloc_pages_node(node, gfp_mask, 0); if (unlikely(!page)) { /* Successfully allocated i pages, free them in __vunmap() */