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 A755EC433F5 for ; Tue, 26 Oct 2021 19:33:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 37FD760E8F for ; Tue, 26 Oct 2021 19:33:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 37FD760E8F 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 AB5EA940008; Tue, 26 Oct 2021 15:33:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A6476940007; Tue, 26 Oct 2021 15:33:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9545E940008; Tue, 26 Oct 2021 15:33:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0116.hostedemail.com [216.40.44.116]) by kanga.kvack.org (Postfix) with ESMTP id 8638F940007 for ; Tue, 26 Oct 2021 15:33:20 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3BA743AE74 for ; Tue, 26 Oct 2021 19:33:20 +0000 (UTC) X-FDA: 78739587360.30.8E50097 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) by imf04.hostedemail.com (Postfix) with ESMTP id D8DD8500030B for ; Tue, 26 Oct 2021 19:33:14 +0000 (UTC) Received: by mail-lj1-f173.google.com with SMTP id u5so636852ljo.8 for ; Tue, 26 Oct 2021 12:33:19 -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=sbyPcOn08VL2I8C/2HZAvhs84VOC3xvrXHI1rlDtOFc=; b=OAPSZiEELZNVbfPgmPd9N2DnjB64tmaKrzB3mEP02TMKa7Q70rLDtrD6eqqZIJvlTL PjTQHz8LS/w1aZ7Yq/VYYdfYmykH5+ml8TCf/8q94NpKvSnnR4Uou70DbDHO46liDZ5x BvqaTFFx5iBTn9482Lu/Y5scw/zDkAzdO7phB5RS1ujUDuBY9ptGtO9pOikjkaRQZh92 OQLPglDb2pj17/ntaQAmk+ilZt+MJCjIgw2D31UpsnRsPLBderuSSC1o6zYwvpdPP0cS kBPXfU4Z9rYlKpbjyd957TaUmqSZUFv0fkBIerqHImLhOT5d5MCLIAGInvLfGl+vELXB 48Iw== 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=sbyPcOn08VL2I8C/2HZAvhs84VOC3xvrXHI1rlDtOFc=; b=Q4wZNvezO9L2GaBzCICXfV8CjcRifDZF40+XbVpzcxzkHBDFIhumRUvmgVngSYXrgD DXoEj8PeNg1iAE4a7TOdFIOWfqbieamswQ5/Ru+0EVt2scDU2a/TQY+2e7ziDU46985R sbJLQI1lVit6jrYfS6j/2uVHfNzXuWaoDV25LON4A/R8GSUd4lFTY9RLUAOyg7b8xcbj 8hTlY1Nh/hAC01mJfuMM0aaYq943nOE42YR1jAg6WcYiIojCL+nWA76k230n2XFclh/2 chYfRWsVa8DPLQcb2Fn6JI8W4knTezuk3KIvwjXLF9jhr66NdgC7mayxPrU+/f6wSetL WOkQ== X-Gm-Message-State: AOAM531LhNuUSwOsewRR0JlnCerd/hdGohe7X/PahOt2L4BwuLtKMOp9 uNZTNnuHfKewQEro29a1aWs= X-Google-Smtp-Source: ABdhPJydkzhlV9E1KalfXwiiHw8d5e2VhZOR+gxOT16ovEHE85ajFZbo9l64fBsGFku0xx5zCd5GLQ== X-Received: by 2002:a2e:9e93:: with SMTP id f19mr27692303ljk.311.1635276798204; Tue, 26 Oct 2021 12:33:18 -0700 (PDT) Received: from pc638.lan (h5ef52e3d.seluork.dyn.perspektivbredband.net. [94.245.46.61]) by smtp.gmail.com with ESMTPSA id a16sm2011793lfu.274.2021.10.26.12.33.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 12:33:17 -0700 (PDT) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Tue, 26 Oct 2021 21:33:15 +0200 To: Michal Hocko Cc: Uladzislau Rezki , Linux Memory Management List , Dave Chinner , Neil Brown , Andrew Morton , Christoph Hellwig , linux-fsdevel@vger.kernel.org, LKML , Ilya Dryomov , Jeff Layton Subject: Re: [PATCH 2/4] mm/vmalloc: add support for __GFP_NOFAIL Message-ID: <20211026193315.GA1860@pc638.lan> References: <20211025150223.13621-1-mhocko@kernel.org> <20211025150223.13621-3-mhocko@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Queue-Id: D8DD8500030B Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=OAPSZiEE; spf=pass (imf04.hostedemail.com: domain of urezki@gmail.com designates 209.85.208.173 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: qccbuxkn176kjcowyhrqn1ocnc36qy9c X-Rspamd-Server: rspam06 X-HE-Tag: 1635276794-79614 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 Tue, Oct 26, 2021 at 06:28:52PM +0200, Michal Hocko wrote: > On Tue 26-10-21 17:48:32, Uladzislau Rezki wrote: > > > 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. > > > > > > Add a short sleep before retrying. 1 jiffy is a completely random > > > timeout. Ideally the retry would wait for an explicit event - e.g. > > > a change to the vmalloc space change if the failure was caused by > > > the space fragmentation or depletion. But there are multiple different > > > reasons to retry and this could become much more complex. Keep the retry > > > simple for now and just sleep to prevent from hogging CPUs. > > > > > > Signed-off-by: Michal Hocko > > > --- > > > mm/vmalloc.c | 10 +++++++++- > > > 1 file changed, 9 insertions(+), 1 deletion(-) > > > > > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > > > index c6cc77d2f366..602649919a9d 100644 > > > --- a/mm/vmalloc.c > > > +++ b/mm/vmalloc.c > > > @@ -2941,8 +2941,12 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, > > > else if ((gfp_mask & (__GFP_FS | __GFP_IO)) == 0) > > > 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); > > > + if (ret < 0) > > > + schedule_timeout_uninterruptible(1); > > > + } while ((gfp_mask & __GFP_NOFAIL) && (ret < 0)); > > > > > > > 1. > > After that change a below code: > > > > > > if (ret < 0) { > > warn_alloc(orig_gfp_mask, NULL, > > "vmalloc error: size %lu, failed to map pages", > > area->nr_pages * PAGE_SIZE); > > goto fail; > > } > > > > > > does not make any sense anymore. > > Why? Allocations without __GFP_NOFAIL can still fail, no? > Right. I meant one thing but wrote slightly differently. In case of vmap_pages_range() fails(if __GFP_NOFAIL is set) should we emit any warning message? Because either we can recover on a future iteration or it stuck there infinitely so a user does not understand what happened. >From the other hand this is how __GFP_NOFAIL works, hm.. Another thing, i see that schedule_timeout_uninterruptible(1) is invoked for all cases even when __GFP_NOFAIL is not set, in that scenario we do not want to wait, instead we should return back to a caller asap. Or am i missing something here? > > 2. > > Can we combine two places where we handle __GFP_NOFAIL into one place? > > That would look like as more sorted out. > > I have to admit I am not really fluent at vmalloc code so I wanted to > make the code as simple as possible. How would I unwind all the allocated > memory (already allocated as GFP_NOFAIL) before retrying at > __vmalloc_node_range (if that is what you suggest). And isn't that a > bit wasteful? > > Or did you have anything else in mind? > It depends on how often all this can fail. But let me double check if such combining is easy. -- Vlad Rezki