Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp818410pxb; Mon, 25 Oct 2021 19:45:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/iTxLjBpUwfPG7lFzsmll7o+Mc3KKFqBCJCNDGcbksEctHbQcPut6Vt5Av4EYVzR4zgYX X-Received: by 2002:a05:6a00:1a8d:b0:44d:72f1:96e5 with SMTP id e13-20020a056a001a8d00b0044d72f196e5mr22735067pfv.40.1635216315654; Mon, 25 Oct 2021 19:45:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635216315; cv=none; d=google.com; s=arc-20160816; b=EdBie25LFuOf9B63bgN/D/KR7s/0B9AlrkRTpb9XYQcrm1Pyfgwl3VAy6xp3ACT65c mw+lHcyEcmvqdcHILMahs8O7dXWi037P7gzAFt1hvJrySR60xImMfg/xsVnexOBShFD/ 8YmFRpn1E4XL9QytJHGzXlACzMXpfqfmmtfWA6hire0xyreeO5ZQytyiM8PnNONhcDU8 1UlpTySRReJ+F/poAB2dgKk9zPX1Z7l9xzisBCU/2JO7fTpkQzSqUjSb5nqPqAd4CKhK p1PB2NlpZwdrz2oqc51w16qpQr5Pvw4OnWWnjWX8lXAmreJXbCoMfE+PSIyMPy03pntp SYSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:references:in-reply-to:subject :cc:to:from:mime-version:content-transfer-encoding:dkim-signature :dkim-signature; bh=a1cKWxIeUcucJel063hg8FOuYcQ7CNUDdSMhSQkwdb8=; b=T54x5XcCkwiUof/Q3A+7ymMDE5kxgDPS0Q+tcmk4S+GyzfyLS9DmywlryOKopT8/Zb jm7dkQuBzkH2e0VLmBr+6VDussD+ECcA2oui3zxkoAUVzhG1LbQUK2EZHX8YowT6Dmql m3sLNUG6/i3C+Hp4dplJTSrlwYl8J1CH90cltonSwHreNDnAOXMQmUqfXzyN6ISEvS0e FpolLP41Gnlacli4Upq11cVy7X/QuefkDhSlXhfRRRKF2gT1hMKR1oiQkkd0NvrXrkQV MwoDaWQxAGU8TCoKLTnwUXJIV+TD2CfyqifePG0R8tPy6BDvqxqE29MkVF5HvrlDMvSI bXqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="JVBLNg/1"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=gHKZ5JII; 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=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j14si16098701plr.37.2021.10.25.19.45.02; Mon, 25 Oct 2021 19:45:15 -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; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="JVBLNg/1"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=gHKZ5JII; 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=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234439AbhJYXCI (ORCPT + 99 others); Mon, 25 Oct 2021 19:02:08 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:47448 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233747AbhJYXCH (ORCPT ); Mon, 25 Oct 2021 19:02:07 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 558C21FD33; Mon, 25 Oct 2021 22:59:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1635202783; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a1cKWxIeUcucJel063hg8FOuYcQ7CNUDdSMhSQkwdb8=; b=JVBLNg/1G9y82k1V452mb4uLSeNfJrhV6/xpgVjF7hypt21RH8fU8ShHKRaYrFPPiemFXs ykUO0z1Omox6SM+yNDqgNkM3t7Hb1Nk6KEnZI9aR3njTBF0yF93Jw+p/hgi4/17wpP1Zsd Hsoz4oP6/smyyJslkGKL1YUXBeQMZpw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1635202783; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a1cKWxIeUcucJel063hg8FOuYcQ7CNUDdSMhSQkwdb8=; b=gHKZ5JIItNsnUp4DTnmQiAtvuz4r8DzJ2mUSEAatnc5VU/t17ZsNedIvbLWz4lUNozMg8m 9wJ75dOttNFUeFDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 201CC13CB7; Mon, 25 Oct 2021 22:59:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iiWRM9s2d2GHRgAAMHmgww (envelope-from ); Mon, 25 Oct 2021 22:59:39 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 From: "NeilBrown" To: "Michal Hocko" Cc: linux-mm@kvack.org, "Dave Chinner" , "Andrew Morton" , "Christoph Hellwig" , "Uladzislau Rezki" , linux-fsdevel@vger.kernel.org, "LKML" , "Ilya Dryomov" , "Jeff Layton" , "Michal Hocko" Subject: Re: [PATCH 2/4] mm/vmalloc: add support for __GFP_NOFAIL In-reply-to: <20211025150223.13621-3-mhocko@kernel.org> References: <20211025150223.13621-1-mhocko@kernel.org>, <20211025150223.13621-3-mhocko@kernel.org> Date: Tue, 26 Oct 2021 09:59:36 +1100 Message-id: <163520277623.16092.15759069160856953654@noble.neil.brown.name> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 26 Oct 2021, Michal Hocko wrote: > From: Michal Hocko >=20 > 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. >=20 > The larg part of the vmalloc implementation already complies with the *large* > 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. >=20 > 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. >=20 > Signed-off-by: Michal Hocko > --- > mm/vmalloc.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) >=20 > 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 *a= rea, gfp_t gfp_mask, > else if ((gfp_mask & (__GFP_FS | __GFP_IO)) =3D=3D 0) > flags =3D memalloc_noio_save(); > =20 > - ret =3D vmap_pages_range(addr, addr + size, prot, area->pages, > + do { > + ret =3D 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)); > =20 > if ((gfp_mask & (__GFP_FS | __GFP_IO)) =3D=3D __GFP_IO) > memalloc_nofs_restore(flags); > @@ -3032,6 +3036,10 @@ void *__vmalloc_node_range(unsigned long size, unsig= ned 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; > + } Shouldn't the retry happen *before* the warning? NeilBrown > goto fail; > } > =20 > --=20 > 2.30.2 >=20 >=20