From patchwork Thu Jun 22 09:47:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Glauber X-Patchwork-Id: 13288934 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 DB32DEB64D8 for ; Thu, 22 Jun 2023 09:47:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29FCB8D0002; Thu, 22 Jun 2023 05:47:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 229368D0001; Thu, 22 Jun 2023 05:47:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0A3B68D0002; Thu, 22 Jun 2023 05:47:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id EBED18D0001 for ; Thu, 22 Jun 2023 05:47:37 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id BD981120174 for ; Thu, 22 Jun 2023 09:47:37 +0000 (UTC) X-FDA: 80929906554.01.99AF280 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf08.hostedemail.com (Postfix) with ESMTP id E819A160019 for ; Thu, 22 Jun 2023 09:47:35 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=digitalocean.com header.s=google header.b=eRTPSMLS; dmarc=pass (policy=reject) header.from=digitalocean.com; spf=pass (imf08.hostedemail.com: domain of jglauber@digitalocean.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=jglauber@digitalocean.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687427256; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=1llRvBzUlI3UuMkgrwvvPQlC2U4WWp6vjfVefBOBT1I=; b=xdoS2IKSfsj5MVFyUFI6BIW+O6xPzNKU2TPg+RTdddfiBD7JwANf740WvQN8vaQ53ibKa8 ln2mdadk0kHHYayD/VXxk4GQ474g2jfHHwdZsdN1hjapdmpDpnCGMyZY6LcVTAydzMExL7 Gxeu+VG/7fczhh6AI1en9bInJ24ZweM= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=digitalocean.com header.s=google header.b=eRTPSMLS; dmarc=pass (policy=reject) header.from=digitalocean.com; spf=pass (imf08.hostedemail.com: domain of jglauber@digitalocean.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=jglauber@digitalocean.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687427256; a=rsa-sha256; cv=none; b=ukNq2FED0+YpzM3P+C4T7saBqwrdtNrl9bOqYOdfYjJO9+Tj1Y97+xwYctXWAA7seHFREm vFmY+k/elnsaDARUMAx3oV+XZdCYH6dVDjLxSIFw+lA+48IrQ6wm7882vGHfPrQoV4j1qK zfAWwkVHsS6WLrkFj8ok2X6ximiADr0= Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1b55643507dso38358235ad.0 for ; Thu, 22 Jun 2023 02:47:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=digitalocean.com; s=google; t=1687427254; x=1690019254; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=1llRvBzUlI3UuMkgrwvvPQlC2U4WWp6vjfVefBOBT1I=; b=eRTPSMLSP5LabF3ZUzJImpbDG1LLPl8Tt/JbkbCl83Z0rMj4ZMaYp4ZvL9pzrouhb9 VYV7/RdHTjYce3hJeebynonOiHIOlGZDutkIwAJPZbu0YsxGa6w9Z2/dkFH+Fcwdquf4 fmGVBr3hE3guZwvOrcC+1kK6TNhPSAD5Ai6rQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687427254; x=1690019254; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1llRvBzUlI3UuMkgrwvvPQlC2U4WWp6vjfVefBOBT1I=; b=SOOoRPzSyULh/f03/LobiorLVhgO8X6zy6XWYJUoBVA+FUBGXUIxoqHVXFbONRQFUh i5Bi79N2qYqEdslI258dT0Ron56eR4B+C/d5hte8B0xvR7j2ySY28A0WtClL1aOkvuXV AjZET9Zm9GDrfS/qZb54DOK30pfLtY+0whj/QcwbjBWiR4HBepYYImhOdnS5JULEwh8A i+j1JnYTLy4OSDZt36VKdoWJssjDvOk45rpMAROqCo2lFuh5FoX1uvimnD2lBVwe3z27 bXWWUoFe2a046SwxdKCc3FIX3gtLo0hixFkYEL/jfR0cY3aRKfHSg6AEZ4hifLhGVBEL AbXg== X-Gm-Message-State: AC+VfDwi73zVeQJbm79K1S7bGBu1DxMNB+2YETjBcha0RuXMRBaoFXvq JtbjZv0K7CHmL5WfugOutznrsg== X-Google-Smtp-Source: ACHHUZ69KXukmyot872anEoUey3A/ripqRG6cW5zFnKfKVcFYWhE2nPM2gOakUW1M8OGWWqjk3tXDw== X-Received: by 2002:a17:903:1103:b0:1b5:91:4693 with SMTP id n3-20020a170903110300b001b500914693mr22501319plh.1.1687427254608; Thu, 22 Jun 2023 02:47:34 -0700 (PDT) Received: from ika.internal.digitalocean.com (ip-091-089-160-106.um28.pools.vodafone-ip.de. [91.89.160.106]) by smtp.gmail.com with ESMTPSA id y10-20020a17090322ca00b001a6dc4f4a8csm4973456plg.73.2023.06.22.02.47.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 02:47:34 -0700 (PDT) From: Jan Glauber To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jan Glauber , Baolin Wang , "Huang, Ying" Subject: [PATCH v3] mm: Fix shmem THP counters on migration Date: Thu, 22 Jun 2023 11:47:20 +0200 Message-Id: <20230622094720.510540-1-jglauber@digitalocean.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: E819A160019 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 8fp9co5yin8ryk8nsbnixtj5nt69s16n X-HE-Tag: 1687427255-805912 X-HE-Meta: U2FsdGVkX1+Nso0gY/AjF5AV5gH1AikrhS3klJoPMAY7QOpTG6nPabUbopIIluDyA0DHb8siXqK3AMIh8l6V/JHqYWm0IvIZLtzIvHtT38jjo/fzc8a9MC1MvH0niRlpO9eNU1fnhSrsDi8ZN1NN5r+xupfvix6d5yUA442N8vXZS5/YIFe18rHgjts7OU1ykMrVTC4kVBM8lXAQkVoKcdYOcjnQttt27kl5zsj6zEH1lArrWGK+lzCVf3wPv5Zxf0x/Q7i7SjSPfJNnL+svVCjOToN5uffhj9U9GiO3yZ7vBqRdw+eZcTuEU9To1GrApfk1WVZQz3kX7GKeRLqYi1OyW8oa8G1dsYgWMkvFTa+LMIs4QMn8ns49eZExs4sUZwIvhnk37Hl4OIMohDjCSiBsLSxojMGSTuWk2+trKR0WDlWYr7H0Drq5iqlNpswwRvemALQP2EO09cDM5RQs/486/WnGVy4NovVTpAhXjdsap/Y51K2rLEw0gSCSp0bnw0E/tpWlu327UbiobWfUX/1YbeGwULvLnaNM7EzHRpCkNrEKmB6MlSq6O2VNfRYXyoqOAANZRuKsl9GSMpYXmnna/89Vp4E5k9MNMgR6s/w56Rs5tlZHe47Ys9TQVxJa2BZgp0i/tnSwx3XOzDCj2+ezKAZ1Al344EVeUlyDvBYoKp6NwqWlUtwKKUqrBMn0/xeDaGRmm+Jsm1dkP/7zanUxgZExo6YJs0WVe6b3DrP3JOKEbofTzCkxIOojJCGxlM7L/YzqyAeo9FZslQE5giYVVY954qTWtftuOvVwnU/r2kSCkWhNZ1wDs+mNNNdPnpYXNtUDoM3I5I4E83URGmQ7lmL37RUhCEq+PvZmFGty6BMHFghPJsh9bxOU6fUH4xnCvCdaqYAZwqJNudUaUDsuRvAclzPhX6m+VW1z5FpgkpBW4WQ3OISTe2myZPzWq9zaWKiokcnjkEXVX6Q yu3HviCV t4fqjYAOVrdJmIbSjgA3UtPMSpG0CipHmnwp/AaEjkYOt79YH++uqmJoucbgFkg/cbovyGG2juXIPLf6zWASDS9K9eu3dW2EmpPMJUueegJC638Bd9FG9s7bHu+W/Rc3DUk8yN7kXbgcsso8WpRw7ZagOoDvdvOxSIIBTW9OU+0y41ZUxxcowAfBxmz4+3t9SNedElS3EZObduevFdTp2IcXW/7DreVHYUKZiiNFohjccE6e0MzrwnJe2w8VtQJQmoCC/xMVaPBT3Gl8TgEQ1P24ZQ2WIXduDeJ6AHKepy9Ps9dJAhuD9RyV3jBcxz2vPZWwnZU/x02FShAozbRN6G8QHcQXFlcddwCc9Sx4gekzZTh+daI39/KrejocSB7Rul07+ 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: The per node numa_stat values for shmem don't change on page migration for THP: grep shmem /sys/fs/cgroup/machine.slice/.../memory.numa_stat: shmem N0=1092616192 N1=10485760 shmem_thp N0=1092616192 N1=10485760 migratepages 9181 0 1: shmem N0=0 N1=1103101952 shmem_thp N0=1092616192 N1=10485760 Fix that by updating shmem_thp counters likewise to shmem counters on page migration. Signed-off-by: Jan Glauber Reviewed-by: Baolin Wang --- v3: Use folio_test_pmd_mappable instead of folio_test_transhuge v2: Fix compile error --- mm/migrate.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/migrate.c b/mm/migrate.c index 01cac26a3127..6ef8b1dea2e6 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -492,6 +492,11 @@ int folio_migrate_mapping(struct address_space *mapping, if (folio_test_swapbacked(folio) && !folio_test_swapcache(folio)) { __mod_lruvec_state(old_lruvec, NR_SHMEM, -nr); __mod_lruvec_state(new_lruvec, NR_SHMEM, nr); + + if (folio_test_pmd_mappable(folio)) { + __mod_lruvec_state(old_lruvec, NR_SHMEM_THPS, -nr); + __mod_lruvec_state(new_lruvec, NR_SHMEM_THPS, nr); + } } #ifdef CONFIG_SWAP if (folio_test_swapcache(folio)) {