From patchwork Thu Jun 23 23:51:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 12893255 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 1E1C7C43334 for ; Thu, 23 Jun 2022 23:52:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ADA298E01A6; Thu, 23 Jun 2022 19:52:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A8A278E01A1; Thu, 23 Jun 2022 19:52:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9521F8E01A6; Thu, 23 Jun 2022 19:52:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 87DCA8E01A1 for ; Thu, 23 Jun 2022 19:52:32 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 68263607CE for ; Thu, 23 Jun 2022 23:52:32 +0000 (UTC) X-FDA: 79611152544.04.BFF0ED9 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by imf10.hostedemail.com (Postfix) with ESMTP id 17BFAC0033 for ; Thu, 23 Jun 2022 23:52:31 +0000 (UTC) Received: by mail-pj1-f49.google.com with SMTP id p5so1135529pjt.2 for ; Thu, 23 Jun 2022 16:52:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=guCk9+fmq044uYhThIHO4V934ZX2nYq8f94Emgz8GLM=; b=SUGUBrBFD30w/LODLPszAIWFJuyzy0h8yKc3XwFCVTjTpmAqYwYtNybMHRZ+ghsnt6 oFA4URHrauTUulNAvk0QCM67P/nkIVpijwPqu2IdFqBueiiaMSAQRPwpv6i3r+6CFCg5 plfgyMDGoKKdV7nNouU2+OWjZzQEV8GM9uqudK4CYp5wzLwGI5Uhh02fmt9opzL/hOuQ CHb2xiFPkQFAEUzJn7vUfUw/CjDKDoPj4aI+IY/+fKamjEPVD1pKTCLT8ivMhoUVoJNj HHF6gHkYy+hsHX3Jl6+v2yJCbU1tOMvmcYoLzEGZK1goInD5vx4s9WLc/yecqlQhAZqt O+OA== 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=guCk9+fmq044uYhThIHO4V934ZX2nYq8f94Emgz8GLM=; b=Xy3rEc8iMe1Qrtdsm9DI1Pko+K9p7tlyWavxma7tl4R9tcVEDkn39dIDOnHcfx/Yoz GmYSTgdaREgWhx3zLHliquWAE4EPJy3nCo+nI4jnNWEyXbmhrHroEXKk1bb/NOyoqEaX bTU/O1lt0jHVQ7jPLhARhvrgjJoKlDU76ydmN4Q4J7TcSKRzbGGTNiJJSHIYnTbHR0Hk K3Jn49e0Io0c3YMt/Nn8QMZZkf/vEmAQZ2PCXm4NBFSl30K8mCXzq3V0fTUVFYjkoMWq M5RGgyPOxny8qKW7PkC2QlZyWlqtpXUyvnkhI+adQFnRDYSLr3YRH8t/mYxMXI8WXUgq GZZA== X-Gm-Message-State: AJIora/arii6IHo4NTtuBRDdVOMDL9mcdTuPajcu6uGpX+XzcdSaEad+ c/isTUZfFlQLu8e3RqAd+1edqO/ZLQ== X-Google-Smtp-Source: AGRyM1vkLEUzFkCo4X+WONweFksRrl4oFKOzMvGjQX9HHb/bP3CF+/JL7adCPfO4KW6Vp/9kEJ5QLg== X-Received: by 2002:a17:90b:1a8c:b0:1ed:1afb:7a73 with SMTP id ng12-20020a17090b1a8c00b001ed1afb7a73mr571077pjb.144.1656028351028; Thu, 23 Jun 2022 16:52:31 -0700 (PDT) Received: from ik1-406-35019.vs.sakura.ne.jp (ik1-406-35019.vs.sakura.ne.jp. [153.127.16.23]) by smtp.gmail.com with ESMTPSA id r10-20020a170903020a00b00168eab11f67sm362571plh.94.2022.06.23.16.52.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jun 2022 16:52:30 -0700 (PDT) From: Naoya Horiguchi X-Google-Original-From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , David Hildenbrand , Mike Kravetz , Miaohe Lin , Liu Shixin , Yang Shi , Oscar Salvador , Muchun Song , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/9] mm/hugetlb: remove checking hstate_is_gigantic() in return_unused_surplus_pages() Date: Fri, 24 Jun 2022 08:51:45 +0900 Message-Id: <20220623235153.2623702-2-naoya.horiguchi@linux.dev> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220623235153.2623702-1-naoya.horiguchi@linux.dev> References: <20220623235153.2623702-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=SUGUBrBF; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf10.hostedemail.com: domain of nao.horiguchi@gmail.com designates 209.85.216.49 as permitted sender) smtp.mailfrom=nao.horiguchi@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656028352; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=guCk9+fmq044uYhThIHO4V934ZX2nYq8f94Emgz8GLM=; b=VNM/QkA7AoZIs55iO9STdvs+4lvRoZrrUWpYXIOcETX3LBj1E6dYPAtWapneZ3abNP4l7s 2VVdVus4Eq+ATEyqC5YMWwvNLEJHKl8xBM4znw651Ot76+ckBI9rYwoTx9rD4eF9cCKB1u g+p2QS16W7BiVXC92Zc8giNfhXjtzGc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656028352; a=rsa-sha256; cv=none; b=SoOl3uzh8/clCp9GPORVmG2goHzTRVuGvFGGlbZPcMohT/C8BL23C7/Vynww/ty3CycwjC W/dKeSyXKL2dS3pn+8nQpmFcnXcqFoKw+efqzvw02R8rUDlLIzXjfFLahGri8kZijwHEUS 2Bk1ozRKZnAnOnifhXFgHHtvtTsDBlQ= X-Stat-Signature: a3ip1j9pmop93e6equ1zwihij9b398a4 X-Rspamd-Queue-Id: 17BFAC0033 X-Rspam-User: Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=SUGUBrBF; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf10.hostedemail.com: domain of nao.horiguchi@gmail.com designates 209.85.216.49 as permitted sender) smtp.mailfrom=nao.horiguchi@gmail.com X-Rspamd-Server: rspam12 X-HE-Tag: 1656028351-245513 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: From: Naoya Horiguchi I found a weird state of 1GB hugepage pool, caused by the following procedure: - run a process reserving all free 1GB hugepages, - shrink free 1GB hugepage pool to zero (i.e. writing 0 to /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages), then - kill the reserving process. , then all the hugepages are free *and* surplus at the same time. $ cat /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages 3 $ cat /sys/kernel/mm/hugepages/hugepages-1048576kB/free_hugepages 3 $ cat /sys/kernel/mm/hugepages/hugepages-1048576kB/resv_hugepages 0 $ cat /sys/kernel/mm/hugepages/hugepages-1048576kB/surplus_hugepages 3 This state is resolved by reserving and allocating the pages then freeing them again, so this seems not to result in serious problem. But it's a little surprizing (shrinking pool suddenly fails). This behavior is caused by hstate_is_gigantic() check in return_unused_surplus_pages(). This was introduced so long ago in 2008 by commit aa888a74977a ("hugetlb: support larger than MAX_ORDER"), and it seems to me that this check is no longer unnecessary. Let's remove it. Signed-off-by: Naoya Horiguchi --- mm/hugetlb.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index a57e1be41401..c538278170a2 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2432,10 +2432,6 @@ static void return_unused_surplus_pages(struct hstate *h, /* Uncommit the reservation */ h->resv_huge_pages -= unused_resv_pages; - /* Cannot return gigantic pages currently */ - if (hstate_is_gigantic(h)) - goto out; - /* * Part (or even all) of the reservation could have been backed * by pre-allocated pages. Only free surplus pages.