Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2920963pxb; Mon, 18 Oct 2021 04:51:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwa58za0UnJSvYMHiT9WRkDge4zalU45Q7Dfde4bXIyVLD9MPg0fzzZ2y9W/iBnXrdI2cS0 X-Received: by 2002:a17:907:3d89:: with SMTP id he9mr11724702ejc.96.1634557885988; Mon, 18 Oct 2021 04:51:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634557885; cv=none; d=google.com; s=arc-20160816; b=KWjrVOXUj6qh7eBQUECFZynezNiHjbtr3aIYvvfPLp35perq+PF+ts2p0dloPRPTQK k1fT3YWgiKKktUq61/RpUlF538dslNbpTuGTxN5/6xmsApKPi5/Ydsg5sjrVDeYFUC9H O4L2GXEg0PpOKMFf6ZZk690/7Crvp8uA23ZrKdmZ39ItKzhdF9CV/pXO4YOxL0l1bK5o T9Hq/zfOAeSEOgrYeVk2pS+3wWJI1mLPQ/b/Z9f2KE2r0TuCFroWIVLVtLDG6D2bCNz7 JBHS5bQffP1wje1DrUe4s6nuWQOtuBEKqcFgndkDFxzN6UUR+yrMfXSi9TsYeqb+vJvC OtIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=4L8lFLAdXhWJMY8TqNwD1OY6QC5E8vHIjyqLADqFDA4=; b=CL3S/cYX3HG8b0YKOO57wnE8Fhe8aC+s78F1aXX7TrdUgv3vvFRO+PK3ILWR4i8McY I493y8sH+Nq4EojO5M20pZ4R97KYiORoNwct5XAf/AIoaTiWNYoYZjIBaP7CWNMnwoMu 1bgad3E93Y23fbg0CmpUYKfezXmXDUG0xn7pu4hmPrK4DKxhg7jdsonnSoDJledWB55g vp4P973M8cZB+n0bljGPob+/nP90cOYsUBY7N4sMwKFVhbwiIFrc6GveDw988NnSdfY1 W3NwI8BE9vRKg6q8UUiPsS3BvYM5HeACqWilJfZAJzB8szES0B/LiQtkw8Tpf65W19SR GiDg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gb1si16327062ejc.89.2021.10.18.04.51.02; Mon, 18 Oct 2021 04:51:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231819AbhJRLuA (ORCPT + 99 others); Mon, 18 Oct 2021 07:50:00 -0400 Received: from mail-ed1-f43.google.com ([209.85.208.43]:44919 "EHLO mail-ed1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231709AbhJRLtp (ORCPT ); Mon, 18 Oct 2021 07:49:45 -0400 Received: by mail-ed1-f43.google.com with SMTP id w14so69741712edv.11; Mon, 18 Oct 2021 04:47:33 -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=4L8lFLAdXhWJMY8TqNwD1OY6QC5E8vHIjyqLADqFDA4=; b=47A5OPoc8SPxbGLytX4WskpX1QWqQxD6GtdhwZZtd3crC2CLsUsgtxfC5L4E6AF91x omuOLyX+z8ijIfd6Rh9tvB7cyceolHA7L2lJSbhqF8KUKFEmV4RMTZZjY7MhYjDZISZm gRrxVmZuM4yffDTBypM0wpGF6ahNN0Nh3LIaYgC01tWkSHl0UgzsCj36s72w+Gt+1EtA o74Lo+nkuxvXwl2rB7/8Wcnf4ewMftYUekOb72lyZx90IkytpuT7IdWAYtueCBr6H8ed ASHqjzWVuWXLwDmLAF0/X4Gc1BY45OfCG+3obKKFboqgjQJAPPgpjhclPvjDyvcSXBAh NMAA== X-Gm-Message-State: AOAM5315IFF7rwDgVMOUu1Lh4jKK9NhIZucwYI5jGvbDapFR6uzzlL+7 AxOKspeWIH0DmKj2Yppaojs= X-Received: by 2002:a17:906:3510:: with SMTP id r16mr30003410eja.209.1634557648625; Mon, 18 Oct 2021 04:47:28 -0700 (PDT) Received: from localhost.localdomain (ip-85-160-35-99.eurotel.cz. [85.160.35.99]) by smtp.gmail.com with ESMTPSA id b2sm9587458edv.73.2021.10.18.04.47.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 04:47:28 -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: [RFC 2/3] mm/vmalloc: add support for __GFP_NOFAIL Date: Mon, 18 Oct 2021 13:47:11 +0200 Message-Id: <20211018114712.9802-3-mhocko@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211018114712.9802-1-mhocko@kernel.org> References: <20211018114712.9802-1-mhocko@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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