Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2355382rdf; Mon, 6 Nov 2023 11:33:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUgliTv1TXa2UxfC+9B8mGOY79YyejyOtnRWV5VW2qqymKImFRYPkw3l1eMCGS2SCb/rYP X-Received: by 2002:a17:902:dac3:b0:1cc:2c45:757a with SMTP id q3-20020a170902dac300b001cc2c45757amr31027068plx.10.1699299213278; Mon, 06 Nov 2023 11:33:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699299213; cv=none; d=google.com; s=arc-20160816; b=pBvdhPQAxo1kyZVA+JuIJuAHgCMCQI0soKGCvKs1szMPHBXe3hRa6fAsXTMjh1ukQm dXX1IW2Wh8l+cYKy8ZaUuCyueHODvOkS8vb4wuHsXvXi+0MPVSsL8nV2tQl8GWMtn/8J okL7wZ7WOGkQItI9N2Fkg2C1eqV72RSg6L0j2KXk+dbO79cqVQQi+l+GqhaTYmXXqR52 IF5M5kFRWGlfHG54YEPANEtSzMlZlmnMB/X/qd4yYqjNtGT4hbZ1jFo0AQudPFYB2p4w mPz+6ojmy9ZC8zHu94GKvyiUathyjmrkBZ/kl4oJdGbc8C7YQHD4cBG1x4X3zfLBZ1GE +FBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=coUY4R4bHV6GlqkmIzcmtT/lwGgqLzFx1u4qLz1y+oQ=; fh=2eCGBedsa59e1s2wxywiK4jSdscn+r4MOfcraKAf/8w=; b=PWoHsfX8q2Ta0fkqo9n48EkOCXAAoS++0I/rR7wIeQyu03d1OisOhBZxxkpEc3hQVz AylHObtAeDwN1r/lJka7YxYtZhWDAI+Ukq4M6xYmeffuYtcoNll+9NYZPTxilJwDMcmV Yhqk1o2g0ZzDCwCiOAWJ0VPiePCw3siMYYkG4KYbDe5Ozn7Z35+I6z+S/BT01wn2TFAc OdE+9eqAamrkpXWldI0gEpBfKSmaTI9iM1se2gFj3vohAkp13nzUuPASpT8dSuwN7PCI 6a4fRc9SmmU57Tc0dwHC7CcSQzgKtEnQUHGzoUFEywaiDvtr5Lj+WYy7KxG+JEiKdjk1 /zlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=PH1GvQOn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id u12-20020a170903124c00b001c62ca6d540si9487977plh.77.2023.11.06.11.33.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 11:33:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=PH1GvQOn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id D04CD8033DE4; Mon, 6 Nov 2023 11:33:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232001AbjKFTdU (ORCPT + 99 others); Mon, 6 Nov 2023 14:33:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231699AbjKFTdT (ORCPT ); Mon, 6 Nov 2023 14:33:19 -0500 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F22F798 for ; Mon, 6 Nov 2023 11:33:16 -0800 (PST) Received: by mail-qv1-xf32.google.com with SMTP id 6a1803df08f44-66d134a019cso34297276d6.3 for ; Mon, 06 Nov 2023 11:33:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1699299196; x=1699903996; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=coUY4R4bHV6GlqkmIzcmtT/lwGgqLzFx1u4qLz1y+oQ=; b=PH1GvQOn6fAbv2MwCknxQhb63C0h2di5Jgcv8yrRgUDGYFm3i+h7Dl/b9evUlb4jYi 8SmOiJM9R/Y7JjD2o04GQiwmQZr9f/bs3MpBn/WSHBoehAt0Ducw/VWLJ9fmM0P0wdnM 4BpTr2YthH9kbCsHnGxwbKkmhTqXq4eYMp6gw3hUfHVgzGQ1k/8C3UvQlwNr0nxSHRkb HU4Yb414aoIVoEnZL0Q08mDj5hYw3qniXSrVLtmg7sR2npSSCG89Hofy5V0QSDw+mnft WZQ9IWnRtMrl4MI8gsN9KJ4MB6FxN0iatCGq42q68O4tRN8314Uadg5xmMnVRg5mbgT7 LrQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699299196; x=1699903996; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=coUY4R4bHV6GlqkmIzcmtT/lwGgqLzFx1u4qLz1y+oQ=; b=oBAH1DLF5EXop86y8bP7mQxN9+j7OqIDVmL1OjLGLfc4WfMqd+G+xrdBj5fedzdvWj 8kAAcc7yGcxLYusPD47rsrY0dvfFoshG/hmRbr7CFzQi0N3Ikr6f6oYS9DnjwOHApll0 3iEkOYjx4HUqwOe+qvVw7L6JHMfamk+B11ucUwRES5IYkVDxEMx1NgH4Ox4Icq+sV3D9 lpXG7O+XyQ7D7yOJnLwpOmgPHsGBFKXU3ZTxnUTRSa/1nAJTBgktUkvTZMMipgKndOm9 4fmhLgY0aU0TCfbO9jOe/f8fkEHa0nRvgOhj2HporgzgGGxN4O3tLsyIIhVDChp+Wm6a aCOw== X-Gm-Message-State: AOJu0YwNRvextu9/z8I5+gUOSK/CVmcAafxpTZRQrixeW8BOM3pOYJ7k mi7aJGYDaADonUGMb2ZD9XJtE9DVFyLcJAlKonI= X-Received: by 2002:ad4:5c4c:0:b0:66d:113e:5374 with SMTP id a12-20020ad45c4c000000b0066d113e5374mr37727312qva.25.1699299196147; Mon, 06 Nov 2023 11:33:16 -0800 (PST) Received: from localhost ([2620:10d:c091:400::5:86b7]) by smtp.gmail.com with ESMTPSA id i3-20020a0cfcc3000000b0066d02f0af01sm3708077qvq.72.2023.11.06.11.33.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 11:33:15 -0800 (PST) Date: Mon, 6 Nov 2023 14:33:15 -0500 From: Johannes Weiner To: Matthew Wilcox Cc: Stefan Roesch , kernel-team@fb.com, akpm@linux-foundation.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: <20231106193315.GB3661273@cmpxchg.org> References: <20231106181918.1091043-1-shr@devkernel.io> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Mon, 06 Nov 2023 11:33:30 -0800 (PST) On Mon, Nov 06, 2023 at 06:59:55PM +0000, Matthew Wilcox wrote: > On Mon, Nov 06, 2023 at 10:19:18AM -0800, Stefan Roesch wrote: > > +++ 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); > > Good catch. Two things: > > 1. No blank line after the 'else if'. > > 2. We're leaving a bit of a landmine for shmem when it gets support for > arbitrary folio sizes. Really all of this should be under a > test_pmd_mappable. I was wondering if we want to keep NR_FILE_THPS permanently for original flavor 512 basepage THPs, or whether they should account large folios as well? Same for NR_ANON_THPS and NR_SHMEM_THPS. If so, then I agree this should all be conditional on pmdmapped. I suppose the same in filemap_unaccount_folio().