From patchwork Mon Jan 13 18:03:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usama Arif X-Patchwork-Id: 13937880 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 153A6C02180 for ; Mon, 13 Jan 2025 18:03:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 98AE56B00A9; Mon, 13 Jan 2025 13:03:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 913E26B00AA; Mon, 13 Jan 2025 13:03:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 78D596B00AB; Mon, 13 Jan 2025 13:03:58 -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 576BF6B00A9 for ; Mon, 13 Jan 2025 13:03:58 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 138E2AE601 for ; Mon, 13 Jan 2025 18:03:58 +0000 (UTC) X-FDA: 83003202156.09.31C4EB1 Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) by imf26.hostedemail.com (Postfix) with ESMTP id 48BCA14000E for ; Mon, 13 Jan 2025 18:03:56 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=hkJVyLud; spf=pass (imf26.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.160.175 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=1736791436; 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=aSerPn266Pb3Ey93gnhZWD46Qo6xjfiDgChx6SZ4WyA=; b=V4uepAh3UOEllltSgzKv9uFKMHHBqFTteUl22z7bp9WCJOZ+MCalWX1jilYd08OtJj2REk SsGnX114UcO+7vP07Ww6xh7iQSLP43EEE7Uj7Uj1dPvqFZ/h0/dm1Q4qGSYKO0p0Q2j+mI chrfCmH8liXj8n/2mqhiIAl/8U6M+qY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736791436; a=rsa-sha256; cv=none; b=nbgsn47h4IoIixZL5DAW4byl/tOf/ofbOrU5eeitgHsXlicADsyxfYjWji41T1CYxVxWs8 7GG1SgHB6whNR4qsZNRhQfv6DnlVIOXL1XeoxN3huD1TSSHqPKVxGZP0DMHlU5urPnrYHZ d1LrEjg51AyfJhH5pN1Wf525L2cMVoA= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=hkJVyLud; spf=pass (imf26.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.160.175 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-467838e75ffso58449691cf.3 for ; Mon, 13 Jan 2025 10:03:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736791435; x=1737396235; 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=aSerPn266Pb3Ey93gnhZWD46Qo6xjfiDgChx6SZ4WyA=; b=hkJVyLudKfVNDo9ZbEHBk/wkMvPoJVU5BJtU2RmD8Sf3J2wgV29DhqNmcsP3I+/UqD fJIRJNZhiaDIccWCR9sh0MN+Xzbet1X0Ni6iFNpu2fsHYxv8uU81Io7fTnNWD4y6MrPv T8pgDsLQ8Y9StM5eEUe91EE3GXp4TxNzJyWGxliSk01NFf7zot9/oHf9rISuKCMqWiGK 8YadmXkz4FYmHwILI/SqACf5zzsXDBAJZxfsX/mnPybScs4pHjcxuqXMtMpNXMBeXfXA 3XQzjp+I3pZZIyujHEu7o9iJVazCs3RneJG1qqXAoapnnG/m/C4oIGmri71I6HWI9v/Z cGww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736791435; x=1737396235; 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=aSerPn266Pb3Ey93gnhZWD46Qo6xjfiDgChx6SZ4WyA=; b=Ha268rCKXbOfP0o1pEfQjiOrPzH1wvkz/O+cJOeq5mXJdIZjpLXd3lNCwHv91w1Esd XbP4wejyyyeeQQ4ybhMdb31hcJm4i0eixyIOWaIbrGvRfo691DR46vaJkO4IRKLUkp2f jl8l5n1rHinDdx2LSvCXGC7pUidZppUK9IteUS/wV2EVRaGSs8Y6vDEFUs+wn+O3g4Hq DQNhQN617jsw/ceRo7k5pZfRyO2HOUHcbGx9ZNi7XuGf2yl0+ADexUJVR/cKyiAXaNpU 5EH8/lb362GdL74KP9BtzAuR+J5KZ6hCdkPisC5l9QjPATwiATcdR1eXyq1QJgzRqNdp VZSA== X-Forwarded-Encrypted: i=1; AJvYcCUI4TBPywFNZWeb/ZtDTLN5pa6CEoiNHdoB8XeiPQpaVRZSqs18Bkd2at9q+BYYwI2ac3WhdU4Jqw==@kvack.org X-Gm-Message-State: AOJu0YzCCenzjJYLO7LZvuSKxpxUX6YOrL1bFdW6+Krh3Ebo4h1tdeJu pamOQsMLYNUMI0tS8Gi18GVBABvQ3TTEDGnM/e+npc5iCWydqg0m X-Gm-Gg: ASbGncviwPLJb40dR1jHriI263heqLNcdADEvkdenmU9C+/rq03CocRJlchva9jvE0W p+8g827eNrZNut8ak8IR2uJDUzEuDh176dRnvrDEGV9o0u0c69pre5yzjVon3meQrBkDnqxWe4A +vAm/VI81HMU72dQ6GclVbiexixu+I+GoIpH5v69pqk1N6QgTIa2B4H30o8ZdclsNh3GUXCo09w QcGuRdlome1uVJdm+LpYVs1JGDwSdEuHX5SEKuv1jXGAggd/uH/yDE= X-Google-Smtp-Source: AGHT+IEAvK+Z7LvnMbeSsClwbqmr2qInUEGlPcAKR2aK81e8XpgPsiIvLB4dQLAMPG5WhZXcmW8r/Q== X-Received: by 2002:a05:622a:4c0c:b0:46c:74a2:3492 with SMTP id d75a77b69052e-46c74a236demr354624961cf.41.1736791435224; Mon, 13 Jan 2025 10:03:55 -0800 (PST) Received: from localhost ([2a03:2880:20ff:4f::]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46c873cddfesm43432561cf.57.2025.01.13.10.03.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 10:03:54 -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] mm/damon: increment pa_stat damon address range by folio size Date: Mon, 13 Jan 2025 18:03:40 +0000 Message-ID: <20250113180340.805474-1-usamaarif642@gmail.com> X-Mailer: git-send-email 2.43.5 MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 48BCA14000E X-Stat-Signature: 6jmdfexx47iswamnyrzy8j7m5bzctqum X-Rspam-User: X-HE-Tag: 1736791436-900742 X-HE-Meta: U2FsdGVkX18YWsIy7prSUmanlRFLah9s3Xi9jBeuMrHqNX/PdbUHVR+XQVg/JtbVeB/tMmJxu+6gXXEwvmJyd1Q8DEF3q67/o9NxNc9LKEUxA7ur9QDvwWDM5uIRjl5mdhVp894uSkklEGCcNrsozbe5+JHeiB06g77Y02EBke7yWXsJCUZ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msnDifeso0ik3yKWOebmqL+qSac89GhUc+3Jc9HPYsdmr7AfzTm2Tf8qM/JgS7co2c7nGDAaQuuMpP+XxQmrhSBOVFGxXOmKlaDYYJBqbHW8Myq41jviUciWWhk17tmoQ05NV1UsHARjaAeGHHv3hQvnMNWSL7MP3W0PQ2W6V+j424wfi5CjQ6ULdHw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.445067, 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 take into account for folios with size > 1 page. Iterating at PAGE_SIZE increment would increment sz_filter_passed multiple times for the same folio by folio_size, providing incorrect stats. Hence go through the folio only once. Fixes: 6347f3385dd0 ("mm/damon/paddr: report filter-passed bytes back for DAMOS_STAT action") Signed-off-by: Usama Arif --- mm/damon/paddr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 6b4397de4199..cc789a97c6f5 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -504,7 +504,8 @@ 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) @@ -515,6 +516,7 @@ static unsigned long damon_pa_stat(struct damon_region *r, struct damos *s, else *sz_filter_passed += folio_size(folio); put_folio: + addr += folio_size(folio); folio_put(folio); } return 0;