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);