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