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 8B4F9C433F5 for ; Tue, 26 Oct 2021 15:52:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 17485603E7 for ; Tue, 26 Oct 2021 15:52:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 17485603E7 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 4F52C80007; Tue, 26 Oct 2021 11:52:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A4FA940007; Tue, 26 Oct 2021 11:52:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 36CA980007; Tue, 26 Oct 2021 11:52:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0073.hostedemail.com [216.40.44.73]) by kanga.kvack.org (Postfix) with ESMTP id 21B6F940007 for ; Tue, 26 Oct 2021 11:52:15 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8048539B22 for ; Tue, 26 Oct 2021 15:52:14 +0000 (UTC) X-FDA: 78739030188.07.5FD7435 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by imf29.hostedemail.com (Postfix) with ESMTP id 3513C900024E for ; Tue, 26 Oct 2021 15:52:14 +0000 (UTC) Received: by mail-ed1-f49.google.com with SMTP id m17so4408286edc.12 for ; Tue, 26 Oct 2021 08:52:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dPVlSd43MaGLNnv2bHAgLRIpF45DjHAQcAaR9piQZVw=; b=mL1u3WabTdo6TubLxq+VUVT7yFq5GGUdgPYcF7n8IlsDSrQNG0Ug76qmuYYJ7QiVum E4jqz6ajdkVD9jLrd7X8Ui9LfYUDf4yp2FTkiy/bv71WJbQUVFfzstzUwKolNlPlFE+F Q78qkSFEpvVHrcFqu7VLfrSei2neTDiIoreLkUFHW8+oFW8ZTAASekwr7sN43NHaLVKN CzfkcXDS1X38syzFULd+WLOxJbRE72xfW/2+653wvqexvSE7bAaWMXE1C730dOCGgMTy g4RkQHPFq6Utpb3L2MIyc7F8P9GVZLMPp1r7fj/6e6uHtjmSIi48ydZrl2qByDegCWqx w4vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dPVlSd43MaGLNnv2bHAgLRIpF45DjHAQcAaR9piQZVw=; b=5mKnwHN/XO9Z4d4OJ9K5MZUydbGo6d1gXQiKCCtdF6JJj3/W8BYAMokBinLOHmHPK4 aOfxaJfA8t2aBvcCXh9jIVux7o07u9zqDnmJVYUexnSEkfVB8SdEDFGrXMd13o/sMYL2 M0ofrDhQJa/bgNRdO3SdfWDnQ1qcYOqgNDvtcKehvlca7epcIwkYzpr8AsJKLQev8x5L UCRHMiUqZPIheNdrNA3Y2pDE6et839/iUs72vnwyXdZ+Dg99tgfGLY1cpiHUaH6vdqQh BIg9BSn3jXXxVCb7LP+demBC+Yc+fnguVqo4z1MR8+pJox5733hkPepyDTVqN6kmjybO jbGw== X-Gm-Message-State: AOAM5313z5EJ+AZrieLEb2lVF+cL3UfOOHFwk92Dp6PPbceKklxg77fr BGLe5qGjG8EvBtAZP0F+6XHJJEizRAothD2u3Eg= X-Google-Smtp-Source: ABdhPJxqIn1UxV+0bZlUbnyq6SqlrKSdHvqrBtSN0t8LXMbFZdTV/iOwOHH1bsLWVmn9c4H5Ign0HOLUzi5MW/KlTi4= X-Received: by 2002:a05:6402:3488:: with SMTP id v8mr36360121edc.106.1635263323553; Tue, 26 Oct 2021 08:48:43 -0700 (PDT) MIME-Version: 1.0 References: <20211025150223.13621-1-mhocko@kernel.org> <20211025150223.13621-3-mhocko@kernel.org> In-Reply-To: <20211025150223.13621-3-mhocko@kernel.org> From: Uladzislau Rezki Date: Tue, 26 Oct 2021 17:48:32 +0200 Message-ID: Subject: Re: [PATCH 2/4] mm/vmalloc: add support for __GFP_NOFAIL To: Michal Hocko Cc: Linux Memory Management List , Dave Chinner , Neil Brown , Andrew Morton , Christoph Hellwig , linux-fsdevel@vger.kernel.org, LKML , Ilya Dryomov , Jeff Layton , Michal Hocko Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 3513C900024E X-Stat-Signature: w11itp74k4k18dn1numjhd4emkbjk8wy Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=mL1u3Wab; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of urezki@gmail.com designates 209.85.208.49 as permitted sender) smtp.mailfrom=urezki@gmail.com X-HE-Tag: 1635263534-256488 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. > > 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. 2. Can we combine two places where we handle __GFP_NOFAIL into one place? That would look like as more sorted out. -- Uladzislau Rezki