From patchwork Mon Jan 13 19:07:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usama Arif X-Patchwork-Id: 13937934 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 381F5C02180 for ; Mon, 13 Jan 2025 19:07:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C55326B009F; Mon, 13 Jan 2025 14:07:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C04E96B00A1; Mon, 13 Jan 2025 14:07:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACD3E6B00A4; Mon, 13 Jan 2025 14:07:44 -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 8CEED6B009F for ; Mon, 13 Jan 2025 14:07:44 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1A4241402D5 for ; Mon, 13 Jan 2025 19:07:44 +0000 (UTC) X-FDA: 83003362848.15.33E7953 Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) by imf26.hostedemail.com (Postfix) with ESMTP id 496BF140009 for ; Mon, 13 Jan 2025 19:07:42 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=kVh7+4Ux; spf=pass (imf26.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.219.51 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=1736795262; a=rsa-sha256; cv=none; b=lgmYtJZAy6tGzSvsXyR8tMIfijNeIwUwTXj2xlkzYwpBL/ltL8EvdjhhUUYEj0+tWo75Lv vgIgoW82ybLU4odxGaWFSABO+snuEq+n1L2Nlmeh2LpBFuJhUkld5l9hJ3YDNzsYSIR0by b9rAEaSre/BfS+crzozmF6e0jpFZEB8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=kVh7+4Ux; spf=pass (imf26.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.219.51 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=1736795262; 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=fN2r+oYRm8VKwOWlsegJ1ciPAZUowW4WF0J8VLzLcrc=; b=6d5HOdcDNHYHuVknk0QY2Nwc2gipRAENGtTVcttSF7mwwitbt7StXjEeko+tLYTXzjmb0g gcpB0Yr6sQnv5+OJJszLDRkbby7GPlQUa4EhFpYcqOFJBufAHDBH0Pn+d5UksbIjnxTjG/ M6GOtnmDW5EO7tq5W2sjLjBWX96pv8Y= Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-6dd5c544813so46751506d6.1 for ; Mon, 13 Jan 2025 11:07:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736795261; x=1737400061; 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=fN2r+oYRm8VKwOWlsegJ1ciPAZUowW4WF0J8VLzLcrc=; b=kVh7+4Ux/jS6exvnt6NNwt2LT5bUabKlGuBOt01Wa2qUrU0om6J75+4oV+Bs9uolBb Lkz9AC3vR9LKdHc9zndWtYK74gpeADnCwsjiyT8JFlMt7PgZzhNDMwKU3hAH0gfM45Er PXgqhXN8W+Ugg6Jj5B4AhKz0qCrlryIqY4LP1SUGl4oO7dSaOxWLD5Oy6vyIFSLolnUc kJCT5ncxLzwnTzWdToJmfM3zDtC3Nf5BUit4lXEwGfGs2ntMZmJTmuWNihL3iataGlU1 0Z3l0Uq+RqR0CqmfzK/lDdml6NN2Jx1eWJov4+yCpyEcmw22d6NhDmbOjIhfRw6MDhj0 AF/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736795261; x=1737400061; 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=fN2r+oYRm8VKwOWlsegJ1ciPAZUowW4WF0J8VLzLcrc=; b=HIb8WriS6XNJT3F2Tbh27wCp3DGCdPphW6rkqVXI7fdR/xmwhEtNpAdkdgbjoDc2fA evn12NGQCIUSyLVwMIscaXxQwYLmTCUrwZPq3pHHuphs+g4INuSBIVxwzGPIs0VaFDBD xfRtF1pyyr5MAQiCPv1eOvHZCsrfwt45GO5oWhMyepCf7OEo9AOO/DrFsorTA6U3tecl VHbRROB5AsR6/VO6GBMFjdhQpAkiqhfl6FOMQJrvJAmIJROalMgyBZd1v+iQuDuDY2Or yC2YwQ7mhXslenw/57X3mluSgwBwJmZ0Ab8HUfpi3Ls8aORwVfSOsZPUPwehJgfcy9LC 9iMw== X-Forwarded-Encrypted: i=1; AJvYcCWs3kVSCvvKCa4wX7bVvqAbKhW0OWURaPcRBC2H3jB6Z1BUW7NGo7DHPJImfaq37H/oaERax8lfyQ==@kvack.org X-Gm-Message-State: AOJu0YyxXH9aMOsE9b20kaMgM7jHwfXyClXM1xe7Hqx/aiFvJmFdNogx 0TzRI/AAUgiLVtevl7F54n1LqW/tNeCLJ3db4+9slo0XlNvJZExy1KQeN1qM X-Gm-Gg: ASbGncuIIsc6NgOpu9EbeEmCfK9rL3/CQg4ylTOzA5/Khp08uubnQhJyQ1TtSYte9TK gpSeHp3P+PEh+IdvhgYaWLFFoHLIGv9FA5UeRsM0bI+l/TldBU4Pd6Bh9Ua67WPTRby1LLapfj+ O1D6bhW8b6Hzt/GK1xEVoT83atRbVEAXYYrlkIahdlfJFs7YCL4bpEvtcBC2URuKlJjxplyGLMe 37sLE72Rh9bw6/mTr8dZdLB6/OEACWq4sLDWtqpS5y8reaLedh2W9M= X-Google-Smtp-Source: AGHT+IERpp9QriM2xmQpFOewoGObdi8kvSThCUOCEi6hwWeezVQIzsdAyC4Pmdq9xZ2RVFNymG+AVA== X-Received: by 2002:a05:6214:3289:b0:6d8:8f81:e2e3 with SMTP id 6a1803df08f44-6df9b1cf331mr369453146d6.8.1736795261383; Mon, 13 Jan 2025 11:07:41 -0800 (PST) Received: from localhost ([2a03:2880:20ff:41::]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6dfade892cfsm44246616d6.106.2025.01.13.11.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 11:07:41 -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: [v2] mm/damon/paddr: increment pa_stat damon address range by folio size Date: Mon, 13 Jan 2025 19:07:38 +0000 Message-ID: <20250113190738.1156381-1-usamaarif642@gmail.com> X-Mailer: git-send-email 2.43.5 MIME-Version: 1.0 X-Rspamd-Queue-Id: 496BF140009 X-Stat-Signature: wx71gmosdacjzitk19htppr65ay7fg7n X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1736795262-809074 X-HE-Meta: U2FsdGVkX19ayYS20uGqUYjjbyS1+myqWY8+PwbcWXXXjfjhXfv47NfvoyE9AFMIuaFhzKJdSX8zDGcWfxMRQA2seflawqczAWdpCkBHMKFAESQklXUpHzMtu8vHk6iTz8X3/583N+j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vn2jgsT4Rkm0slFVCB/h9ZY5o5AKihBNbUilGdsw0yjNC51kznxQVUb/Vebqt5Nn35d+0A3xZD0kGpbg1c3GCxOj+dqqAErynM4Qw6tdxQR+zNF5WvLbzXcfPFJMqIy9BWbatbXSfTKeU/P0rD7mcULqFMw45ZuehI27stUKYPwu1fN8LrOYZR45MIva5UVvsYTI6OBpiUotlVAsfpEpHKmUvpj6mONkCEM9/sAA6q+Q= X-Bogosity: Ham, tests=bogofilter, spamicity=0.271308, 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 avoid going through all the pages in a folio. For folio_size > PAGE_SIZE, damon_get_folio will return NULL for tail pages, so the for loop in those instances will be a nop. Have a more efficient loop by just incrementing the address by folio_size. Signed-off-by: Usama Arif Reviewed-by: SeongJae Park --- v1 -> v2 (SJ Park): - Update commit message to change the description as an optimization instead of a fix. - handle case when damon_get_folio returns NULL. --- mm/damon/paddr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 6b4397de4199..bd8cfe10121b 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -504,17 +504,21 @@ static unsigned long damon_pa_stat(struct damon_region *r, struct damos *s, if (!damon_pa_scheme_has_filter(s)) return 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; else *sz_filter_passed += folio_size(folio); put_folio: + addr += folio_size(folio); folio_put(folio); } return 0;