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 6F237ECAAA1 for ; Tue, 6 Sep 2022 01:52:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A89A80243; Mon, 5 Sep 2022 21:52:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 957D680224; Mon, 5 Sep 2022 21:52:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8464F80243; Mon, 5 Sep 2022 21:52:28 -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 74F7780224 for ; Mon, 5 Sep 2022 21:52:28 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 40079ABAA2 for ; Tue, 6 Sep 2022 01:52:28 +0000 (UTC) X-FDA: 79879985976.18.875524F Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf24.hostedemail.com (Postfix) with ESMTP id 41F74180092 for ; Tue, 6 Sep 2022 01:52:27 +0000 (UTC) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MM7Zr6kw2zkX54; Tue, 6 Sep 2022 09:48:36 +0800 (CST) Received: from dggpemm100009.china.huawei.com (7.185.36.113) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 6 Sep 2022 09:52:23 +0800 Received: from [10.174.179.24] (10.174.179.24) by dggpemm100009.china.huawei.com (7.185.36.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 6 Sep 2022 09:52:23 +0800 Subject: Re: [PATCH] mm/huge_memory: prevent THP_ZERO_PAGE_ALLOC increased twice To: Andrew Morton References: <20220905133813.2253703-1-liushixin2@huawei.com> <20220905130728.1e814d185b189faece6f2c2f@linux-foundation.org> CC: , , Kefeng Wang From: Liu Shixin Message-ID: Date: Tue, 6 Sep 2022 09:52:23 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20220905130728.1e814d185b189faece6f2c2f@linux-foundation.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.24] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100009.china.huawei.com (7.185.36.113) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662429147; a=rsa-sha256; cv=none; b=xWPdqgOkqnIvPGkpgkD56bv5aRW7bQnJk9qY3IC9NTCACotlIk7Sm5SaUBP3aujIV+8DAa +cYMoL2giQeL3K1PMxDYnKdJMu6A82k1EDI+RjrMvwWO3P3Ydn6AucYWSY27eTxlAJpLdG uxMMjk0FgcV+KQ82XsRhh6Ds7XCUZ9U= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=liushixin2@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662429147; 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=1Doatvx8kfElS9UT6gUGhoGXIwC+klPzc9c85tuuLN4=; b=LTO9P1nhssi8YM80/yHQ9//vKTTGUn+vdFUT/b2p0njI5MSD73z6zdhAxb/FI2Et8+KAb1 YNMIUQtJi7XUykFRRTo7E9LhJ6crOoe/gTDVsGlO0DuFlVkD4/sa6Y1WCYfhatOxlwf8Mv vi8QFAFn46AX/7+HBvhVL41PX6rYEWQ= Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=liushixin2@huawei.com X-Rspamd-Server: rspam12 X-Stat-Signature: xaomagx1tg1dqadhtajn7ixiifsdqzbr X-Rspamd-Queue-Id: 41F74180092 X-Rspam-User: X-HE-Tag: 1662429147-270132 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/9/6 4:07, Andrew Morton wrote: > On Mon, 5 Sep 2022 21:38:13 +0800 Liu Shixin wrote: > >> If two or more threads call get_huge_zero_page concurrently, THP_ZERO_PAGE_ALLOC >> may increased two or more times. But actually, this should only count >> as once since the extra zero pages has been freed. > Well, for better of for worse, > Documentation/admin-guide/mm/transhuge.rst says > > thp_zero_page_alloc > is incremented every time a huge zero page is > successfully allocated. It includes allocations which where > dropped due race with other allocation. Note, it doesn't count > every map of the huge zero page, only its allocation. > > If you think this interprtation should be changed then please explain > why, and let's be sure to update the documentation accordingly. > > . Thanks for your explanation. I misunderstood the meaning of thp_zero_page_alloc before. Although the rules are clearly explained in the documentation, I think that this variable should only incremented when a huge zero page used for thp is successfully allocated and the pages dropped due race should skip increment. It seems strange to count in all allocations. If there's something I still misunderstand, please point it out, thanks. Thanks,