From patchwork Mon Oct 25 15:02:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 12582071 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 6F8A0C433EF for ; Mon, 25 Oct 2021 15:03:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1453A60D43 for ; Mon, 25 Oct 2021 15:03:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1453A60D43 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id A479D94000B; Mon, 25 Oct 2021 11:03:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9F6DC940007; Mon, 25 Oct 2021 11:03:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8BDF994000B; Mon, 25 Oct 2021 11:03:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0028.hostedemail.com [216.40.44.28]) by kanga.kvack.org (Postfix) with ESMTP id 77402940007 for ; Mon, 25 Oct 2021 11:03:54 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 37FF2180373CB for ; Mon, 25 Oct 2021 15:03:54 +0000 (UTC) X-FDA: 78735279588.05.138073F Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by imf28.hostedemail.com (Postfix) with ESMTP id D0405900009E for ; Mon, 25 Oct 2021 15:03:53 +0000 (UTC) Received: by mail-ed1-f44.google.com with SMTP id s1so586689edd.3 for ; Mon, 25 Oct 2021 08:03:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=is5ZDC1BahE5nkVkXn47Hcgm/HWZp8+0MbF9wxx8kgU=; b=I//b+V54FzMNVMnEhJnyy99vxxpz7pVQDMCOCQrcBcPTUDvThCNhgn7vWlOyqIWbWt WiSkEzTXGt2PNUUqxS6lNx6DeUNnsBUfuKKh5FXcmO7Z20V9bybVUmP6t2HJj2omqbNN slRzmMktLiHeMLltgGoaIODzJNVRYbQYd2ZGUsviiKV6QPZoOixxHY7rX0/gBnX8cClv CUPnamLjns2Ya8LIox5B8rVBqFzgl5gKLWI/0xBqjCiXL383te27u72v/tO9J9beJFdJ 709INjnTK9gzFKCkUOXiRbOcYvEDctN42qvTnOgAHtpl2vK960ZdXiQuZfDQnrG3qhzA bn4A== X-Gm-Message-State: AOAM533TkRd8GXv4x5LynOX2ysZFCuj/cKxvd5K2ooFsvCLuyfWMu055 8Q/ebaV2WKcmfvmMR4PUk+Vdlcq8TfI= X-Google-Smtp-Source: ABdhPJwwVcroxT7QraFpGhjr1v8G3BYv6JBUob+3acdxXiP1C2i0nOfZ2f/Nud8KWLUBV9luq/Yc4A== X-Received: by 2002:a05:6402:11d4:: with SMTP id j20mr27327097edw.267.1635174160482; Mon, 25 Oct 2021 08:02:40 -0700 (PDT) Received: from localhost.localdomain (ip-85-160-34-175.eurotel.cz. [85.160.34.175]) by smtp.gmail.com with ESMTPSA id u23sm9098221edr.97.2021.10.25.08.02.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Oct 2021 08:02:39 -0700 (PDT) From: Michal Hocko To: Cc: Dave Chinner , Neil Brown , Andrew Morton , Christoph Hellwig , Uladzislau Rezki , , LKML , Ilya Dryomov , Jeff Layton , Michal Hocko Subject: [PATCH 2/4] mm/vmalloc: add support for __GFP_NOFAIL Date: Mon, 25 Oct 2021 17:02:21 +0200 Message-Id: <20211025150223.13621-3-mhocko@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211025150223.13621-1-mhocko@kernel.org> References: <20211025150223.13621-1-mhocko@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: D0405900009E X-Stat-Signature: 3ziu3kzdnkm5dci9dniqfuejct6g66ad Authentication-Results: imf28.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none); spf=pass (imf28.hostedemail.com: domain of mstsxfx@gmail.com designates 209.85.208.44 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com X-HE-Tag: 1635174233-795129 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)); if ((gfp_mask & (__GFP_FS | __GFP_IO)) == __GFP_IO) memalloc_nofs_restore(flags); @@ -3032,6 +3036,10 @@ 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) { + schedule_timeout_uninterruptible(1); + goto again; + } goto fail; }