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 BC85FC77B6E for ; Thu, 13 Apr 2023 17:12:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0B10C900003; Thu, 13 Apr 2023 13:12:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0391C900002; Thu, 13 Apr 2023 13:12:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF566900003; Thu, 13 Apr 2023 13:12:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id CE28B900002 for ; Thu, 13 Apr 2023 13:12:18 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8A43D16037D for ; Thu, 13 Apr 2023 17:12:18 +0000 (UTC) X-FDA: 80677011156.19.8F2A8B5 Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) by imf15.hostedemail.com (Postfix) with ESMTP id 8E369A0028 for ; Thu, 13 Apr 2023 17:12:16 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=T74YjVxw; spf=pass (imf15.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.171 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681405936; 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=wdGAVmsoTCF3y26q/e3koPed6S+/37Tv/FP0omN5R7Y=; b=JuuXN+ux83/QQ7kUW2jQNq0MmGdCTTSB519/FUG0m3M+avhyD6rkRl2PO9vAmqsWwJFYJJ h1iC80+YAepJnsgK76ROs8bA+kthfD0Gqr0cw5J6InHiCH2YSbSkKAjzdVSfIA5BTVHhsm hjf+co6yoNrBJ8oMV0yZDRUXyYfThHM= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=T74YjVxw; spf=pass (imf15.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.171 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681405936; a=rsa-sha256; cv=none; b=7xYrt3n9g89qkTwFIa2CbhoSXG7uU7CSp05Bag//IMtPVjXN6yl+5T4uuSWbn38ok4sWbM ZL5Bdjps6l7sCkaNS/jjG9BfsoGSZTwpb9n1ukq9FNiyRfZ+7je4P7HhxKIGW9+cKfdtwq NF0y6L0AEr6Cm4t6so2YsBx1SI41Qy8= Received: by mail-qt1-f171.google.com with SMTP id e3so4242221qtm.12 for ; Thu, 13 Apr 2023 10:12:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1681405935; x=1683997935; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=wdGAVmsoTCF3y26q/e3koPed6S+/37Tv/FP0omN5R7Y=; b=T74YjVxwFqqN3Mb1q5sKlJ/s1SnH+lFUVXw/YHomlGgEWk49qZcRP6beva7bsmFp4w JWFavkFHyIaFs167FzL4d2e77LAAevZ0a+Y8qmBlTRZtHC7AdX/DjhQEzNE5vTfYAURa mg2Av0rzj/wf5j3hOlaWeZUjhWcJqpqVak+psV6huOF+rOq8oCrojWQih72o2BcV2rzQ ql0SueYX+7r+k/KZLdvzjK6cGqse7gmlGj3PDAsxZuK+5wVOXGIFuUhZMrXUAHcIzwgK GWuo5uVCKEExaCSvcJkP+ozQIrXkzGirXsgsBjsOK1Ze03hJiGkm1g4HTaTBo9m1K40G RZPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681405935; x=1683997935; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wdGAVmsoTCF3y26q/e3koPed6S+/37Tv/FP0omN5R7Y=; b=PR9aArwB5FAqs6Eccy0iLuK+voVHe0bSs1zE9Ix28A4TEII811vS6R3Y0gTfj/f6DF UMDZdhBPmsGN6I+XjIK5Dpp9l1XGfkj4GuNMlFB9PQESd82634exBxcJyUxjTCQqVUM/ n3iQ1TN61XCPjPDmaXoqGoDlPYu+6DKAUZuaWroeVJ9p8bXWCT/TN811SimRVTkTiD37 uIO1s528ejPr8qd2bRVKKUwjUmy/xKBFocHFTI+xu6qy9zxZd865zymh5cBTF/axmFoi LRuYCa5vo6CLIYlkE3FQ0LB4mnc9lozqLqb1ryv3aG2/RUstDz/UNCRf4Gr/Be2R+H8Q qE9A== X-Gm-Message-State: AAQBX9dh1b+hRuZYapsSaE4dTQskDGhaIWxMVNWk2Rpl1IGVKzOV72EM Ihjo99Wh6t5vJ1Jmlot4eoA0NKIEZGgKVyG57qyFdA== X-Google-Smtp-Source: AKy350YzqrdtZMK5jVV0DcosmEslCmJ1WSRul9YGMh6Fq0NYh7iqJb6N1OWRXPNdm35IvX9AZCfPtmhhe4y1hZ8d43U= X-Received: by 2002:ac8:5945:0:b0:3e6:970e:a405 with SMTP id 5-20020ac85945000000b003e6970ea405mr889280qtz.6.1681405935505; Thu, 13 Apr 2023 10:12:15 -0700 (PDT) MIME-Version: 1.0 References: <20230412195939.1242462-1-pasha.tatashin@soleen.com> <20230412131302.cf42a7f4b710db8c18b7b676@linux-foundation.org> In-Reply-To: From: Pasha Tatashin Date: Thu, 13 Apr 2023 13:11:39 -0400 Message-ID: Subject: Re: [PATCH v2] mm: hugetlb_vmemmap: provide stronger vmemmap allocation guarantees To: Michal Hocko 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 8E369A0028 X-Stat-Signature: ys17cerjjizs64cm9gfun33t3ktfs3cd X-Rspam-User: X-HE-Tag: 1681405936-143439 X-HE-Meta: U2FsdGVkX18RyPTOMvXdNBVw/PFbhmhAJsRc3KSd85vQzLBFIrPxN6RKKrVQLr4apR59ODeiOOpCQnWYWLtpAX5pl5Oax0RJvWuCVeJ7UniA7GW59OyVIj9pMy2lkjaGZJNpOu0hogxmqZcELuahobBpmZIFo0BMhHtEKOjjWMKpdkVHYR3AokQuvWrLBV2/9X0zb/lBg4jcQeQtlwopbAsGUCreVR+AcgsXDVYiBaS//BYLN+7yBlvlLVcZ6xdR3slxDDqfTse4Vcu3I/0oFAJgLgrPeaDAb24uPAGqJGSwY/XW41qll+w7qXk0Pm12HEpUJniJaH6oceqnHTIMJPM/WjcdpygwDkuU0tGNhwwJpuJVvaD3t+WtrfY2vMvkNjFiTCTSqnqr71SQE9NC2FRlqkAI9Pt9OWtaDaa8fRNEKLom+ZE0jZ78oa2BlDoPg8dHFmxX0L34WGX0nRmbh3oIy4JpXnqQEnKNgDiypUuVMKDGYZmffPUypBuuq6R99Qvhrdwrm6KLp3WNYLb4hUvib/AzfBTh6w1rNrMPc9iJQgY+swUtIc7C/OrWFWrlHvF/QskkME4r3EGLjIQI8LosfX9qJWWOkGCU5TfZXD+oIScIGKi3c73HCfaZTC/gYnzl8te90HQ1SSvUzdfq86oAoT08eJbNvt4dtahZf04RObJCnU9P+/LIavtFCfU9uUaXPyfWJNSRTYYTCKtsYLCnEFE4bzKSLaC5MhoxufHpI/fxOrysfJgsoIIVPe0zcTi4M60an0aBOPx1+YeXMu0NVUUgSwyL+jtTwlqK4/MGhzf04BMzbg/X+zhq4QlUj/T0vT/boVqeCv65RShrb5C7UYj7UVsnzI9Kug5HELXJDp51MBmPl3ylqvO3QlT5Fxd09AXvOffmZcMf3aZ4H+cZkANjLZn2L0Rl+do6vMiFaT5DVwS77/DrmUU3tKubae4XXoKK4qiTeeXSHcH 0tV+DczO U1M3sFevgofnFq2SNZZWo6eq7toM4Ju8S5zidXCsovipw8bO/s83uElRzcMA4HZoVPGf6sPC8P3GVkuJfn8vE48fYQUNaH8VtBxYU8/6ijIFHO6xF68t9G2RaQ9OoPQ0FeSUmLBsd0TLHK+etC+EwlMYSGTo4b0YwftZJx6113k1tTAdJQFkidVyj3hOhIYBeudACiN/azfJ3EQ42wn32SrqMgYIwmdW+yjvRq9K/bD8PO1BhXVC2l8UOIbzqWJ64c2cNh42lnE9Fg4Xu0LS6KR8AfX/vk60CKCx3YvwjOZKEt04+LFgLTTsK4TUgq+JFdN62bteyE5ZooQg09ZyRsFTxYhfucwjyZjgoN9GISYgrGqkGG5L1AttDDoM4gU4LuwuonpNlYohqsSg9+FrmjGInACVag5fM7PUCSTypUkPEOI3IHXpVrQqbb3TGiHTLSohb 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, Apr 13, 2023 at 11:25=E2=80=AFAM Michal Hocko wro= te: > > On Thu 13-04-23 11:05:20, Pavel Tatashin wrote: > > On Wed, Apr 12, 2023 at 4:18=E2=80=AFPM 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 m= emory 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 rec= laim > > > > > memory the returning of huge pages back to the system can be prob= lem. > > > > > > > > Are there any reports of this happening in the real world? > > > > > > > > > Lets > > > > > use __GFP_RETRY_MAYFAIL instead. This flag is also performs grace= ful > > > > > reclaim without causing ooms, but at least it may perform a few r= etries, > > > > > and will fail only when there is genuinely little amount of unuse= d 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 becom= e 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. I will add this to changelog in v3. If __GFP_RETRY_MAYFAIL is ineffective we will receive feedback once someone hits this problem. Otherwise, we will never hear about it. I think overall it is safer to keep this code with __GFP_RETRY_MAYFAIL flag. > > > 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. I suspect this is because at the moment it is not that frequent when a machine is reconfigured from having a lot of HugeTLB based workload to non-HugeTLB workload. Pasha