From patchwork Thu Jan 16 14:44:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usama Arif X-Patchwork-Id: 13941775 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 EDD98C02183 for ; Thu, 16 Jan 2025 14:44:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65A616B0082; Thu, 16 Jan 2025 09:44:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E1636B0083; Thu, 16 Jan 2025 09:44:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 45B2E6B0085; Thu, 16 Jan 2025 09:44:47 -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 279CD6B0082 for ; Thu, 16 Jan 2025 09:44:47 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9F5CA160DB7 for ; Thu, 16 Jan 2025 14:44:46 +0000 (UTC) X-FDA: 83013586572.10.1D67F00 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) by imf08.hostedemail.com (Postfix) with ESMTP id D34ED16000F for ; Thu, 16 Jan 2025 14:44:44 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=WIGRlnyS; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.160.172 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737038684; a=rsa-sha256; cv=none; b=z6IJIHPAY7s0pL7u0Q/+NEPJ9wrinUuOC61kTJ/CzYD2DEwBCYPRQH7y4Yz451nKZCT+Go 34OAJOLHfYE7avR2Mrzo4vN4lZapNdlyazvPptwi7ITAg3Arn2R1PsM0yUvtrhEMYFXDtc Ss2BclfI9T2rpUtW3Ee80lyzK62iNmI= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=WIGRlnyS; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.160.172 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=1737038684; 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=/qBRxGOqRj/BiiIpTnOTMTghJc9OOxuTBkEh32b4BHo=; b=if4Ee8sjlBgE9vnnTqi5BP2IbGk9kzVpE9+Pgae2TGhVMwe+4SmCnGpIHq2dNxTofVaPc/ o7Z2DylsGxDRcOf0i0r7MYwp68AoI6iJjcu5kYzXC9ZG7vCfB5YypBQhF+5NhXGZCdO6g/ aqmr4S8VrEwFnmXZ8++Ill0mnL2JZO4= Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-467b74a1754so13299651cf.1 for ; Thu, 16 Jan 2025 06:44:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737038684; x=1737643484; 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=/qBRxGOqRj/BiiIpTnOTMTghJc9OOxuTBkEh32b4BHo=; b=WIGRlnySveI5u0kGjB3Ek0+hs6zBAVVyzYz7KVwtiCSev0NNINAFJCHyaO6y9VzXn4 zRhNggF/W7uFNE0fHQxZhG8vdGCM+W75MUrzUzJWHqKOP6IMRe/rWG8jdJ2SYzGC2yUw 8qpyV2Iy5HmMHVsHC0SeqRl0E0feiBcIQmVl82uYW4jRJ+4P7RIhUvOkDswdsd8m0XES /tnWWpfGqXMi0bKg3nrKnr6yOZbWW0f6MgaH3c0ISSaqK1YSF+aV6Eym2cIdCvgNxHwP 9z5rvP85pbnwdIsOMWk+Skc9dn6MRPmTWMBpgdsyzqba5rsRram7Gk7UUJ1LZPqIZen2 996Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737038684; x=1737643484; 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=/qBRxGOqRj/BiiIpTnOTMTghJc9OOxuTBkEh32b4BHo=; b=H6FhkIhmFPIt2wX3AmQ9qH16K3+g9T272AbjsAE4tUBpoepiRLM5LMCv0hWRvDtCVC I39FhKWXreDDvL7YfWW1N3qPBSFM4v3nBk31hR5uvteUUYkBOnrQKQkfUxVUFy6slD+E h10EQY/U/ESkfKNTH2w58iT0ZIh2BFtvgWzeWuC5oFH2YGY3t7bl4aif0kM2HMv83MA3 JI64sUp/+oY2Dl7KIVlpnJh641m/SdjvuPVlEy+kjT/aeu16Rm0cN8DnxY5BAYJUuBQg A+LfOJwjSfCHCQC0wAi+eUDEvjf2zCheURQu7PK49PDp4gLcxT5w/78Xr9lWr+jIEYpt uQYQ== X-Forwarded-Encrypted: i=1; AJvYcCXb6VrYvs4miElgenAuCNK1cPigjzwiiBLZ/jViSRtlhimT9pddxJ+hTiyyh0wUBFO+I0d61SO8Gw==@kvack.org X-Gm-Message-State: AOJu0YwyA1d3x2mGg2klKaRKTQ0MxiG3DRyw3WRY06L0q9+TFgSkWvcM w73APKtjilTD2nPXU3A5aOE4AQGfHnFHLJ0/InnjUEevstsPrd77 X-Gm-Gg: ASbGncsTokfYu40CBAXMgz/hJzedhiHyAql7I54FqIypu+VwaiQGqKeLaZz1DDD0Tlc aSq6o+LEth/EwZ9Xvzwem6wyqYXGOz7EJtGbxw2UlVyMZUgHqgLrjHTctyjZI0ul4U+Glstj34t wHUoBsUkvu/Re9D7jZcBOhCfOANyHfCObcolSHw9/L4TQqS6nAUudlCZGUc3uGWUvINwd5CB0Y9 ZNWCpYYqvTz5tR9o8XG+Ypx815tleo656FOiCpF/QwKNWUtCWTAPQ== X-Google-Smtp-Source: AGHT+IFoL7VpAVfqxDqGv6+fM/ykqbHT2KJT9u/FoMGsdyegmHbkvZkYFe7oA5X2KWAfOc78pbZ53w== X-Received: by 2002:a05:622a:1a19:b0:467:7fbf:d115 with SMTP id d75a77b69052e-46c71003ad4mr490164081cf.12.1737038683857; Thu, 16 Jan 2025 06:44:43 -0800 (PST) Received: from localhost ([2a03:2880:20ff:9::]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46e10436015sm80071cf.77.2025.01.16.06.44.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2025 06:44:43 -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: [v1 1/2] mm/damon: have damon_get_folio return folio even for tail pages Date: Thu, 16 Jan 2025 14:44:35 +0000 Message-ID: <20250116144436.3947318-1-usamaarif642@gmail.com> X-Mailer: git-send-email 2.43.5 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: D34ED16000F X-Stat-Signature: kgwkdsqm7dw45r6wqo9o8qx837wsck4k X-HE-Tag: 1737038684-432675 X-HE-Meta: U2FsdGVkX19Rn77qkuo39lkgaMUkyATIU/GX3PM/E8MqlS3T1uD7ALTokrFXIySZt5LaJ2dG4Kn4wkyoBnEmU47G3CF85mkARBwRBSy2ZQ7oFxgsqPHD+Y6l6oH3C6hP7tTR23D5I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QLdLuf1CnYhaLpVJytyTs65vfl+UmuHBOIwzPcCYCmkJS3IsyHoeF42x4JeBxNT4DrtMigoJEiTpMJ3uKcKSK66Zbyohqd9ckcdty9iLcmfR6v+DUWstMzTMTvuA6WT/9A3PjixMvw5rGwe0S5Pc6ykTnCCU2bt7jN7h/TpdLqMd5LCOmjYXXqT18EU3hl9Edy5vkWBmo9/LS2fXiYC5gW6JhVOXPGzPm7QuoRX2kntc3eJ9GUiYchse/dfHfx6FPUd8HMREyS7xWD2SDb3lFJg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.032583, 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 Thu Jan 16 14:44:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usama Arif X-Patchwork-Id: 13941776 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 7622BC02188 for ; Thu, 16 Jan 2025 14:44:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08CA7280001; Thu, 16 Jan 2025 09:44:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 015B56B0088; Thu, 16 Jan 2025 09:44:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA9ED280001; Thu, 16 Jan 2025 09:44:49 -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 B34146B0085 for ; Thu, 16 Jan 2025 09:44:49 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 69FB5A0DB7 for ; Thu, 16 Jan 2025 14:44:49 +0000 (UTC) X-FDA: 83013586698.20.11FF1E9 Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) by imf08.hostedemail.com (Postfix) with ESMTP id 8A66C16001E for ; Thu, 16 Jan 2025 14:44:47 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=HVEU8ZmQ; spf=pass (imf08.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.222.175 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=1737038687; 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=+B+QyGFJcFFPr4jLp7rJgEDbi3fOKEsn6Qh3/DdOqts=; b=RG4BIuq6xmlWEAqfdtPpCmgJeeJ8B1oeHw9u9cNhwQxpTJ0870AH5qouNr9uPaQNsDE91k r2M/brFDH6uTBET+XZm1qZhFGtKHQ5Tg8fBaRJf2mgdXW9kOlL9DySKHJa9LC4TJo6rPam Kh2gNGViTcHDTFiOHtjnlV6uwRiGyEM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737038687; a=rsa-sha256; cv=none; b=OeYUC25sNOcFNGNpCuiak0Fd9fvHlLDwVTh5v7Yz37L7mXlv251RyRqVTcJgf+q2Ohw5WV NmGqtP4xdAlDMJv2ic/1hIBl23IqBpLQqoe0EwIQRwlwBIgSgo8gyso3qEbymBz1yB3skz 45ClH1J4KeSdulUCN8DpeMB909c9Yyk= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=HVEU8ZmQ; spf=pass (imf08.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.222.175 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-7b702c3c021so90411385a.3 for ; Thu, 16 Jan 2025 06:44:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737038686; x=1737643486; 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=+B+QyGFJcFFPr4jLp7rJgEDbi3fOKEsn6Qh3/DdOqts=; b=HVEU8ZmQMhZR5m/MIoMoGtv5vmkUu9RzHxDQT30ryLGSdNfiyKzZ/y57W/MBJ8UrcZ p2gFKlryIeo94PslZTWVaCU+JnFMOB3uW3+xqZ98y7vVadSwbKhePzGUqCTGCibYZ9Bv s8XNXSE+SR8R6qPMysHYoVyNzj5g9G3sQe1eEmtDetGBtFvAOmkzMKFirpDKvSd7gUI2 sE6cagU3Lcd2mvsaJ20EOVEcfwYI7wau6REwY1VwQEpm9PKEOkAlyAhyAhsn382TjOLB YTLXD9c03TXILXjqo/WIVhbBrmBQf7g1fwIEeZJ2GhWFxJw+NdRdBjaueP2xXFU++I9G 9f2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737038686; x=1737643486; 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=+B+QyGFJcFFPr4jLp7rJgEDbi3fOKEsn6Qh3/DdOqts=; b=LAHYZFgjVukqW+YTMT2jHLj6hWrUl3lQf5zMTrwvFl/yrti93i3I9ce1d/zo7Bk4kH Cwy6HJm5cSTYb4EVfYWOfEn5RZh/HhkBQVHE5DyjTD2YAkCNhNTZ65lHKT0hfQzmtgtM Ni0KQv4te+HDrVKxaUULlUNFveXHN3l1myApdoIJ4PlKRck4SX619uoQrUEp13W6kX5I jd/WuUA2UXMc00/TAI1MdwvvLJVyNfgZqSk8gQZt7WWw16aAPHVfwcQL5e3h68ePKMZm f4KNP8fYSt29UtvhPpxMbY4kguNMFoH+e43h8JrZj1hL2NGUX/QP7lfoqkgAgsnsocVm gVYQ== X-Forwarded-Encrypted: i=1; AJvYcCV37Fcbwhm2cagjsMpfVot6XZx6moVogWDBLN53HPaU//cCiCXEmKP6QY7ya7kfKuqEwvw6LjH7Ww==@kvack.org X-Gm-Message-State: AOJu0Yw4adRe/b0iMEj/yBltwzS8NQkDVAxRJiTzGqFbr8ny3ak3APoy gOyeWb+Ro2rKIHACiS8ToYU86CtEUDZe0242H6V3wwZF5wbGGjCv X-Gm-Gg: ASbGncvcOOmQ1q1LtcvQnU1mQaYKfwVJFwFewD2O6gWrQAcvSpUBr6Bh9puQ66tZFIP waVui5gqn1VDkrZvWWTVkgBfJFIsfCA5ZlsiRY8i2wsodcfYg4+apPyuJcIuf5rx5M00jOp6f71 /xhI7jYz7m8VPks1m+DrbHu4fPhCdEWA3+UwrMIerG02dxmlypS4mg+YSqQ261QPR85EjbO1fPk SNtjJI7JDveNgLJ7aN5S8UmCnM6b370nKv9Oe4ilN+8tr066IZQNw== X-Google-Smtp-Source: AGHT+IEaNPPwv2jgmflcyY86b/WEwel2W1k8equ5GjnUoSfoOqjiDz0DmZNagpICpan2+ywzoOgFQw== X-Received: by 2002:a05:620a:45a7:b0:7b6:df08:367a with SMTP id af79cd13be357-7bcd970960amr5194628485a.23.1737038686573; Thu, 16 Jan 2025 06:44:46 -0800 (PST) Received: from localhost ([2a03:2880:20ff:6::]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7be61487360sm10397985a.57.2025.01.16.06.44.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2025 06:44:46 -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: [v1 2/2] mm/damon: introduce DAMOS filter type hugepage Date: Thu, 16 Jan 2025 14:44:36 +0000 Message-ID: <20250116144436.3947318-2-usamaarif642@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250116144436.3947318-1-usamaarif642@gmail.com> References: <20250116144436.3947318-1-usamaarif642@gmail.com> MIME-Version: 1.0 X-Stat-Signature: p5ebt6s85omyha7tbhnre89ej9cr66hj X-Rspamd-Queue-Id: 8A66C16001E X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1737038687-84753 X-HE-Meta: U2FsdGVkX18R2trUO1O2CB9qpmbA48xL4f1xSXPEYkwyR+FQCuSkNEnwJg8SdASqikmqxgBl8GPQteuOJIS+El0pF5ZoeQLpjxAvw2tsjx6li52Xgizg/aVQnoDF1t1yOEKhOAaQ9WF9LpGK5FMwemXPU2xJtQzprSVpgVVAVRvgbvSSbVMdUepV5+EvX/CUBF3tV7QwUAjj7U1OmADNh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LoiR6msWzDRxB4v+usuQN4NiiZ9hNtHAH8F9ZMsQ3q1Zgv4bTqHBAOEHLdn0aUtHpL+L+/Y5OcHd8UtckX+Ctg4g1dEn8NVy+um9thc/aHwARjOLoYuejA+rnHT7QgM7E98I5Uo/5kAkFjB7vR1/k= X-Bogosity: Ham, tests=bogofilter, spamicity=0.004480, 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 hotest memory regions 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 --- include/linux/damon.h | 2 ++ mm/damon/paddr.c | 3 +++ mm/damon/sysfs-schemes.c | 1 + 3 files changed, 6 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..a9e69179d45c 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -222,6 +222,9 @@ static bool damos_pa_filter_match(struct damos_filter *filter, if (matched) damon_folio_mkold(folio); break; + case DAMOS_FILTER_TYPE_HUGEPAGE: + matched = folio_size(folio) == HPAGE_PMD_SIZE; + break; 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", };