From patchwork Mon Jan 20 10:16:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usama Arif X-Patchwork-Id: 13944993 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 90C42C02182 for ; Mon, 20 Jan 2025 10:17:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 26E38280002; Mon, 20 Jan 2025 05:17:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 21DE3280001; Mon, 20 Jan 2025 05:17:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E608280002; Mon, 20 Jan 2025 05:17:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E564F280001 for ; Mon, 20 Jan 2025 05:17:10 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9E0268295B for ; Mon, 20 Jan 2025 10:17:10 +0000 (UTC) X-FDA: 83027427420.05.F29C1C8 Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) by imf04.hostedemail.com (Postfix) with ESMTP id C0D6640005 for ; Mon, 20 Jan 2025 10:17:08 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=KjxvHsCr; spf=pass (imf04.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.160.180 as permitted sender) smtp.mailfrom=usamaarif642@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=1737368228; 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=wH8n6M1FLf+Q3kYAV5hU2GmbXEqnbBe66cN0Bk155yE=; b=acxyOFW20ADo2fMsFBzKZo7T/cXaSvmD9cXtknl3B8vp5cJZEhj6F6QtaNNqh+JaphFHjG VdlBOtHQSHu8Ubx4EyfbPW8A27wuXGQ9GNArQ3sl1YtQRsy6yph9l8tbPm5diNoEDQ115E IAxtA3ewTNwRZJqbwSgHQfPohQx1wJk= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=KjxvHsCr; spf=pass (imf04.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.160.180 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737368228; a=rsa-sha256; cv=none; b=upVXSOjNSUsf0o4WieqYHZYhwdEoZl/Cgdc8JalbMc8tXD2shpYMhWQ3zQe+VLmo7w0uK1 9ucRk/ZEy6ewllW25893IjbFjDu02PmjO7WL7iY1Z5C07ksPt/oG4v6BmTctam8SOwiOsm SxuImJrGr8+9RlZPgC/gZFRi4e57k5Q= Received: by mail-qt1-f180.google.com with SMTP id d75a77b69052e-467a63f5d1cso36106971cf.0 for ; Mon, 20 Jan 2025 02:17:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737368228; x=1737973028; 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=wH8n6M1FLf+Q3kYAV5hU2GmbXEqnbBe66cN0Bk155yE=; b=KjxvHsCr0siR5W5ROjjM0JXyp6k5oXa8SRRMXjP7oHMcrZ995ACNBBsvPDhtAHsUqC 5G/Pa7MAh5GkKidSSG3kT89ExDonqxnppmVzbv94C9cMFb6UNOu2H7qUAGkY2EOfY4TV 5QmYgZugKWkgcf/fWRXUVC5WUGYaUb59NTFtISx1mRmhPSUzHidoJBzZ+vE46pMowvgZ Z6ttb5InHpm2Wzb4ZuPQQb1CuiwWLSGp7KAZ/vBaxfKENp3kD39TP6/OT+4W063dIviv LFpkMAzpIeOkXZe7i44INlqKc4RFhrFKILSEX92UxBI3D2crm/PAjSE2vtZWBvprTSXi yyyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737368228; x=1737973028; 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=wH8n6M1FLf+Q3kYAV5hU2GmbXEqnbBe66cN0Bk155yE=; b=IcCpFQaD4frBAMKuUV2XJ2gaxxFXiiBdL3GUmMbYq6LJ4/K+2PUVIOlhBsJiYUHidr JyjbhUWeTjAtgJ9Nf+sEmf4X4SmSyCZS7M4DonI/u47DH/5qX+xlXcCTaqUolpKEsrBH nwgqmPIW8Wh/VTWWReWY9MKGDI3vFmgJb6IZqX0fNwcPfeSjrx5BK36+6w04bgWlQn47 LMUg6XBgJbcac4EaCHFhdx/1NmwPnKqDZ2SY2kmOcUXBvFLjrT7AQTGtBUR648gHMu0k 1uF6nlrKRn3Is5RaHBuP8mY1IhiI2JksDuk9uEcopDhrfSMgtayEJDVxTcukwORiq1yi JheQ== X-Forwarded-Encrypted: i=1; AJvYcCWk2BYUK9aGt5LxpjNqDVHS0Qhf27q/R4VTfZ1I59wsXqVGQhwi+4sDG9S2fjmbiM+aL9by54B3AA==@kvack.org X-Gm-Message-State: AOJu0YwKyHAhGBKnq6OPzTruTvX7F4ciCnYVr9da6OPkiyn/UzLj8lr5 rQ5360v54t+zUyFnsfUcJrMJ9oFrgTiVPscA6bsSOzIy3RgoTnxs X-Gm-Gg: ASbGncspvKmymiGSxdh+6mGqr733qJGW6WQFbwmkEl3AlZrsFjbgs5/KuUGPKHtrMnd 9laEbSrj6juei8Tf6ARwUkAwga9dLFJdtgNWRwk8vBq5FF0J2wC/dlTj5srpfwhQk/8+pSER32i na50b1hASw4hgO+7+uZLUQ7XI0ROs1G0f4DHHKyuY66+thY6nL2jdRaJ4moG4hgsMUuZm846pwJ rELqCrE9owLAqLx6pIjpB6EjLJD+/bRJIcT3kXoDg101fe2Y7mBo7E/vlODxjqA58Vs X-Google-Smtp-Source: AGHT+IFmUgBA3+omEnqHHxh5cbjS72TTV3b+VWTE2szCVUIWMLyqJVzELE/lD1IXBI92VmONmnfh0A== X-Received: by 2002:a05:622a:1a0d:b0:467:5ea8:83e7 with SMTP id d75a77b69052e-46e12ad56d3mr165357511cf.9.1737368227740; Mon, 20 Jan 2025 02:17:07 -0800 (PST) Received: from localhost ([2a03:2880:20ff:46::]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46e10305328sm40934491cf.32.2025.01.20.02.17.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2025 02:17:07 -0800 (PST) From: Usama Arif To: sj@kernel.org, akpm@linux-foundation.org Cc: damon@lists.linux.dev, linux-mm@kvack.org, Usama Arif Subject: [PATCH v2 2/2] mm/damon: introduce DAMOS filter type hugepage Date: Mon, 20 Jan 2025 10:16:50 +0000 Message-ID: <20250120101650.3761306-2-usamaarif642@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250120101650.3761306-1-usamaarif642@gmail.com> References: <20250120101650.3761306-1-usamaarif642@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: C0D6640005 X-Stat-Signature: 1dpus18t1z531chojyz5b6srdjcwwiyq X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1737368228-927846 X-HE-Meta: U2FsdGVkX1+Jm/SvzMMpZ2UJDZIH3iTRpwr6QfRn+HVXh1ij0z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VOBsKU2MLgrE4S6eH6QxAbil5zh0OPfb30S6Ei3//v9T/IM/2qLgciYTkE9GtzM818MPH6FgHAjZjMfKph/fbUyVXSEl/LZ5QTiuxhhs+4Pg7dB6m6NuNrGMACEtywFaLoidSO17U725h2xxRrzCk3dTP6tQLvs3cOHgFEhS/47RQT+jPd32I1BShoy+q4z+XNVB0qoeHlp1xJ4UzEUISzEKBtPUFhIXNUaHH2hECnGzQ7KaqYAeslcXfCr1FshyrExNWFaFhTnWkZgR2CRXPsGliMjrQrNr7kUEF03HKyTEZREwmsSntP+jypecc/pQs= X-Bogosity: Ham, tests=bogofilter, spamicity=0.003084, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This is to gather statistics to check if memory regions of specific access tempratures are backed by hugepages. This includes both THPs and hugetlbfs. This filter can help to observe and prove the effectivenes of different schemes for shrinking/collapsing hugepages. Signed-off-by: Usama Arif --- v1 -> v2: - Wrap DAMOS_FILTER_TYPE_HUGEPAGE case with CONFIG_PGTABLE_HAS_HUGE_LEAVES (SJ Park) --- include/linux/damon.h | 4 ++++ mm/damon/paddr.c | 5 +++++ mm/damon/sysfs-schemes.c | 3 +++ 3 files changed, 12 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index af525252b853..b0dbf380ab76 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -326,6 +326,7 @@ struct damos_stat { * @DAMOS_FILTER_TYPE_ANON: Anonymous pages. * @DAMOS_FILTER_TYPE_MEMCG: Specific memcg's pages. * @DAMOS_FILTER_TYPE_YOUNG: Recently accessed pages. + * @DAMOS_FILTER_TYPE_HUGEPAGE: Page is part of a hugepage. * @DAMOS_FILTER_TYPE_ADDR: Address range. * @DAMOS_FILTER_TYPE_TARGET: Data Access Monitoring target. * @NR_DAMOS_FILTER_TYPES: Number of filter types. @@ -345,6 +346,9 @@ enum damos_filter_type { DAMOS_FILTER_TYPE_ANON, DAMOS_FILTER_TYPE_MEMCG, DAMOS_FILTER_TYPE_YOUNG, +#if defined(CONFIG_PGTABLE_HAS_HUGE_LEAVES) + DAMOS_FILTER_TYPE_HUGEPAGE, +#endif DAMOS_FILTER_TYPE_ADDR, DAMOS_FILTER_TYPE_TARGET, NR_DAMOS_FILTER_TYPES, diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index c0ccf4fade24..224308140441 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -222,6 +222,11 @@ static bool damos_pa_filter_match(struct damos_filter *filter, if (matched) damon_folio_mkold(folio); break; +#if defined(CONFIG_PGTABLE_HAS_HUGE_LEAVES) + case DAMOS_FILTER_TYPE_HUGEPAGE: + matched = folio_size(folio) == HPAGE_PMD_SIZE; + break; +#endif default: break; } diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 98f93ae9f59e..3eb3ec464591 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -329,6 +329,9 @@ static const char * const damon_sysfs_scheme_filter_type_strs[] = { "anon", "memcg", "young", +#if defined(CONFIG_PGTABLE_HAS_HUGE_LEAVES) + "hugepage", +#endif "addr", "target", };