Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp103716pxu; Thu, 22 Oct 2020 16:59:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwoB97ddAhbcMaBpPM/9zl6dcplo4KqDhgyW76Il15M43PxPRRL14MfpZom6UFAIh/w9yey X-Received: by 2002:a17:906:1750:: with SMTP id d16mr4813423eje.292.1603411154494; Thu, 22 Oct 2020 16:59:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603411154; cv=none; d=google.com; s=arc-20160816; b=VSe3KRf9uO4pRb7dImCFqHx5+F/Ek0oVkTVMSD8JgFaVsXXW6aV/YRnD5zMyWWdVq9 6Q4/FtbG2WQUdMn8MofRxayxapvCoQPE2kmLRFSzHzkhIfdOCo7tHqtpZJTV9fFQKlNT QnC0idFspPTNjKTPyN+Oq1awQP+Mro3CVlUGTgi8QZ9I5GdUElgr8in2jpcneFTNgRMe bB2jzzflvJ2NkYKRQnO1oRLD2GkFegHEZAAK3kTXq2WtLyueouX6mRrIZx41F1dMYdtl pbmHeRYNmHYhKkZwZYjWAh0LapFClumcs/tDjNDAzGiSocSflhvV/sb2U7XWWVJQ4g8D 5HOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id; bh=WfebKxdFv/BfJ4B/ZE7pHUGmDGssRpzkTeYyC4VgrCs=; b=wHIfEq1kq22EFTRx7T8bq3awfw06j5d6TYqDXbkFoP1M7gUOVZnd9JYDMMUoxPYtl0 epx9oHOgt58+IPM9uWrwrSzKSruFEZhipJjN1Ln8EuR4AqZfVF2s5iFO3RMhmGVOK61b 9QcIfnbrVrhQvfDnLL9WGlbbye+luaTKYkN9PvGJ8mjs4pqWElJdM4bXbJAiB9C6Ql36 BkF45rp2jZm8YRM1shHYa9YLqoEkupnqK4lFT2YdoFO/sv8HnNU7015m1UdNRfYnGzqC eZbdvwmgFao3QpDcdn8GWGjovLefOjeY37th9u5BZKO6s9fpzjQaMLoONr5+e57OJk7/ YBnA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n12si1854995eje.169.2020.10.22.16.58.52; Thu, 22 Oct 2020 16:59:14 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2901301AbgJVPQP (ORCPT + 99 others); Thu, 22 Oct 2020 11:16:15 -0400 Received: from shelob.surriel.com ([96.67.55.147]:34696 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2901297AbgJVPQP (ORCPT ); Thu, 22 Oct 2020 11:16:15 -0400 Received: from imladris.surriel.com ([96.67.55.152]) by shelob.surriel.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1kVcK3-0000pJ-7H; Thu, 22 Oct 2020 11:16:11 -0400 Message-ID: Subject: Re: [PATCH] mm/shmem: fix up gfpmask for shmem hugepage allocation From: Rik van Riel To: Xu Yu , linux-mm@kvack.org Cc: hughd@google.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Michal Hocko , VlastimilBabka Date: Thu, 22 Oct 2020 11:16:10 -0400 In-Reply-To: <11e1ead211eb7d141efa0eb75a46ee2096ee63f8.1603267572.git.xuyu@linux.alibaba.com> References: <11e1ead211eb7d141efa0eb75a46ee2096ee63f8.1603267572.git.xuyu@linux.alibaba.com> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-NO2+ukY9FXiPfB4rJuJV" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Sender: riel@shelob.surriel.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-NO2+ukY9FXiPfB4rJuJV Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2020-10-21 at 16:09 +0800, Xu Yu wrote: > @@ -1887,6 +1930,7 @@ static int shmem_getpage_gfp(struct inode > *inode, pgoff_t index, > } > =20 > alloc_huge: > + gfp =3D shmem_hugepage_gfpmask_fixup(gfp, sgp_huge); > page =3D shmem_alloc_and_acct_page(gfp, inode, index, true); > if (IS_ERR(page)) { > alloc_nohuge: This looks it could be a bug, because the changed gfp flags are also used for the non-huge allocation below the alloc_nohuge: label, when the huge allocation fails. Using a separate huge_gfp variable would solve that issue. However, your patch also changes the meaning of SHMEM_HUGE_FORCE from "override mount flags" to "aggressively try reclaim and compaction", which mixes up the equivalents of the anon THP sysctl "enabled" and "defrag" settings. I believe it makes sense to continue keeping the "what should khugepaged do with these pages?" and "how hard should we try at allocation time?" settings separately for shmem the same way they are kept separately for anonymous memory. I also suspect it is simplest if shmem uses the same "how hard should we try at allocation time?" settings from the "defrag" sysfs file, instead of giving system administrators two knobs that they will likely want to set to the same value anyway. Coincidentally, I have been looking at the same code on and off for the past month, and also sent a patch to the list to fix this issue yesterday. I suspect my patch can be simplified a little more by directly using alloc_hugepage_direct_gfpmask to create a huge_gfp flag in shmem_getpage_gfp. https://lore.kernel.org/linux-mm/20201021234846.5cc97e62@imladris.surriel.c= om/ --=20 All Rights Reversed. --=-NO2+ukY9FXiPfB4rJuJV Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEKR73pCCtJ5Xj3yADznnekoTE3oMFAl+RojoACgkQznnekoTE 3oMtbAgApfrn8Wh8rXaZFyRMK7jp9ky7Ndr5yPFJhHrs4RVL7Je7En4oVt0Phy/i Rq5EWBARSLBngRvfvXm13N7SQZXk8aNWQLIwgyFjGLm+BTVAJBp9i2+2QzYZxRCf IbMBIM3M+awJNjOZ0iw/h82V4PjOv5l5e59poYF4T15G+qqP/HXwbVJFUuRX5pAH +a7q6olFIlBl17huVrakuYgi3AHWyYUs4zAoxvhlzIQ+bcR+v1tDmP8BWFv0/Pc/ ELZ+yzlK9gxAKNZBUP8bjxNri7ZxXsR1+OyNG9aOwbnQioCvKFcglt9gn6CGGzZ8 baU0hds485oQsDY374u6q9qFQ8VuFA== =Xew8 -----END PGP SIGNATURE----- --=-NO2+ukY9FXiPfB4rJuJV--