From patchwork Mon Jan 20 18:19:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usama Arif X-Patchwork-Id: 13945466 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 AB68CC02181 for ; Mon, 20 Jan 2025 18:20:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 20E946B007B; Mon, 20 Jan 2025 13:20:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1BF026B0083; Mon, 20 Jan 2025 13:20:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 087446B0085; Mon, 20 Jan 2025 13:20:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DAF5B6B007B for ; Mon, 20 Jan 2025 13:20:07 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7E36442E5A for ; Mon, 20 Jan 2025 18:20:07 +0000 (UTC) X-FDA: 83028644454.28.4D51D55 Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) by imf24.hostedemail.com (Postfix) with ESMTP id A86B9180016 for ; Mon, 20 Jan 2025 18:20:05 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=GMWmTHW9; spf=pass (imf24.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.222.177 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=1737397205; 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=JVrThU83vZ5H73oLhTqtQwzItGk1gBFlj8uzbRxyZks=; b=d52R2KlPp+ypE+P576/Rl/Q9kolByqfJHqKKSNUqQH7V3RIM3Rxma0C2Ct2Nli3RBsT69D ykoyrspBZP+aUQfe6vGTYL7X45+msNJDgu6fm+ZvPHgPKduHyUoJgrdbR89mfSa2cd66Qn dBD+IMrJGTTDpUIzFVa6fcYuTMDyrd0= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=GMWmTHW9; spf=pass (imf24.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.222.177 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=1737397205; a=rsa-sha256; cv=none; b=DXz5EClC4AqfZ/pE2lI8Raz44+47L1aeCEtmLz+MMrZlFQQM+QX+V0MWQumFIbu0lSfm2b 69cdOxx2UpGaxsRDkc/6JnNw2HUkT5vWwPZwXceR5+BJ5wmI2asjf+gvvlnuTO5wxQ7FBe YlvGo8/VE2Rn/EnjOow4tItfFmLRNOc= Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-7b6e9317a2aso501262685a.0 for ; Mon, 20 Jan 2025 10:20:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737397205; x=1738002005; 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=JVrThU83vZ5H73oLhTqtQwzItGk1gBFlj8uzbRxyZks=; b=GMWmTHW9hPixT7kcMEk1kf1aTmq131cW4JZ+mCggRaiRIOQNS4Jzrnojngy1scT8Eq M1AlpLAcZRPJKx30FC/CbV3xX3Q7Mv+kJX15LdKOAQ07pKpShK4LQmRw0vvh53Ebd1VR 7FFeD84REWD1pcbGj4ZHuAfS9R+a3EDgqXYpcfot3AQygFTzW5Fyhd/WGkMbKrkIVX6j W9FI8C2pB335JcAv7nsfagGGipWGzBKmiUKfHIRnc3js98t0FxvVCOmInaFTBcTjWYZW 52wrxj2Li8w4uuUnMrGgIWi9E0UKJ2qOFEJdtap9Ya0ouQb1b7/HiRCmlAUhrWlrKmCm 6vVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737397205; x=1738002005; 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=JVrThU83vZ5H73oLhTqtQwzItGk1gBFlj8uzbRxyZks=; b=j57Hg3CBF1Xwgv+XShEUC0QKX+5YXWSCBjVUPWNaX/PsVx3VkYo5YAFJc5TEXsAOPl M8yg6SF5CKqBeen9WRPgA5SMKe+hUetuGOE1a5lFgtzfoQ7ehiAj3H85/T9uA2wvFlvW 7CvM+zPsvGevpsh3ScowrgBZUxeDH36XxL5CAibzVnGX18bthCnx6eP+pRTFVGe8+0X3 g2K8ATtAixO9GDPJQYaTAEnyukOImDwzG0+wnvWN00q7SWp3QyQYP/7HWO2R0cS/n2uU DYeacZxPHdvTZWyCHoY0p6VoOy43aN+cQe2TsnGtZB7Hx4KyI2hm5H+JCg+jizPeoAUB 08rw== X-Forwarded-Encrypted: i=1; AJvYcCXsNEEA008cwYZTnUh7jScvvhPHgPKcRLdSJ4YkoN/C+oLG8sVXB+9mLj9TcqBDwCOx8UsZu6+0ug==@kvack.org X-Gm-Message-State: AOJu0YzBwJ9oO9jhDRMU3hFbeEhUBoyek1uLu5jcbkz7pEY1umBcAHO9 tqHOXQZQRpV4j7tY0/8ct5ZMmYTBqD+imYdW9H9n2jgWHqCQOP/p X-Gm-Gg: ASbGncs03fZJAkHh+QcYrET8qG2o8+p9w1NUyJeNVct7sSBZ5/K+n6DJup5GOPIUkhJ ptxEuIq1Qnc+4A4y9APB1vrod56a4rb4oicqPPN2AvS7xtUaPMd6Xszq9bnuInPT8yjEJmQjRXB JD5HyzLcbvolr/VMZvbHyqRyFw4/BfpzdUAAYoTFK42dAwwmsSvU4e8P8uj/KYsbsrEBEMVaGzz 4uokgzU7XFDB8f+Bel5K31WSUASZ1RNPqL362rqoMs8WW3HMnaRlCDSLyzfIqZPFXk= X-Google-Smtp-Source: AGHT+IHWKPSR5z9JA6koDvNP81QlnTvc47HRNzCL+8YDLseL8aIfUAnt2oN7O0sCFq1Zh0xaT9RoHg== X-Received: by 2002:a05:6214:5c01:b0:6d8:b733:47c with SMTP id 6a1803df08f44-6e1b27a48fcmr243385356d6.22.1737397204636; Mon, 20 Jan 2025 10:20:04 -0800 (PST) Received: from localhost ([2a03:2880:20ff:6::]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6e1afb1b293sm43501026d6.0.2025.01.20.10.20.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2025 10:20:04 -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 1/2] mm/damon: have damon_get_folio return folio even for tail pages Date: Mon, 20 Jan 2025 18:19:58 +0000 Message-ID: <20250120181959.2564362-1-usamaarif642@gmail.com> X-Mailer: git-send-email 2.43.5 MIME-Version: 1.0 X-Rspamd-Queue-Id: A86B9180016 X-Stat-Signature: 9pp6sfspb6tk78p1r1xwrmfp9zpcsofs X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1737397205-158179 X-HE-Meta: U2FsdGVkX1+dJToDvgYFQJSmJz/Hy1iQzSNNui24Hn6C1z5uIAebqUTOJXZSKk4dCCOaNcu3eyxq/jXNz/j1iAKG//kfVHcCPRPFMZ3iQSOND0kgvNOXhzdWO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ZdC3GpLmczjxClEgZ11qVyXD9lW2IWeohvZgEFs3gbCP5uXlDDKwP4qW7AVwIXtuC+0BH5sY1xN3MbC1Nr+tFxIgykKjibSoz8vNiFMdbSiL6tk8So98En24+ksXTU2nylcjltrjUGRc4EpIh5uP4IKHJgczGk6tR7bkrpfQxY6UDMvQm+V0sZYeELaZgM6p/KJyTwpVnp0LZDcyA8wVjDFc6WucVisrRa7q4B9M1kI6VXodtP0tOF2ms+hDi6fOPzL7ALnXUXEjkoMHI/3EobchRs0gWnf5vF91sNQk4Cg1pVHJFM5JjDYPZxv6HTqo= X-Bogosity: Ham, tests=bogofilter, spamicity=0.185952, 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 effectively adds support for large folios in damon for paddr, as damon_pa_mkold/young won't get a null folio from this function and won't ignore it, hence access will be checked and reported. This also means that larger folios will be considered for different DAMOS actions like pageout, prioritization and migration. As these DAMOS actions will consider larger folios, iterate through the region at folio_size and not PAGE_SIZE intervals. This should not have an affect on vaddr, as damon_young_pmd_entry considers pmd entries. Signed-off-by: Usama Arif Reviewed-by: SeongJae Park --- mm/damon/ops-common.c | 2 +- mm/damon/paddr.c | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c index d25d99cb5f2b..d511be201c4c 100644 --- a/mm/damon/ops-common.c +++ b/mm/damon/ops-common.c @@ -24,7 +24,7 @@ struct folio *damon_get_folio(unsigned long pfn) struct page *page = pfn_to_online_page(pfn); struct folio *folio; - if (!page || PageTail(page)) + if (!page) return NULL; folio = page_folio(page); diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index bd8cfe10121b..c0ccf4fade24 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -266,11 +266,14 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s, damos_add_filter(s, filter); } - for (addr = r->ar.start; addr < r->ar.end; addr += PAGE_SIZE) { + addr = r->ar.start; + while (addr < r->ar.end) { struct folio *folio = damon_get_folio(PHYS_PFN(addr)); - if (!folio) + if (!folio) { + addr += PAGE_SIZE; continue; + } if (damos_pa_filter_out(s, folio)) goto put_folio; @@ -286,6 +289,7 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s, else list_add(&folio->lru, &folio_list); put_folio: + addr += folio_size(folio); folio_put(folio); } if (install_young_filter) @@ -301,11 +305,14 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate( { unsigned long addr, applied = 0; - for (addr = r->ar.start; addr < r->ar.end; addr += PAGE_SIZE) { + addr = r->ar.start; + while (addr < r->ar.end) { struct folio *folio = damon_get_folio(PHYS_PFN(addr)); - if (!folio) + if (!folio) { + addr += PAGE_SIZE; continue; + } if (damos_pa_filter_out(s, folio)) goto put_folio; @@ -318,6 +325,7 @@ static inline unsigned long damon_pa_mark_accessed_or_deactivate( folio_deactivate(folio); applied += folio_nr_pages(folio); put_folio: + addr += folio_size(folio); folio_put(folio); } return applied * PAGE_SIZE; @@ -464,11 +472,14 @@ static unsigned long damon_pa_migrate(struct damon_region *r, struct damos *s, unsigned long addr, applied; LIST_HEAD(folio_list); - for (addr = r->ar.start; addr < r->ar.end; addr += PAGE_SIZE) { + addr = r->ar.start; + while (addr < r->ar.end) { struct folio *folio = damon_get_folio(PHYS_PFN(addr)); - if (!folio) + if (!folio) { + addr += PAGE_SIZE; continue; + } if (damos_pa_filter_out(s, folio)) goto put_folio; @@ -479,6 +490,7 @@ static unsigned long damon_pa_migrate(struct damon_region *r, struct damos *s, goto put_folio; list_add(&folio->lru, &folio_list); put_folio: + addr += folio_size(folio); folio_put(folio); } applied = damon_pa_migrate_pages(&folio_list, s->target_nid); 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+2IkeuHKBXdvLFmbBakECAjpd99muB89lrKsY9Fhe5B3HWkApJE3QoSKbV2vjkUJGqcJtR24WF3g3x3M5C6nkP/zdocYSoKSTgpwcnB8tPFlbo6mTPgTtkAdaoI2pJFN1AAGlvThsX3FRL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Kb7IPXzg4fLefqQEajnOQRXhR0yaK+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", };