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=-3.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 26629CA9EAB for ; Sat, 19 Oct 2019 01:59:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 34260222C6 for ; Sat, 19 Oct 2019 01:59:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="l56rdP0f" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 34260222C6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BBFFE8E0005; Fri, 18 Oct 2019 21:58:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B713A8E0003; Fri, 18 Oct 2019 21:58:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A60208E0005; Fri, 18 Oct 2019 21:58:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id 849598E0003 for ; Fri, 18 Oct 2019 21:58:59 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 42A9F2C81 for ; Sat, 19 Oct 2019 01:58:59 +0000 (UTC) X-FDA: 76058875998.14.hate11_31498b5a0aa00 X-HE-Tag: hate11_31498b5a0aa00 X-Filterd-Recvd-Size: 5458 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Sat, 19 Oct 2019 01:58:58 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 30A80222C2; Sat, 19 Oct 2019 01:58:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571450337; bh=GWYlF/iOYA1FbDRl6AS4IwAeF86kJLhjlrh3zMQI9OA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=l56rdP0f9iXMTAUXnT5mvBkd8G9OESNitxSge0+9JSeYosNk39wnMmHTYF48/jsUY eF+88V+rmk/e38F9ME1C0VO9uDi5X2FVanpc6NbVRamIE8QqgR2fT2n0H0CmgQBrw9 QzMaZ0a2d45b0vbZ/bZVX9GRNOBkJ0a2dOXPJ0l8= Date: Fri, 18 Oct 2019 18:58:56 -0700 From: Andrew Morton To: Uladzislau Rezki Cc: Michal Hocko , Daniel Wagner , Sebastian Andrzej Siewior , Thomas Gleixner , linux-mm@kvack.org, LKML , Peter Zijlstra , Hillf Danton , Matthew Wilcox , Oleksiy Avramchenko , Steven Rostedt Subject: Re: [PATCH v3 2/3] mm/vmalloc: respect passed gfp_mask when do preloading Message-Id: <20191018185856.1a77fc3a14a58ec18ca76a59@linux-foundation.org> In-Reply-To: <20191018094049.GB8744@pc636> References: <20191016095438.12391-1-urezki@gmail.com> <20191016095438.12391-2-urezki@gmail.com> <20191016110604.GT317@dhcp22.suse.cz> <20191018094049.GB8744@pc636> 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 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: On Fri, 18 Oct 2019 11:40:49 +0200 Uladzislau Rezki wrote: > > > alloc_vmap_area() is given a gfp_mask for the page allocator. > > > Let's respect that mask and consider it even in the case when > > > doing regular CPU preloading, i.e. where a context can sleep. > > > > This is explaining what but it doesn't say why. I would go with > > " > > Allocation functions should comply with the given gfp_mask as much as > > possible. The preallocation code in alloc_vmap_area doesn't follow that > > pattern and it is using a hardcoded GFP_KERNEL. Although this doesn't > > really make much difference because vmalloc is not GFP_NOWAIT compliant > > in general (e.g. page table allocations are GFP_KERNEL) there is no > > reason to spread that bad habit and it is good to fix the antipattern. > > " > I can go with that, agree. I am not sure if i need to update the patch > and send v4. Or maybe Andrew can directly update it in his tree. > > Andrew, should i send or can update? I updated the changelog with Michal's words prior to committing. You were cc'ed :) From: "Uladzislau Rezki (Sony)" Subject: mm/vmalloc: respect passed gfp_mask when doing preloading Allocation functions should comply with the given gfp_mask as much as possible. The preallocation code in alloc_vmap_area doesn't follow that pattern and it is using a hardcoded GFP_KERNEL. Although this doesn't really make much difference because vmalloc is not GFP_NOWAIT compliant in general (e.g. page table allocations are GFP_KERNEL) there is no reason to spread that bad habit and it is good to fix the antipattern. [mhocko@suse.com: rewrite changelog] Link: http://lkml.kernel.org/r/20191016095438.12391-2-urezki@gmail.com Signed-off-by: Uladzislau Rezki (Sony) Acked-by: Michal Hocko Cc: Daniel Wagner Cc: Hillf Danton Cc: Matthew Wilcox Cc: Oleksiy Avramchenko Cc: Peter Zijlstra Cc: Sebastian Andrzej Siewior Cc: Steven Rostedt Cc: Thomas Gleixner Signed-off-by: Andrew Morton --- mm/vmalloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/mm/vmalloc.c~mm-vmalloc-respect-passed-gfp_mask-when-do-preloading +++ a/mm/vmalloc.c @@ -1063,9 +1063,9 @@ static struct vmap_area *alloc_vmap_area return ERR_PTR(-EBUSY); might_sleep(); + gfp_mask = gfp_mask & GFP_RECLAIM_MASK; - va = kmem_cache_alloc_node(vmap_area_cachep, - gfp_mask & GFP_RECLAIM_MASK, node); + va = kmem_cache_alloc_node(vmap_area_cachep, gfp_mask, node); if (unlikely(!va)) return ERR_PTR(-ENOMEM); @@ -1073,7 +1073,7 @@ static struct vmap_area *alloc_vmap_area * Only scan the relevant parts containing pointers to other objects * to avoid false negatives. */ - kmemleak_scan_area(&va->rb_node, SIZE_MAX, gfp_mask & GFP_RECLAIM_MASK); + kmemleak_scan_area(&va->rb_node, SIZE_MAX, gfp_mask); retry: /* @@ -1099,7 +1099,7 @@ retry: * Just proceed as it is. If needed "overflow" path * will refill the cache we allocate from. */ - pva = kmem_cache_alloc_node(vmap_area_cachep, GFP_KERNEL, node); + pva = kmem_cache_alloc_node(vmap_area_cachep, gfp_mask, node); spin_lock(&vmap_area_lock); _