Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2319373rdf; Mon, 6 Nov 2023 10:27:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWxvATd6kyBssljFTtDpU6BtbQx1LOwnwcuSVUeNwegkTyRWyru2l8zBHcEqmq4o5Wo6BX X-Received: by 2002:a17:90a:9bc9:b0:280:31a8:191d with SMTP id b9-20020a17090a9bc900b0028031a8191dmr18757583pjw.39.1699295230663; Mon, 06 Nov 2023 10:27:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699295230; cv=none; d=google.com; s=arc-20160816; b=axKFzLJUnRzp7dAFBwxyby1NP/hEM+fdbme12eWMdlN8Rpw8b+AOLdnwcA94bTrMPI IM7G70pTh0CElzs+Xm+Wgo/QVVVCBG6SRod+9R0gJKZQG1fUs+r8ttLQoRqPo0Vz5+O0 1013k1Bt6LJBcQpLXhlwNVcfTcp3B1bHrepx3r2PvLbiy4NWhn1CxPi7x1n6w0z6fn8S 1j5MU3fSJncE+5VnnDawThSpv81dv1wdOKwURYNl+Co74YziMRVgC1C8iXP0W3UNIhWn f0xNnHuOqwA2xEMpzFcIV8B1ZNlruIP/9O5uM654dh2/p81Viuc/dTZne+5K5rMOE2u0 upuw== 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=JH4Kls/3MBhkiClYWM6sASDg5gAzrgTGBTG91q830Cc=; fh=sHj43leL0iYUpjx3uaFOe8q+Ty4pePjRNS51w/OCiM8=; b=YG+xORiCzGUMCQINxy+6JsqqevXw+0HiGSldubrfQqGR+tKD4djRILFCQGnK+eqBPG 1scyETMJ04RILSLUK20tvSKNbeVcyxADDFIdtm/0Er5tMzyPFvzsxG4aWhyFPePz7QW+ x39j4UgIHLrAZB+tlxcvuNasyir2PS+19N+FKYtp69DyX4tPmy8hVCeaJEsJpvQukLZ5 YDv7zqPN6mnA9VGC/9XKhHc9CUFmPmSxehMA+kNY4sY7pKLybKqX8dAmiIUwbhdI2z6z 43qLkKtbTC/9KvoYYQE8lT6Iyvl0X9DEdAa2tyY/XGXEJCJTvisfCH3KukLpqWl1Nk3g 19jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=pwaKx8X1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id lr3-20020a17090b4b8300b002806cdeecc6si9649872pjb.35.2023.11.06.10.27.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 10:27:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=pwaKx8X1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A9D118065032; Mon, 6 Nov 2023 10:27:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232685AbjKFS1B (ORCPT + 99 others); Mon, 6 Nov 2023 13:27:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232958AbjKFS0q (ORCPT ); Mon, 6 Nov 2023 13:26:46 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65EDC173A for ; Mon, 6 Nov 2023 10:26:37 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C262C433C7; Mon, 6 Nov 2023 18:26:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1699295196; bh=VzcmarRj5xg87q6eM78zA0Xh095fv6u/JvD6rbia9pk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=pwaKx8X1ahf/f+kUWCkPOV0SH985FU13FHH0XDHIhcibepRoAQglwQ+AingOuHCt+ hexL80g9HbmCscfsbE9u/hmukg1wVvvFNNxoGr1EG/sc2a+CvnE3x1Cr684W/7AMt0 h97vxN4soL/QFx4qs1xSAhkzh2f5VB2n6TYMKW0A= Date: Mon, 6 Nov 2023 10:26:35 -0800 From: Andrew Morton To: Stefan Roesch Cc: kernel-team@fb.com, hannes@cmpxchg.org, riel@surriel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v1] mm: Fix for negative counter: nr_file_hugepages Message-Id: <20231106102635.55bdf0cd99baad5c1fc8617a@linux-foundation.org> In-Reply-To: <20231106181918.1091043-1-shr@devkernel.io> References: <20231106181918.1091043-1-shr@devkernel.io> X-Mailer: Sylpheed 3.8.0beta1 (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=-7.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 06 Nov 2023 10:27:09 -0800 (PST) On Mon, 6 Nov 2023 10:19:18 -0800 Stefan Roesch wrote: > While qualifiying the 6.4 release, the following warning was detected in > messages: > > vmstat_refresh: nr_file_hugepages -15664 > > The warning is caused by the incorrect updating of the NR_FILE_THPS > counter in the function split_huge_page_to_list. The if case is checking > for folio_test_swapbacked, but the else case is missing the check for > folio_test_pmd_mappable. The other functions that manipulate the counter > like __filemap_add_folio and filemap_unaccount_folio have the > corresponding check. > > I have a test case, which reproduces the problem. It can be found here: > https://github.com/sroeschus/testcase/blob/main/vmstat_refresh/madv.c > > The test case reproduces on an XFS filesystem. Running the same test > case on a BTRFS filesystem does not reproduce the problem. > > AFAIK version 6.1 until 6.6 are affected by this problem. I'm thinking a cc:stable is justified. > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -2740,7 +2740,8 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) > if (folio_test_swapbacked(folio)) { > __lruvec_stat_mod_folio(folio, NR_SHMEM_THPS, > -nr); > - } else { > + } else if (folio_test_pmd_mappable(folio)) { > + > __lruvec_stat_mod_folio(folio, NR_FILE_THPS, > -nr); > filemap_nr_thps_dec(mapping); > I expect this will backport OK until it hits 3e9a13daa ("huge_memory: convert split_huge_page_to_list() to use a folio") at which point the -stable maintainers might request a reworked version.