From patchwork Mon Jan 20 18:19:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usama Arif X-Patchwork-Id: 13945467 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 0F95EC02185 for ; Mon, 20 Jan 2025 18:20:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 98AC36B0083; Mon, 20 Jan 2025 13:20:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 938A36B0085; Mon, 20 Jan 2025 13:20:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 78BCE6B0088; Mon, 20 Jan 2025 13:20:09 -0500 (EST) 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 524106B0083 for ; Mon, 20 Jan 2025 13:20:09 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 01C83C01AA for ; Mon, 20 Jan 2025 18:20:08 +0000 (UTC) X-FDA: 83028644538.29.A7DE8B2 Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) by imf01.hostedemail.com (Postfix) with ESMTP id 172EF40010 for ; Mon, 20 Jan 2025 18:20:06 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=fJNq1URa; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.222.174 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737397207; a=rsa-sha256; cv=none; b=nZEAJA8hqGr1OYxPH2We5OnW0QVB0DpO56GC/t7SbW5kYMCK4J96860tdemn8bNGDko6ny P/GdpkovcHKmUs8+Xq37r6w+j+HcI+n1mAmoqdeM0GC0lljHpiZFNq1VjqjS3N6/4SfbHq LHGcSckbzgF7b9x7UrqpChwwSzQ0oLk= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=fJNq1URa; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.222.174 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737397207; 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=1M4q3OzaFWK9ln4L3PJAAcFbjl3Cez+v0LDvBWtRTqI=; b=2s8OB51FbeZob3bmxOpMPrn7dNRkxq8Lw6ApF2Lp+U8u9nZJJcckTC1PSJEE8Do3IPFMsN 6wYyIBzrtVmvm93InpHo8E0iZ0Kum2GvaEHvjCnALU4A9pegb4ZEBGkR3YJBuwywNrgJ5I sddDBI7T25bC2CX37LTCaWFdthUvHnI= Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-7bcf33f698dso426139585a.2 for ; Mon, 20 Jan 2025 10:20:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737397206; x=1738002006; 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=1M4q3OzaFWK9ln4L3PJAAcFbjl3Cez+v0LDvBWtRTqI=; b=fJNq1URal5vPeDhmwST8aMMCEIEfsM+UcRYnGZoY2SUJQVc1yZODljvmZLWAxCUlAN 32Ebjhpzjb4bb2asbJ4rz11k+HInj8fO8ilXc7JhiJkYb1AjlyudstMwoMDmnYaFo41u dCikjUnr4Dxx/ARAAFHelZf9rugQuoEwKPcqnYXM23tpwcYSp90uGYXZs33F6PcWCtbc gjTw7vWN5AXbBxc7VW7ZIwDktQ6eXDvdunhgMm1l7ILVaMR0jE/1LBYVFlVSrM1coXmI C/wc6SPRKbOV9F18fImyk9xgw5y/C41xpSvpNjv3sHcLLn6AgE2DMByvOPIRC4YsVG/d t2zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737397206; x=1738002006; 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=1M4q3OzaFWK9ln4L3PJAAcFbjl3Cez+v0LDvBWtRTqI=; b=Sn/0dYxlCwyLHGy3BJ843PTYrZZ0jB5bC7yBQUtyWi2cziZX0T87Rr9wQPE4D1Smza m+Iys+WQSbmbPpxcnP9ufusBW8SIMVQQlG5JM+0oc34G5WCFkDaySXzRVzYKpJfwEYqH I0oqGCiA6XJkzk/bDc+k2fhkgRaSi+I1Vvx5NtlhqH9aG8divlWEkgA5CNYXfsq57Lhu wqTO1Njl9g4RnIDuKSWIzwsIKIIFs+ZEcQv4aR1fcIr+61fGudPVaoSzDp5SNhttMV6d 96tfgMeMm6n2lK21QXDBrYkKdNwD6Vjr3zN8W97iGVK0dIAOGigHMHE30NYCbvV9zo/h oS1g== X-Forwarded-Encrypted: i=1; AJvYcCXb3lwS/hnobuCWaSxlhMGPY2pHS4TUDNClf3R9nH5HkifaqLgmmxbwyYH3PVEt+QkN5gZX7l1nKw==@kvack.org X-Gm-Message-State: AOJu0YzyczQXQ5stgtJTGnczF2fy8k1b6i7lYjmzRTm5Rwq5lpUp7Ool yKLYt68G+Tb0Y/Y6J8ym5hhkH4U3FWVq13ArTWB7DTQ4sSd79RBI X-Gm-Gg: ASbGncsYiapNuf6mFJgGN3k+pM1op1KUSg75oLG0iwTbdStIuhCoVMzmbmLLCS0GuFg NWhn8ViOWRfJ1XSuV58JhlNL/UT7fPbRJm0aOVjy1DyQcB9/FWTt696FeaHhzza3RXcAazv0MYU dfvp+yX9S4UnpSJREuAbU/QRObCN+U9zy7vw/ln83t2XNGEDlsR6CCRnJ5wjzGmmm4TSju4B4yX 28LJy1mTg2jAucsFuOq5b/ulYV45Dd5gu0OEUbJxozUY+NtbJVVkgJ+uXjKy5XQHICj X-Google-Smtp-Source: AGHT+IFQAsTito3CSh5J8vV/UKToUeMLlCwtyu125qfFxl1QXAB+MAWCHYWQfO74uxRe9qi8MQIimw== X-Received: by 2002:a05:6214:5296:b0:6d8:a0c8:e467 with SMTP id 6a1803df08f44-6e1b217a15emr222678776d6.13.1737397206176; Mon, 20 Jan 2025 10:20:06 -0800 (PST) Received: from localhost ([2a03:2880:20ff:49::]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6e1afce473dsm43444246d6.106.2025.01.20.10.20.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2025 10:20:05 -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 v3 2/2] mm/damon: introduce DAMOS filter type hugepage Date: Mon, 20 Jan 2025 18:19:59 +0000 Message-ID: <20250120181959.2564362-2-usamaarif642@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250120181959.2564362-1-usamaarif642@gmail.com> References: <20250120181959.2564362-1-usamaarif642@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 172EF40010 X-Stat-Signature: rwhdsqwmzd5bqzbfqd6upww83rwo5583 X-Rspam-User: X-HE-Tag: 1737397206-294792 X-HE-Meta: U2FsdGVkX18CM+2IkeuHKBXdvLFmbBakECAjpd99muB89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fTM6AcoGmQ4Xl6nrbMN+2woDKczNHT0i97f6SURGnMV1piSGkTWHA2tYOSU6bEz1B2gnkfTa3yjM1tqYwGpbwv+9V/0/mRpnVzfHBVBil20/2Te1Kb7IPXzg4fLefqQEajnOQRXhR0yaK+ieH7K2Gz9BJ85gxLm9D/FJ0NKfBtUF7ovSfZarzGnNszvI4kdNfW1KiCRuhawHHJ1D10+HPkQflXdmd8dJ2HFYyCZcJCpbkqy5s4o6bCHKe8ACMVAw9/hhachShyGuWLTLfbifDqn/1OktcQaz0NCgYOnm19wmGZ48CSjXGqjTp2dZVWl6mYhzdWzewyDhqxoTJ8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.010057, 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 Reviewed-by: SeongJae Park --- v2 -> v3: - expose hugepage via sysfs even if the kernel is built without hugepage support. DAMON will just just return 0. (SJ Park) v1 -> v2: - Wrap DAMOS_FILTER_TYPE_HUGEPAGE case with CONFIG_PGTABLE_HAS_HUGE_LEAVES (SJ Park) --- include/linux/damon.h | 2 ++ mm/damon/paddr.c | 5 +++++ mm/damon/sysfs-schemes.c | 1 + 3 files changed, 8 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index af525252b853..1d94d7d88b36 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,7 @@ enum damos_filter_type { DAMOS_FILTER_TYPE_ANON, DAMOS_FILTER_TYPE_MEMCG, DAMOS_FILTER_TYPE_YOUNG, + DAMOS_FILTER_TYPE_HUGEPAGE, 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..de9265f7ccde 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -329,6 +329,7 @@ static const char * const damon_sysfs_scheme_filter_type_strs[] = { "anon", "memcg", "young", + "hugepage", "addr", "target", };