From patchwork Tue Apr 9 08:26:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song <21cnbao@gmail.com> X-Patchwork-Id: 13621997 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 9BE13C67861 for ; Tue, 9 Apr 2024 08:27:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 346246B007B; Tue, 9 Apr 2024 04:27:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 300436B009E; Tue, 9 Apr 2024 04:27:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1BD436B009F; Tue, 9 Apr 2024 04:27:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id ED1EB6B007B for ; Tue, 9 Apr 2024 04:27:26 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id AEE831C049B for ; Tue, 9 Apr 2024 08:27:26 +0000 (UTC) X-FDA: 81989314092.07.309F07E Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) by imf04.hostedemail.com (Postfix) with ESMTP id 0D6EF4000E for ; Tue, 9 Apr 2024 08:27:24 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=O6coziRY; spf=pass (imf04.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.161.47 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712651245; a=rsa-sha256; cv=none; b=ob2nkeBzl3lp+2fGIVCHWSilXALUIIXfr31gNWfPMIv89k6mFLr75BTLA4L3PbKvcvhKnj knF0ewYVqIfVJU5uXQIgpiimJ4p8E+4Ck3by3HXIibACXycS6TPgvRJgwcf95QswneQMwZ 9E+cQ4UQJd+w7kibaO4M+y8Rh/GFMHI= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=O6coziRY; spf=pass (imf04.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.161.47 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712651245; 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:in-reply-to:references:references:dkim-signature; bh=VvJHnREnFZ1cH5hEIu5QcKzQyYhaFholreUs1EUriRY=; b=gAKlrRv3uvDJ983CDgZ0dMuPyXaahOqMKKa3DPNszpgNJREfiXiFzv6yDmehxavF3CQwZ/ xX6lEp4LYxwMuIt5OE52SosVZRgnkfpA+LgMOqdi+goE0JOS892ovUl1Bb5K+LXgK7HUPw Sg/zVKUV32IczMJvzRFcw0mbpYcJdx8= Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-5aa20adda1dso1979600eaf.1 for ; Tue, 09 Apr 2024 01:27:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712651244; x=1713256044; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VvJHnREnFZ1cH5hEIu5QcKzQyYhaFholreUs1EUriRY=; b=O6coziRYUBf3HXvH1smalQLi5L6Si7xi2odywHmhKFC5dVT17YnY4ilyk3wDz3CC2P n650SHrrg41zGW4UEEDg0leap13WOGttB3aIMOvJm/rvr/2fbmuUU0LtyaMXaHf2/M+3 Kj28S2GZBC2e9R6yeQJ/uIODzgm0yKllSYFeDvmcDAT8XWJ3VyH/cxt4F6lOrT3hltNU 6TD+8t2uqyKxtqWHHZn069IICEoNO+K1FJBmZGk2hnBuggnto0+8vZbuzRAxzIZW2JUx tHmIXogOb6kchoYt1bXg1qYTCoRbo4PwN8ivtQ6uFUsZQhKUrUJzzBSUlR4BtmUHcTOQ Sxtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712651244; x=1713256044; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VvJHnREnFZ1cH5hEIu5QcKzQyYhaFholreUs1EUriRY=; b=GKNoXqvsKvOnYhMvNEWKGD05nWZLT+zer2T63RcKXK3ZEuq0htgp6Y/iywFY4r5rA9 zSj5SY+jWPVn8cU63xDCsozyLHwLl8ISjuAXVEmJ2bgH9+HzLh33rmCjQhfaN4IDwmMx 0Fyub6R3G9CRVYQKAPwHhzDbPB5e43SjqK220kHvzDcB/RPHgbvdqWWOPNmzGUQuOr1P 3UbfUyZj5T8ZFPX/7dq5PmxyP0DbydCDeFifRn91ArcVpp7FViVrPrBf6dyhJyU8p1LN Z37NC1Y3FE9AtzNDTm0ZkJSOJeWvVLQTOCJSkxVj0sFWLf0/r4uXxEbkeIebedFM7JQT 9dcA== X-Forwarded-Encrypted: i=1; AJvYcCVwUgGrwAPV6/La7KlrFmKnbaRfIrZwdNIMle+Jr4/LPT4E7gqI0RCwv6fum8fzIH6C/Wjo70qbn/Scf4bNNYAuhjc= X-Gm-Message-State: AOJu0YxB6622gwX1osj1ApNKIcnUqAf/0IFATBOWHm0YXQWkaYspDC4m eJMMcmZeLJCTYIqdINE+j3fl1KCk7AGueQMerHpTpWdygxa6uLoJ X-Google-Smtp-Source: AGHT+IFBs0lnKgGergw9nSynKWYDcWV9NAHxsayy25kkPHq1gK1xpsfE+xyR/l1fPI85a7fcICPnHg== X-Received: by 2002:a05:6358:d39f:b0:186:102b:777 with SMTP id mp31-20020a056358d39f00b00186102b0777mr9881254rwb.10.1712651243980; Tue, 09 Apr 2024 01:27:23 -0700 (PDT) Received: from localhost.localdomain ([2407:7000:8942:5500:aaa1:59ff:fe57:eb97]) by smtp.gmail.com with ESMTPSA id r16-20020a632050000000b005f05c88c149sm7594238pgm.71.2024.04.09.01.27.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 01:27:23 -0700 (PDT) From: Barry Song <21cnbao@gmail.com> To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: baolin.wang@linux.alibaba.com, chrisl@kernel.org, david@redhat.com, hanchuanhua@oppo.com, hannes@cmpxchg.org, hughd@google.com, kasong@tencent.com, ryan.roberts@arm.com, surenb@google.com, v-songbaohua@oppo.com, willy@infradead.org, xiang@kernel.org, ying.huang@intel.com, yosryahmed@google.com, yuzhao@google.com, ziy@nvidia.com, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/5] mm: add per-order mTHP swpin_refault counter Date: Tue, 9 Apr 2024 20:26:31 +1200 Message-Id: <20240409082631.187483-6-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240409082631.187483-1-21cnbao@gmail.com> References: <20240409082631.187483-1-21cnbao@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 0D6EF4000E X-Stat-Signature: iwt6ae9wn3yaqxu9bucsz7onpqdf3k3m X-Rspam-User: X-HE-Tag: 1712651244-702132 X-HE-Meta: U2FsdGVkX19NkgkET4PsPsy11SPQXfVjBpZiFVmaarz7m/tABQk6MPM1Z7C/LrplsGya62sT7e8QgqYwOj8kt0JPa8/kx5fAkTWlGidjzFZ80XOiaBX1H59xe24FPBGa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.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Barry Song Currently, we are handling the scenario where we've hit a large folio in the swapcache, and the reclaiming process for this large folio is still ongoing. Signed-off-by: Barry Song Signed-off-by: Barry Song Tested-by: SeongJae Park --- include/linux/huge_mm.h | 1 + mm/huge_memory.c | 2 ++ mm/memory.c | 1 + 3 files changed, 4 insertions(+) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index c8256af83e33..b67294d5814f 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -269,6 +269,7 @@ enum mthp_stat_item { MTHP_STAT_ANON_ALLOC_FALLBACK, MTHP_STAT_ANON_SWPOUT, MTHP_STAT_ANON_SWPOUT_FALLBACK, + MTHP_STAT_ANON_SWPIN_REFAULT, __MTHP_STAT_COUNT }; diff --git a/mm/huge_memory.c b/mm/huge_memory.c index d8d2ed80b0bf..fb95345b0bde 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -556,12 +556,14 @@ DEFINE_MTHP_STAT_ATTR(anon_alloc, MTHP_STAT_ANON_ALLOC); DEFINE_MTHP_STAT_ATTR(anon_alloc_fallback, MTHP_STAT_ANON_ALLOC_FALLBACK); DEFINE_MTHP_STAT_ATTR(anon_swpout, MTHP_STAT_ANON_SWPOUT); DEFINE_MTHP_STAT_ATTR(anon_swpout_fallback, MTHP_STAT_ANON_SWPOUT_FALLBACK); +DEFINE_MTHP_STAT_ATTR(anon_swpin_refault, MTHP_STAT_ANON_SWPIN_REFAULT); static struct attribute *stats_attrs[] = { &anon_alloc_attr.attr, &anon_alloc_fallback_attr.attr, &anon_swpout_attr.attr, &anon_swpout_fallback_attr.attr, + &anon_swpin_refault_attr.attr, NULL, }; diff --git a/mm/memory.c b/mm/memory.c index 9818dc1893c8..acc023795a4d 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4167,6 +4167,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) nr_pages = nr; entry = folio->swap; page = &folio->page; + count_mthp_stat(folio_order(folio), MTHP_STAT_ANON_SWPIN_REFAULT); } check_pte: