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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D396C77B61 for ; Thu, 13 Apr 2023 15:25:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 21425900002; Thu, 13 Apr 2023 11:25:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C48D6B0074; Thu, 13 Apr 2023 11:25:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 08C44900002; Thu, 13 Apr 2023 11:25:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id EDFDF6B0072 for ; Thu, 13 Apr 2023 11:25:50 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 2088CA021D for ; Thu, 13 Apr 2023 15:25:50 +0000 (UTC) X-FDA: 80676742860.07.D567091 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf17.hostedemail.com (Postfix) with ESMTP id 118A340017 for ; Thu, 13 Apr 2023 15:25:47 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=nIUV0xHF; spf=pass (imf17.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681399548; h=from:from:sender:reply-to:subject:subject: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:dkim-signature; bh=Q8qWv6lbQrmiYVPxlfAYsRxNyuhBzv0qM6z/DYPvLY8=; b=mrErn85TpI/wZWcnT00HTB4lJltbTtQXWfbBQZhd06qVp+JhIYE0GGwHNL9ISJ0YrmFoXF wLeDiMQ1JmyI+rgyeTe/ai0f2LHyXdPWFIjUax8Evye9WfoWSGekb0GiVFn+ita3RebFqe 982Uf+r3AzxlF0sgNDhaOz1Vy9UYoDA= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=nIUV0xHF; spf=pass (imf17.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681399548; a=rsa-sha256; cv=none; b=1/kyqWmSg1Lh/0+rjBQWxceJwcufObyslTQ+nXkZlNGYhLAMlSxm2e5+YIag362GvJhNc+ F80rt3c1BZWB1jyDcEpr6PTkzSMIbV0JmHOfEmobts7BkWewPPgdy3t1xyj/P7Y9cpSjpC sLGMW5c+0tEoV5QaRvid8ynXFgypcFE= 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-out1.suse.de (Postfix) with ESMTPS id 78C10218EC; Thu, 13 Apr 2023 15:25:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1681399546; 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=Q8qWv6lbQrmiYVPxlfAYsRxNyuhBzv0qM6z/DYPvLY8=; b=nIUV0xHFYLmN/NjQ6MlbvuHk2NlfIglNqJSc8i+EZ7qROM0EATg8BrNQCfnckWBPcBFTk+ dR5tvdO1lQMOsPltm2Xs06ZhfqpXKfwr+M/TmGGBNL6EfwuM3OniPCwe4M1kKPzpZ/GUy3 x3dJG3tVQbA3gADt9pJCnk+mwRg1fU4= 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 517381390E; Thu, 13 Apr 2023 15:25:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6qcFEfoeOGSDWQAAMHmgww (envelope-from ); Thu, 13 Apr 2023 15:25:46 +0000 Date: Thu, 13 Apr 2023 17:25:45 +0200 From: Michal Hocko To: Pasha Tatashin Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, mike.kravetz@oracle.com, muchun.song@linux.dev, rientjes@google.com, souravpanda@google.com Subject: Re: [PATCH v2] mm: hugetlb_vmemmap: provide stronger vmemmap allocation guarantees Message-ID: References: <20230412195939.1242462-1-pasha.tatashin@soleen.com> <20230412131302.cf42a7f4b710db8c18b7b676@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: gfqr6dujeoq8t91bz1kajysk6a7a7z5d X-Rspamd-Queue-Id: 118A340017 X-HE-Tag: 1681399547-388022 X-HE-Meta: U2FsdGVkX18nlF16vJ7NwX1MpNhtE8of26o9lsm2tdOXn1HH1mJNWRuyDM1UBZIhpdhWKuqnt4XFudIHxk9rBQhjTELPgbVRz4gzBj2tnKPpt7B1114bPu4vf3oPzWbd9Oa/gRtSCgDJBfj5wq7boy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+z6wyZ4E3d6mPYyQRGABarI7oaWxY/BvBhcLtc4cbbyqUjnnv/koor8uuwUHta0hjT72u7BIEwRzsdyInmPmu8bTiGQbkifgLsUMzsKjBhy/NMrTZI9iNv+2Q+MtE6VbidicGzTjKgBLvdW8vnECtKhezLV932O/I= 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 Thu 13-04-23 11:05:20, Pavel Tatashin wrote: > On Wed, Apr 12, 2023 at 4:18 PM Michal Hocko wrote: > > > > On Wed 12-04-23 13:13:02, Andrew Morton wrote: > > > Lots of questions (ie, missing information!) > > > > > > On Wed, 12 Apr 2023 19:59:39 +0000 Pasha Tatashin wrote: > > > > > > > HugeTLB pages have a struct page optimizations where struct pages for tail > > > > pages are freed. However, when HugeTLB pages are destroyed, the memory for > > > > struct pages (vmemmap) need to be allocated again. > > > > > > > > Currently, __GFP_NORETRY flag is used to allocate the memory for vmemmap, > > > > but given that this flag makes very little effort to actually reclaim > > > > memory the returning of huge pages back to the system can be problem. > > > > > > Are there any reports of this happening in the real world? > > > > > > > Lets > > > > use __GFP_RETRY_MAYFAIL instead. This flag is also performs graceful > > > > reclaim without causing ooms, but at least it may perform a few retries, > > > > and will fail only when there is genuinely little amount of unused memory > > > > in the system. > > > > > > If so, does this change help? > > > > > > If the allocation attempt fails, what are the consequences? > > > > > > What are the potential downsides to this change? Why did we choose > > > __GFP_NORETRY in the first place? > > > > > > What happens if we try harder (eg, GFP_KERNEL)? > > > > Mike was generous enough to make me remember > > https://lore.kernel.org/linux-mm/YCafit5ruRJ+SL8I@dhcp22.suse.cz/. > > GFP_KERNEL wouldn't make much difference becauset this is > > __GFP_THISNODE. But I do agree that the changelog should go into more > > details about why do we want to try harder now. I can imagine that > > shrinking hugetlb pool by a large amount of hugetlb pages might become a > > problem but is this really happening or is this a theoretical concern? > > This is a theoretical concern. Freeing a 1G page requires 16M of free > memory. A machine might need to be reconfigured from one task to > another, and release a large number of 1G pages back to the system if > allocating 16M fails, the release won't work. This is really an important "detail" changelog should mention. While I am not really against that change I would much rather see that as a result of a real world fix rather than a theoretical concern. Mostly because a real life scenario would allow us to test the __GFP_RETRY_MAYFAIL effectivness. As that request might fail as well we just end up with a theoretical fix for a theoretical problem. Something that is easy to introduce but much harder to get rid of should we ever need to change __GFP_RETRY_MAYFAIL implementation for example. > In an ideal scenario we should guarantee that this never fails: that > we always can free HugeTLB pages back to the system. At the very least > we could steal the memory for vmemmap from the page that is being > released. Yes, this really bothered me when the concept was introduced initially. I am always concerned when you need to allocate in order to free memory. Practically speaking we haven't heard about bug reports so maybe this is not such a big deal as I thought. -- Michal Hocko SUSE Labs