From patchwork Thu Nov 21 16:27:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenchao Hao X-Patchwork-Id: 13882133 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 04A65D7878A for ; Thu, 21 Nov 2024 16:28:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 601D36B007B; Thu, 21 Nov 2024 11:28:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5ACE66B0082; Thu, 21 Nov 2024 11:28:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 44DDC6B0085; Thu, 21 Nov 2024 11:28:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 283176B007B for ; Thu, 21 Nov 2024 11:28:11 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A40641C7F0D for ; Thu, 21 Nov 2024 16:28:10 +0000 (UTC) X-FDA: 82810632324.25.645728E Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by imf11.hostedemail.com (Postfix) with ESMTP id 25D774001D for ; Thu, 21 Nov 2024 16:27:02 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=J96NFHLB; spf=pass (imf11.hostedemail.com: domain of haowenchao22@gmail.com designates 209.85.215.170 as permitted sender) smtp.mailfrom=haowenchao22@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=1732206305; 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=fYbMhn+O/PdOLgendykEEYqTshCuv9eC2NatkA4BCfA=; b=lKIOLhXy/TuJKqoiRTCh0Qz2a5PM1fjAtv9fC7XvNOJ+pCw/dWx8ncg/9NrjEQY+nwKO5M PGSyJa6p5OqkeOp/aypjLz1b5J8WXG4w5yebbxeat0IvSMvN4mcCQk2YH4CC9iaVUzVMoq p0LQVRpaaU5WDVfe+Z6ovDv3yfOTYYQ= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=J96NFHLB; spf=pass (imf11.hostedemail.com: domain of haowenchao22@gmail.com designates 209.85.215.170 as permitted sender) smtp.mailfrom=haowenchao22@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732206305; a=rsa-sha256; cv=none; b=LssL98D/z5J49pSo4pugzzRUoKmW9Jvt90csSJgh+q6/5Q7WFu4dlufD6/6IfqKkpIYV+S NHLY//qZaHw4PlMbqMJHTKwHApPVzAHrjh/6AsaOz+uRfk/wlNiikaDdKEa8M4T+fsFA5A YUgtlphBrtNbqJ+7NMGk22mAVDBMTyU= Received: by mail-pg1-f170.google.com with SMTP id 41be03b00d2f7-7fbc29b3145so436726a12.0 for ; Thu, 21 Nov 2024 08:28:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732206487; x=1732811287; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=fYbMhn+O/PdOLgendykEEYqTshCuv9eC2NatkA4BCfA=; b=J96NFHLBUvasM6f+4jdM8f1gPpeFDJL2SWdJhQ4UgRKTuU1OJkU+69M05XkjcG72iT xSaODhnJZOVVVU85GhYwtjCA71aGFvWL8ZKTjD/xlPL+dZaEckomFwmmIOnfTXgSnrPn Qi2A1GdKHmA/rX+PfwAwXdLehhTFE6AOJEbNMc694CosYNU0paaJ1PCeaBzSamzy77fU wx3tYaHW3Au/RC9nnFnn4zKvo+GJ2kWPUkW0l0YYlnGUf81VdLgx9vH+/2KjtoSL59ly o8yxLrHc+s8njNX6lhxDHZ+WWumsyGPdrwQWzAp+C7EvW1Sd7y8WpIr4RVf8U3L7Os42 NybA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732206487; x=1732811287; 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=fYbMhn+O/PdOLgendykEEYqTshCuv9eC2NatkA4BCfA=; b=JWlaw1i6+vHkVGRrZfv8UL4/tFDJ0/gvtImw4qyviN2eUA/uV/UWxx1XiScrIMfhHH GLXDT0xt/8XwG5WrQxYdSk2otKYd5zASciFKUuGxuvUbvqnhlacfQmnvJnjrjmd0dhmY sPbalVAtZQ0vPAu4wGHz3kPMLkOCLy+YNifvelmlI1KEcNZCZiro2ONqoNWyqCFqn1mr dRt4fEqgKZpHckmBqre6tsdDJ4ZIHzIrgx/TwZSqlV6Qf2dLDSRx/RHumj/GAoLZlzeh Er5MXxf8qIj8Bf/97F0wEZjnqDX+6ZP/R0bsRE+jPMLJWTJa6WnF7lTHheXI2FbC6ytd BDgQ== X-Forwarded-Encrypted: i=1; AJvYcCVCOZITmm3zk6pHvDUyLetq0ot5wsBa8f6x3NJr96SZoJLiWmzST7MChuu8I2aeYiIq5mrIvQO4xw==@kvack.org X-Gm-Message-State: AOJu0YxgmazZ5hiTGZfzgqsd+f9BmRfJdbyHuG9m/4XT9/jIlpjDU6cP qnI3Tr9dx6xh39ASI8zoDSOx1vG3UqDo61YsVmA85SSjoWVCAaeo X-Gm-Gg: ASbGncuMOvjxwn4GRzsj1285HhkK/7y6MY+mnspLpfThuqfiLb6yMAN5EQ0jKp894jC qVS2b+jm0Y0eucW6GAol38SGV997YBTp4n7GQDhHUHzlDJEIBsnmyXwDpT9oUQ+iqi1j3T4s/Tv wf9nSvHSXOKq36lZgPoUHzkr0xblW4XntrQLr8cAgEOGS58ok7ktGxKnn7539C4iDD86pQdQVLq aRfwwgTa65TxVJpO0RXFWZzm6lH+VC9S36BfsQmenClz7daCVjOjbHePornAMsQWB8RLRCFZSY= X-Google-Smtp-Source: AGHT+IFz+jBkxsWaONKMNJNklRjrdFnYIvcTcgGwbRZcbPXsMhd4+ZGYWBAXIpEQk96vXKzSeLeGvw== X-Received: by 2002:a05:6a20:12c6:b0:1d9:3747:fb51 with SMTP id adf61e73a8af0-1df9c805af0mr6412811637.8.1732206487069; Thu, 21 Nov 2024 08:28:07 -0800 (PST) Received: from localhost.localdomain ([112.2.230.32]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fbb659e913sm1518418a12.71.2024.11.21.08.28.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 21 Nov 2024 08:28:06 -0800 (PST) From: Wenchao Hao To: Jonathan Corbet , Andrew Morton , David Hildenbrand , Barry Song , Ryan Roberts , Baolin Wang , Usama Arif , Lance Yang , Matthew Wilcox , Peter Xu , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Wenchao Hao , Chuanhua Han Subject: [PATCH] mm: add per-order mTHP swap-in fallback counters Date: Fri, 22 Nov 2024 00:27:35 +0800 Message-Id: <20241121162735.9558-1-haowenchao22@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 25D774001D X-Stat-Signature: 3dbwwjxq6bax6bz3adey8ct6e14isjz7 X-Rspam-User: X-HE-Tag: 1732206422-806162 X-HE-Meta: U2FsdGVkX18go7NPMMfPx7yu78j/wsYUMq9bWT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7/7Y6aTSPZ9XDHMSkPrpBIWZPjSFi1bBqyotjkzaWIJzRarCgEyOjnql8ilqu8niQjxsSgdVwiPCplk9jjodZU/M5spJpOaj20zg+rOF5u2GdRczDiocEMi9hEFr4RdwPdqc2TwjJlcRGzycOuPK+dV1XplQDkZ1Ghfgo6QPUrQTc6pkdU5kvmr8E7tsLhdCZuInANr6d/xOuZNsB/8NQ8plHKpmLBqaFon3iHaKI2yd7vXDRyKI6772O+UWlQMkm9GjkBR9ihjC2+qCMcGNU+7PWtx9FNaifDg== 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: List-Subscribe: List-Unsubscribe: Now large folio swap-in is supported, but we do not have a method to analyze the success ratio of large folio swap-ins. Similar to anon_fault_fallback, we add a per-order mTHP swpin_fallback to help calculate the success ratio. The new counter is located at: /sys/kernel/mm/transparent_hugepage/hugepages-/stats/swpin_fallback Signed-off-by: Wenchao Hao CC: Chuanhua Han --- Documentation/admin-guide/mm/transhuge.rst | 5 +++++ include/linux/huge_mm.h | 1 + mm/huge_memory.c | 3 +++ mm/memory.c | 1 + 4 files changed, 10 insertions(+) diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst index 5034915f4e8e..f5c775457913 100644 --- a/Documentation/admin-guide/mm/transhuge.rst +++ b/Documentation/admin-guide/mm/transhuge.rst @@ -561,6 +561,11 @@ swpin is incremented every time a huge page is swapped in from a non-zswap swap device in one piece. +swpin_fallback + is incremented if a huge page swapin fails to allocate a huge page + and instead falls back to using huge pages with lower orders or + small pages. + swpout is incremented every time a huge page is swapped out to a non-zswap swap device in one piece without splitting. diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index b94c2e8ee918..dcf08f8fdf52 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -121,6 +121,7 @@ enum mthp_stat_item { MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE, MTHP_STAT_ZSWPOUT, MTHP_STAT_SWPIN, + MTHP_STAT_SWPIN_FALLBACK, MTHP_STAT_SWPOUT, MTHP_STAT_SWPOUT_FALLBACK, MTHP_STAT_SHMEM_ALLOC, diff --git a/mm/huge_memory.c b/mm/huge_memory.c index ee335d96fc39..6b089a41acef 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -617,6 +617,7 @@ DEFINE_MTHP_STAT_ATTR(anon_fault_fallback, MTHP_STAT_ANON_FAULT_FALLBACK); DEFINE_MTHP_STAT_ATTR(anon_fault_fallback_charge, MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE); DEFINE_MTHP_STAT_ATTR(zswpout, MTHP_STAT_ZSWPOUT); DEFINE_MTHP_STAT_ATTR(swpin, MTHP_STAT_SWPIN); +DEFINE_MTHP_STAT_ATTR(swpin_fallback, MTHP_STAT_SWPIN_FALLBACK); DEFINE_MTHP_STAT_ATTR(swpout, MTHP_STAT_SWPOUT); DEFINE_MTHP_STAT_ATTR(swpout_fallback, MTHP_STAT_SWPOUT_FALLBACK); #ifdef CONFIG_SHMEM @@ -637,6 +638,7 @@ static struct attribute *anon_stats_attrs[] = { #ifndef CONFIG_SHMEM &zswpout_attr.attr, &swpin_attr.attr, + &swpin_fallback_attr.attr, &swpout_attr.attr, &swpout_fallback_attr.attr, #endif @@ -669,6 +671,7 @@ static struct attribute *any_stats_attrs[] = { #ifdef CONFIG_SHMEM &zswpout_attr.attr, &swpin_attr.attr, + &swpin_fallback_attr.attr, &swpout_attr.attr, &swpout_fallback_attr.attr, #endif diff --git a/mm/memory.c b/mm/memory.c index 209885a4134f..7cda8b65e0c9 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4191,6 +4191,7 @@ static struct folio *alloc_swap_folio(struct vm_fault *vmf) return folio; folio_put(folio); } + count_mthp_stat(order, MTHP_STAT_SWPIN_FALLBACK); order = next_order(&orders, order); }