From patchwork Mon Jan 9 21:33:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13094367 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 C3130C5479D for ; Mon, 9 Jan 2023 21:33:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EC2C8E0006; Mon, 9 Jan 2023 16:33:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 29C078E0001; Mon, 9 Jan 2023 16:33:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EF648E0006; Mon, 9 Jan 2023 16:33:51 -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 040B08E0001 for ; Mon, 9 Jan 2023 16:33:51 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id CC27A140EB4 for ; Mon, 9 Jan 2023 21:33:50 +0000 (UTC) X-FDA: 80336563020.18.082A86C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id 56981140009 for ; Mon, 9 Jan 2023 21:33:49 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fd3GB+4W; spf=pass (imf23.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673300029; 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:in-reply-to:references:references:dkim-signature; bh=//qlcWifAoXDaS+oMk7paqPQ3a5SATg+IvT3pkm/jOs=; b=e5u8kO5J6MULRXyPrZMScbFaKf0jejy+btDfU8kZ6fdX9m1Ko5F35z2hMiIAmoE6RevJLp jYNQJQAtAjVJvJ9nuGjGaJmO/YBIckE5XR0sWUJWoN9VGUrJhcF4tJhNYjDK+XYqDOa0vB FILmKFFOXZJbcmjKtk5AzQt4S0fWV+U= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fd3GB+4W; spf=pass (imf23.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673300029; a=rsa-sha256; cv=none; b=clQGWv3Ud1ej3ZmWUtTmrJKwjIoywq+zC+lUIhDMznLfiar2RVzCb9tdFkBw6EhrWf3Vp1 yQWoa2NMPls8aXVfNHGUMC3+p88dybtLBsGyMOBGYf3U5Xc1eKoev6rMDBqwEM/kcPIRWt SCoZfjSZYR2DJ0YcIIqFB0hVwDyAq3U= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4CD526141C; Mon, 9 Jan 2023 21:33:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B924C433F0; Mon, 9 Jan 2023 21:33:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673300027; bh=2JLtN8tos+I5Ax4pubeTviifV4tMrNZA936nz1vxxcQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fd3GB+4WIT0xNztbpTNCwyNhCDV1rv7z8xAvq8Nxtl4ZCZTIvE8E4qoOJzAuF0qd/ nIxdhKCEKTchIOd2lY5DKaGN1EQ2wSTEJ06oObeHGBiYuXf6fLkGhJMvJSkZFf1kW7 bZikE7oMHL1fDZ3JidDlVkhMdB74EQ6VYGwvUxzaf6y0k1s+VxA4Nh40zWa/Oyx1ge hu7GJpQg5axP/a+/wogIcX0QmJqqRY06JBBZGPDszg/dSU8/V2wLG1VaU9PaWOwra7 NCsnLXECcDn2l7pAQ8RjpT/y0DEKzI5Sy9zMRvtfOpqm+BHHDySbyTDUHvsaNj77LC 6vtqs4qizzHYQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/6] mm/damon/vaddr: record appropriate folio size when the access is not found Date: Mon, 9 Jan 2023 21:33:32 +0000 Message-Id: <20230109213335.62525-4-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230109213335.62525-1-sj@kernel.org> References: <20230109213335.62525-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 56981140009 X-Rspam-User: X-Stat-Signature: 3jpxnhau8ze59qp19z7s1oxt4gkfun87 X-HE-Tag: 1673300029-155586 X-HE-Meta: U2FsdGVkX19qYzwROIMZuaK5hq0c5C3jLF5MPNmQWzhDVt1YGxxFNZqlIGUt535Q8AZzCV/5sm2nZPS+C6qTeQHVcS3oPgYAvhMF+HfvahwSe49/WDTBKLv4dOCNJbbjFO7w2UU2vqalD9Npt8zLGRvxRzPaHzUB/F3yxcFve5wVGRx3KjtrOpt7beKrRT3uQdihqwF/jDUIXqGskxj2hzThDOH/Vs//GeZwKivgbdCOguhAqRxhYTABcO/9UjLgjED+EKQiuDCBOE9tuzngJCFUDJJnuj36SLtuV1bBX57zBfvRuu2HA4NzKwl6+SP7i6zu2X1C1oR7rKxmOWPQDc10SGw1fqA8zSuiTGEDPvKnH0Z/yWiMrbsb7BSNzl3fIXgN9NCeVT6NxedDOMMYTrJF/0Nslrf/0zKZ1XkZTP1PbonAsHUQ4EIyikl9bHOe5VwkpLRGM8vsq6zqI7+B6lAoTVg+KX8zSEQgiJMFBkMEMcruOt+ghFoqxJDbwqOBvEkR2Vm/LypdCsPYlQ0j4ukPLoueDWyAsF85beu6clskNAY+n38tfbtiJB3yN1YHqaxlwBzeTx7uhXEVm7MsIqKpE1qw9igVn7P/V102IJi5KhikdMQrGF0E0vmxAInjuCZh3yez1eOCLa1+7w4xHZWwfZwAXhmwgMunYO9GbVy3IiuJmljfhTvS+KNgKUZaaALN9Svfr9n5PBMZFxEPjn/51Ym6j256rKqClWUXtq64xOsAHnITCXT5lUgORr6Dtpyi3f1ya2UIVBS64EX2hcfsVKl46vCNgdItwKzUkX4iwoLQv9cnOKolGhXNAs9jCiQA7Gt34uV7lE/4V7MdayqElhI4n+ONRHfSPmbLH7/v5lzGWfUad6kmsQXcXYX6hsym6Be+xDNHKgHla1Q8u2Y2+c+QAS1o2E9IsynQ9WMgSvIRMZ3RHUpV7eeysL0X3Lfs7rEjEo/q07tVQdQ 8NZ//Uri mcLHpd9N5wHoKIudgBYITRKLMkWlb1FpHnRz4vBq/JhWNmqIgzK3ivUEaNun9oa5VX1NJ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: DAMON virtual address spaces monitoring operations set doesn't set folio size of the access checked address if access is not found. It could result in unnecessary and inefficient repeated check. Appropriately set the size regardless of access check result. Signed-off-by: SeongJae Park --- mm/damon/vaddr.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index c7b192006fe6..1fec16d7263e 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -452,10 +452,9 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr, goto huge_out; if (pmd_young(*pmd) || !folio_test_idle(folio) || mmu_notifier_test_young(walk->mm, - addr)) { - *priv->folio_sz = HPAGE_PMD_SIZE; + addr)) priv->young = true; - } + *priv->folio_sz = HPAGE_PMD_SIZE; folio_put(folio); huge_out: spin_unlock(ptl); @@ -474,10 +473,9 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr, if (!folio) goto out; if (pte_young(*pte) || !folio_test_idle(folio) || - mmu_notifier_test_young(walk->mm, addr)) { - *priv->folio_sz = folio_size(folio); + mmu_notifier_test_young(walk->mm, addr)) priv->young = true; - } + *priv->folio_sz = folio_size(folio); folio_put(folio); out: pte_unmap_unlock(pte, ptl); @@ -504,10 +502,9 @@ static int damon_young_hugetlb_entry(pte_t *pte, unsigned long hmask, folio_get(folio); if (pte_young(entry) || !folio_test_idle(folio) || - mmu_notifier_test_young(walk->mm, addr)) { - *priv->folio_sz = huge_page_size(h); + mmu_notifier_test_young(walk->mm, addr)) priv->young = true; - } + *priv->folio_sz = huge_page_size(h); folio_put(folio);