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