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 08BE5C433EF for ; Mon, 11 Jul 2022 01:55:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 058946B0072; Sun, 10 Jul 2022 21:55:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0075C6B0073; Sun, 10 Jul 2022 21:55:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E38858E0001; Sun, 10 Jul 2022 21:55:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D50F96B0072 for ; Sun, 10 Jul 2022 21:55:24 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7B8733367E for ; Mon, 11 Jul 2022 01:55:24 +0000 (UTC) X-FDA: 79673151768.17.B3F83F8 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf06.hostedemail.com (Postfix) with ESMTP id 6CF4518001A for ; Mon, 11 Jul 2022 01:55:23 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Lh6My3bpyzhXYL; Mon, 11 Jul 2022 09:52:46 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 11 Jul 2022 09:55:17 +0800 Subject: Re: [mm-unstable PATCH v5 1/8] mm/hugetlb: check gigantic_page_runtime_supported() in return_unused_surplus_pages() To: Naoya Horiguchi , CC: Andrew Morton , David Hildenbrand , Mike Kravetz , Liu Shixin , Yang Shi , Oscar Salvador , Muchun Song , Naoya Horiguchi , References: <20220708053653.964464-1-naoya.horiguchi@linux.dev> <20220708053653.964464-2-naoya.horiguchi@linux.dev> From: Miaohe Lin Message-ID: Date: Mon, 11 Jul 2022 09:55:17 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20220708053653.964464-2-naoya.horiguchi@linux.dev> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; spf=pass (imf06.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657504524; 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; bh=KWsxOlC/HksiB9Us2xaO56RheaOVcaKfUjLI4kA27V0=; b=QyfXe9CU9MPaMEKD3kDqhxAEbghNKRhfeTgxNwArwkZ3+C29pc0FDhpwk2m289CXE8auXm YFeAZmZSkAq6U7t0UREXxlXzz7PY4ljNsrv5Pb9KshIoETlBk5lO0YJB7NBn5vXRzmMWQ4 kaM4KPJvmbrRcb41btCFZ/JnMiM6UaQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657504524; a=rsa-sha256; cv=none; b=i4SuTvZtJy4AQ0cCqDXtIWKQvZjXaZHDG6SRN5jEEkYnDrvSuRRO6UvFRhxzVM3WftaQD9 DVWdtkeLoabL1jrXwWRIQUQYheBdrh8sBUhdBEyulB+iduHFhGPXidutf+M+9N1fDilMut lwjm/pdvU57BKoBPaa8SseYMRAo51eU= X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=none; spf=pass (imf06.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Stat-Signature: k3ao7w4q863uek8grm7z9bucnq3b6w34 X-Rspamd-Queue-Id: 6CF4518001A X-Rspamd-Server: rspam04 X-HE-Tag: 1657504523-891856 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 2022/7/8 13:36, Naoya Horiguchi wrote: > 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 surprising (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 > at that time the gigantic pages were not supposed to be allocated/freed > at run-time. Now kernel can support runtime allocation/free, so let's > check gigantic_page_runtime_supported() together. > > Signed-off-by: Naoya Horiguchi Looks good to me. Thanks. Reviewed-by: Miaohe Lin