Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp317178rwn; Wed, 7 Sep 2022 17:27:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Kx7f8wtaqdBvJVnhN4utq425V0QbKvqk4kEr6eBI7SniRzCAyLCbVQdDkW52Ku/3LGMAf X-Received: by 2002:a05:6a00:24d3:b0:53a:8f28:5054 with SMTP id d19-20020a056a0024d300b0053a8f285054mr6337972pfv.36.1662596856369; Wed, 07 Sep 2022 17:27:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662596856; cv=none; d=google.com; s=arc-20160816; b=c2fnov7dbpTcKXbnzxPfxoh4ylwUlGBWXn87XNmh15S2tcXdrwBBI/ADc8+8QZDbkR glg84AYwPx76yp7B6fxE0bcUejmooCav9PZc3kqMyWlzBfIQIjglliB+37QP2d6xLB4Q C6iPHYiCrEVTO8y86MwnXgEAbxlXWC500AilofiFcRHtZ5bvkhviQVnezW3hhUw85P0x XXeGYT6IgwfjnOT3LgdAe+U9vhhV7DxaMSs6ntObAxjn2+5kqRQAc0dV7cLmD0k918SR aSlxVfKxukezjgrbn8t4el0BxcCM5w3EDg/yeTqXEhBWhiwx1VyiQ8kqMisshYgdRHkH Ek0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=VTYNLBdap4u2xRypU37d/WY0sKlchNpzR6mETDMFQeU=; b=UWVA/S0IuZ2cnel87EoJUVOAugFKFxeElugig9SdhFkoGFQkGxAa99BsByNIPyeHP2 QlaXJ890BpFtRour7umHRZe+JAbv3JImvUx5H+M7aHAEA/7XJFq3wCD4YMSXvOprqi15 JAF2MNAV4iddmDF5r6Zq/GyE+PrFwZAn+OCMOhC0wY8Ja+z/RNTeuq2KpOnoQkmAYoSr WdADR+yqErezISuxJqIbBl4jwZ8Nzl9PVN6CzN9zl2g7gK9vgcNj9tHM/JVzGabPAFi9 Sw9HB42rediC/IpdKHvcyjyWnB3rA7j9k29RdjhWZf1jwnfmT7EMXXF2s8DKrlfIaWA3 XQ2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=0ZI77c2S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pj4-20020a17090b4f4400b00200559cf715si620444pjb.97.2022.09.07.17.27.25; Wed, 07 Sep 2022 17:27:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=0ZI77c2S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230090AbiIGXfh (ORCPT + 99 others); Wed, 7 Sep 2022 19:35:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbiIGXff (ORCPT ); Wed, 7 Sep 2022 19:35:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FAD325589 for ; Wed, 7 Sep 2022 16:35:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C017261B09 for ; Wed, 7 Sep 2022 23:35:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 137E2C433C1; Wed, 7 Sep 2022 23:35:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1662593733; bh=H9RDF9OiTaoOA9yZu6oVkkKo3sgFcjeJpEoCasUhSiY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=0ZI77c2SpLtuQWG8DwLDs3E9RL5BsOTZczG0Gj+11coXyTQcyLcCG7MUP+/UZvSSo PSjzwqBNxXBs1TFUTcOIzlK+QepJjN65E076vhbU+OaKEU8OVnK1Pqp5acOgs44VNp sO9aaGXjbmfIoEkKfkzKm+jP7h/Vzjs5A2PJNY+0= Date: Wed, 7 Sep 2022 16:35:32 -0700 From: Andrew Morton To: Liu Shixin Cc: , , Kefeng Wang Subject: Re: [PATCH] mm/huge_memory: prevent THP_ZERO_PAGE_ALLOC increased twice Message-Id: <20220907163532.413d52275e8a8d865e9321d2@linux-foundation.org> In-Reply-To: References: <20220905133813.2253703-1-liushixin2@huawei.com> <20220905130728.1e814d185b189faece6f2c2f@linux-foundation.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.