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 37FEBECAAD5 for ; Thu, 8 Sep 2022 03:28:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CCD516B0073; Wed, 7 Sep 2022 23:28:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C55E58D0003; Wed, 7 Sep 2022 23:28:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF6406B0075; Wed, 7 Sep 2022 23:28:56 -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 A0D1E6B0073 for ; Wed, 7 Sep 2022 23:28:56 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8628D1412C7 for ; Thu, 8 Sep 2022 03:28:56 +0000 (UTC) X-FDA: 79887486672.08.DF4BC7F Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf01.hostedemail.com (Postfix) with ESMTP id D26664006B for ; Thu, 8 Sep 2022 03:28:55 +0000 (UTC) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MNPcQ4nQCzNm4t; Thu, 8 Sep 2022 11:24:22 +0800 (CST) Received: from dggpemm100009.china.huawei.com (7.185.36.113) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 8 Sep 2022 11:28:53 +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; Thu, 8 Sep 2022 11:28:52 +0800 Subject: Re: [PATCH] mm/huge_memory: prevent THP_ZERO_PAGE_ALLOC increased twice To: Andrew Morton , "Kirill A . Shutemov" References: <20220905133813.2253703-1-liushixin2@huawei.com> <20220905130728.1e814d185b189faece6f2c2f@linux-foundation.org> <20220907163532.413d52275e8a8d865e9321d2@linux-foundation.org> CC: , , Kefeng Wang From: Liu Shixin Message-ID: <6c0aeb6c-0dcc-2abb-d6af-559ff881d289@huawei.com> Date: Thu, 8 Sep 2022 11:28:52 +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: <20220907163532.413d52275e8a8d865e9321d2@linux-foundation.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.24] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100009.china.huawei.com (7.185.36.113) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662607736; a=rsa-sha256; cv=none; b=O2RY/Yau/Iz+JkPyOMhCDEaCZvOLJ1r1o8OoaDceNd+v+GpTaJeUkdiKUsMdcMrA/DZWB8 8gY3NrxmNblhD5ks7W+YSVYL9MblN0jaOUyTSZ/+5XH7vQBS95FpnrO+ulpK4cyCTxAyDD Cs3Q4+h4cQ4x7KF71DAmfRd4niDdAZk= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.188 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=1662607736; 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=W/bBRrIFmNpYVHKMtnkfc4n2xNaT2AVMlNY8VNR2F7s=; b=G/i/K9KnVcBCNeRUi2yjEvGfrcdrW68SxQgU0aH5CUTV9J6oVfSujpqFiV61ZknbKsoTqC by3C0xQtHIAaDKwt9uLlW9MJQzn/dmZoUEu54bqNKg+h4U3p9ogopXWJWy1Smupitn+8TH w7iXUnRkAnaV9lI2F+lyxLoMLnh6Xa0= X-Rspam-User: X-Stat-Signature: f5h8omgt4pieom186tnggpifk7hrtf15 X-Rspamd-Queue-Id: D26664006B Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=liushixin2@huawei.com X-Rspamd-Server: rspam05 X-HE-Tag: 1662607735-490145 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/8 7:35, Andrew Morton wrote: > On Tue, 6 Sep 2022 09:52:23 +0800 Liu Shixin wrote: > >> 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. > It seems strange to me also. Perhaps there's a rationale buried in the > git and mailing list history. > > . I didn't find previous discussion about this point. I update document in v2. Kirill, what do you think about this change? https://lore.kernel.org/linux-mm/20220908035533.2186159-1-liushixin2@huawei.com/