From patchwork Mon Jan 20 10:16:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usama Arif X-Patchwork-Id: 13944992 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 94BC9C02182 for ; Mon, 20 Jan 2025 10:17:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D436D6B0082; Mon, 20 Jan 2025 05:17:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CF3646B0083; Mon, 20 Jan 2025 05:17:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BBAA46B0085; Mon, 20 Jan 2025 05:17:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9BB406B0082 for ; Mon, 20 Jan 2025 05:17:02 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 20190162B25 for ; Mon, 20 Jan 2025 10:17:02 +0000 (UTC) X-FDA: 83027427084.05.461AD18 Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) by imf16.hostedemail.com (Postfix) with ESMTP id 57578180007 for ; Mon, 20 Jan 2025 10:17:00 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=grvpl37w; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf16.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.219.54 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737368220; a=rsa-sha256; cv=none; b=c85YlD7Wb3EwIR+sNbXXgKtAzYAHQOnIdolUR/EkNheilMPB3OWgjCsc6k+kiuJm6nXzbp 4be7+70cp8WyfG7/VweCxhdVgFm/ZdvvX0GjBZpZo/7cxy5b8I3SKLRvmAfeveeR672rRc wVAlAgnlYTNrHV/065iCODibj9X2e/8= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=grvpl37w; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf16.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.219.54 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=1737368220; 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=fTwIlgrFboLO8llVcA+r2QVYArEV9SS2nGHbvQ6CuebPwm6QFCwre4QR4ZVmKZxyxVSkcJ Gh6C+GRHnwoxaF0AUwPr6wdL9NDd+urr1ZVHJpQQJrzIMp2nZuLz7NKAx8yovwH7RKj6mK MgOLkpE29BSLworgyimQz9mMcFLKlbo= Received: by mail-qv1-f54.google.com with SMTP id 6a1803df08f44-6dd0d09215aso40785006d6.2 for ; Mon, 20 Jan 2025 02:17:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737368219; x=1737973019; 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=grvpl37wF7Vjy9cmRlXEUfj4z260xv2QNbv/qkZY/G6ROvpV27p6O9gI2ZZtCsuYYY HFq/w/k//aG/B5t6jpYtwo+G31VGE2cVc0dorWci26N9po8qWe4GTUBaCBrMaCAdDBL6 p1mRqVd44XRhY2FTyCFU3/TJdqXnvhXBnTP8or/WNLNDYFsWZmmcaX2zM9Cxex2U+COu abBkT8XKSdjccXThOtEXcJEUC6s3eBypOco1IiVXVsK7VGkhDfKa9lRX21DXUoBJTf3p NbyflOWPvhsCIem45JmV3RjunxJLP6N+KHfiKiiC419d5ATXw35sx7g9YWlE75NFYGac 5DZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737368219; x=1737973019; 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=GvTi7Ols6OuICj3lZbYeYQY1piYlI/ZZB0whmU/TntlDX0s/U1LFeWl2Pe8Tn43Q0c VhodSaDxxczU22YYqRc1/Im9HjOvy2/a0b1Qr1EmRf9Wn/vuvxSMlgtlB4A76anV0IgM nb9hzF42+ZzparPxIuaKeJb/ANpU2QrdscoMz6U9rGx/inuiEngHrsgsOwFzQ6NRce1b JzT/ouINiHK9gLC99DX1A/TtRzmhaSf8KQEx91b0fYgTiY8RqkJQSp76MdzClMLAAYfm mGg5dJHOhnqbN7FzTIA++v8Hl35kQdX4dBOB3PjODoPU4zcvYxphLUow22+2aIKIBkCX BItg== X-Forwarded-Encrypted: i=1; AJvYcCV6LZEPjw2fShqaY8mruN9jpCdK1edtxQbJHIA8Yir+J77c/oi8/3Cke87j5kH/F+oj+uAQeSUhPw==@kvack.org X-Gm-Message-State: AOJu0YxXd7PELfRjJHlijdSzHqsUAsjUL2tTKTcEvak+T0AADXzFf5h7 ymbcROMCP7K7NEyQABZjk+bNiKlsFxItw7KNJoQeTvUxwkTO8RJE7Af8BA== X-Gm-Gg: ASbGncswPcff8bM4X7kU99zB/4/f5Us+X6s6PMRJdQ7AkkERbJMjZsUBglZqD0roo3a D8Hov1MSWJ/ivsSBctLOchpXlkSc8Y9uKqugpEshPCFirWmx4Vu5yFDMvx6suFB8ZyoJlvKszg4 WejY7HxqUofwhMMOBXUr13P7AwSk5RmZr9/qGQ4i/ppwDyuOEtsL1EaHoTx/mfaVvPtt7rKMty0 kjVnYYS/oLbKo+gW9Zw/GVqsEhzutQ2Aw2xfl9Bn6v8PuUvfwieVJG+CtbNMwUiS6k= X-Google-Smtp-Source: AGHT+IHWsCDp+rMCIvKd//LQXmnou5+5ZLPiZihGfKVZrHa5E6zB/aee8bOWFYwEgMOAnN9n+FXCwA== X-Received: by 2002:a05:6214:27e2:b0:6d1:9e72:596a with SMTP id 6a1803df08f44-6e1b21d8673mr217503466d6.37.1737368219411; Mon, 20 Jan 2025 02:16:59 -0800 (PST) Received: from localhost ([2a03:2880:20ff:5::]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6e1afcf4ef9sm39778626d6.111.2025.01.20.02.16.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2025 02:16:58 -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 1/2] mm/damon: have damon_get_folio return folio even for tail pages Date: Mon, 20 Jan 2025 10:16:49 +0000 Message-ID: <20250120101650.3761306-1-usamaarif642@gmail.com> X-Mailer: git-send-email 2.43.5 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 57578180007 X-Rspamd-Server: rspam10 X-Stat-Signature: 33qep6384encpmnusruncad17k7m197t X-HE-Tag: 1737368220-608116 X-HE-Meta: U2FsdGVkX1+X6cIs/u/z8O7ft9GXtBD1WsZkv4wLutuCWWigFCtLiYZGztNjCUOgmkRin0O/H+3TRV8xDVQvxx1BypuyTVkjvF8+NZdEBoS2n6PrnTjF6QnC0VGKhJWA4jeksS4W5z0HNdgEG/2s2E9uPcmZLdasZ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vx7D42BLAwzusUTE7UqE+hQ5Ox2TmN0GuY436ArfRhvVVqQGtZctFcQvpKTCymL34tRK3ovkFMgXi5yKqOJ4IVyh5sdv2LU8yABm/dMqiI9WXCQtw+8x8snUXrPMcN6qzX7zffBh7t+UGxkWjo+FoLbjhVcu0QpN2rdRIgpA4mQTHeYFeRPOTGzrfvH8Werlii2Tn3DmDJE77L0vfPpZGptK0CMAiKvbWHVh+2dEJDysDL6vqub49tpRS4kYEou1f3piOWjKjZv9awU5b8zHgrwhFFzjMIpaY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.047583, 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 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+HVXh1ij0zYLSZem7HhnDp92HWBex1qzKwKlO8au0ahMR4vaAohcCcVLqEXwuh5Q/Sj9rRkgLokis6z+Sh9NQwQHCJb9dOJ6dW1oJK4xJDyW9I8FPmFkpXrrVJTHKHpoxNk7WL1aGAYKvY8iyiukiU6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Ck3dTP6tQLvs3cOHgFEhS/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", };