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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 372A0C433EF for ; Tue, 19 Oct 2021 11:06:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CE132604DB for ; Tue, 19 Oct 2021 11:06:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CE132604DB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 0F5756B006C; Tue, 19 Oct 2021 07:06:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0A5BA6B0071; Tue, 19 Oct 2021 07:06:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E890D900002; Tue, 19 Oct 2021 07:06:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0237.hostedemail.com [216.40.44.237]) by kanga.kvack.org (Postfix) with ESMTP id D9CC56B006C for ; Tue, 19 Oct 2021 07:06:53 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9D2FB39B10 for ; Tue, 19 Oct 2021 11:06:53 +0000 (UTC) X-FDA: 78712909506.03.5CB108C Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by imf22.hostedemail.com (Postfix) with ESMTP id 5EBB71904 for ; Tue, 19 Oct 2021 11:06:52 +0000 (UTC) Received: by mail-lj1-f180.google.com with SMTP id g8so5422200ljn.4 for ; Tue, 19 Oct 2021 04:06:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=tAD7zB8LM4f7YToBrIIqjU4Z5P1aP+J+3akIYooYFgI=; b=iMsktpTc9SPawOT2NakNmiXvq50ESMo7mzuI1jCaBysrlgBv00bjDX4DC74IDX0p/B IglEQEjsnbiXtKEm6Zf0FwxEH5OJmij/GKTFPdejO32sUW61IEVFjegxmb4BWA3tYzb4 ALLA/mo0JWxOme4cySkma44ncYG5SPScsVbS9me4eSvF008gRa5nUBwnYI61GZwzVUGA CGdver6Za5JVZPGYjC6cEK/bL3kiGBW3ZMUZffBskeKLZBWthXF6ggAg+ZC5ruGpinpT WA0A2yf/luRwP6PJOKyXLU73pYzH4BF7j/sn2sruVrcnEPGE56t8pxlGTLdWHUAp9ckI sTrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=tAD7zB8LM4f7YToBrIIqjU4Z5P1aP+J+3akIYooYFgI=; b=5x+fwyolrB2hymiK3GN59wDfb40MSQxS3RyJ++uDubqNtGzagCTWwfknWpb6dvlogn ICkTTRoMT7ZFz0ywydpULRBtCUGTebgHDQJzGIfsMSsHLPy0B2wLGq2GfvtIdAXNGR6T 2FCfSrIogw29z/7s+4NuiO2vTD/ri8QBK9KbonWZPYY+Rk1ZCBCawQGlvKyuCK2Rl6ih uuiqv4FOLsjROohOXrYOwBLsqsxOYaQ2UzshEHQzAueDUw5bY6QX6vJpnUSjF2Hajpov TjyDukiF6INcaRnFPPsmi9+g5Ugnoj1wrcoAbdUK3G8uDiuKSbveaog/kOg6AxffTiAo 6LIQ== X-Gm-Message-State: AOAM532jMWu+Rn/SCD3r2NNNn2N9G3p80uZWOzD1c6aaHQhGr8P5GRJS H48mWWErvsu4VZ22lhJpocc= X-Google-Smtp-Source: ABdhPJyDg8JhJM+ACrmcGUWrMbttXSWDvW0F5ZT/zkT5/NpawPSvYfQ/Cb9JGS7Jdj2l9jPhGN8lhg== X-Received: by 2002:a05:651c:1589:: with SMTP id h9mr6215602ljq.151.1634641611570; Tue, 19 Oct 2021 04:06:51 -0700 (PDT) Received: from pc638.lan (h5ef52e3d.seluork.dyn.perspektivbredband.net. [94.245.46.61]) by smtp.gmail.com with ESMTPSA id h25sm1911356ljg.24.2021.10.19.04.06.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Oct 2021 04:06:51 -0700 (PDT) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Tue, 19 Oct 2021 13:06:49 +0200 To: Michal Hocko Cc: linux-mm@kvack.org, Dave Chinner , Neil Brown , Andrew Morton , Christoph Hellwig , Uladzislau Rezki , linux-fsdevel@vger.kernel.org, LKML , Ilya Dryomov , Jeff Layton , Michal Hocko Subject: Re: [RFC 2/3] mm/vmalloc: add support for __GFP_NOFAIL Message-ID: <20211019110649.GA1933@pc638.lan> References: <20211018114712.9802-1-mhocko@kernel.org> <20211018114712.9802-3-mhocko@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211018114712.9802-3-mhocko@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=iMsktpTc; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf22.hostedemail.com: domain of urezki@gmail.com designates 209.85.208.180 as permitted sender) smtp.mailfrom=urezki@gmail.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 5EBB71904 X-Stat-Signature: mys99abqg4y4tmfw5t91k98ay1zkz7m4 X-HE-Tag: 1634641612-263087 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: > From: Michal Hocko > > Dave Chinner has mentioned that some of the xfs code would benefit from > kvmalloc support for __GFP_NOFAIL because they have allocations that > cannot fail and they do not fit into a single page. > > The larg part of the vmalloc implementation already complies with the > given gfp flags so there is no work for those to be done. The area > and page table allocations are an exception to that. Implement a retry > loop for those. > > Signed-off-by: Michal Hocko > --- > mm/vmalloc.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index 7455c89598d3..3a5a178295d1 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -2941,8 +2941,10 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, > else if (!(gfp_mask & (__GFP_FS | __GFP_IO))) > flags = memalloc_noio_save(); > > - ret = vmap_pages_range(addr, addr + size, prot, area->pages, > + do { > + ret = vmap_pages_range(addr, addr + size, prot, area->pages, > page_shift); > + } while ((gfp_mask & __GFP_NOFAIL) && (ret < 0)); > > if ((gfp_mask & (__GFP_FS | __GFP_IO)) == __GFP_IO) > memalloc_nofs_restore(flags); > @@ -3032,6 +3034,8 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align, > warn_alloc(gfp_mask, NULL, > "vmalloc error: size %lu, vm_struct allocation failed", > real_size); > + if (gfp_mask && __GFP_NOFAIL) > + goto again; > goto fail; > } > > -- > 2.30.2 > I have checked the vmap code how it aligns with the __GFP_NOFAIL flag. To me it looks correct from functional point of view. There is one place though it is kasan_populate_vmalloc_pte(). It does not use gfp_mask, instead it directly deals with GFP_KERNEL for its internal purpose. If it fails the code will end up in loping in the __vmalloc_node_range(). I am not sure how it is important to pass __GFP_NOFAIL into KASAN code. Any thoughts about it? -- Vlad Rezki