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: 41171 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2392348wrt; Mon, 9 Jan 2023 13:35:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXuLrabBjNyYB4mTNfmhU18fevPdCsgGFeDi6pJKE4/dAbecY8w1r2IKWkCz5EUrC1nLinh0 X-Received: by 2002:a17:907:a643:b0:7c1:1752:da68 with SMTP id vu3-20020a170907a64300b007c11752da68mr49910621ejc.76.1673300129825; Mon, 09 Jan 2023 13:35:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673300129; cv=none; d=google.com; s=arc-20160816; b=xCscqjlDqHKDXm+GNnQX2jtZtH1TBo7KOqjN9b66m8aJcE7c8KIXbHSDLYIplCjvPi kB4TGmgqH25GRdwbKobg6zbKOp14Zms+pp51XNleRuzk4AXRVuLLL93AKdvp5At39efg wKQwV1pPETLKgU/Uehg2GtXwV9RkHDTMN5paJ3cfmG5+yn4FmLIvSL36Y1NUlUTcLiwX pYA8y+VsdrPcqJwO7pPxCWPK8pObMyXJahjMEkbZHNRwwfzx3M9OVEG36ctAUQMZWbLQ 7bHT844PR3dgALLDx9cZ6nwLhGGYdXxeBjKlVzYztfBykM5IPqUqFhvwCyd96ARRoYKF KRBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=//qlcWifAoXDaS+oMk7paqPQ3a5SATg+IvT3pkm/jOs=; b=xmUn5RLV4T41Nk7cMpOQkw/Rt/f9rKW9HXJk7Zeqsm69y/dCbwUAoYY6lc70hxNmQE tJu5j8FMy9E7GYjGFuku6NlwDLdRuB+XuL5LxlTt/UOTmdejEUU7wIUiTfpW0UbYNlgR hdWJHwH9nCe7E7CaC9WRAtYsMDcZ7gnk0sOeWiObuHqjurlp8uaNno6XoNTgPabF3KOJ vEiFPhKjETZVpR63li+eBTBZ4bUSkpvXwLtrOwI8SJYmkpBu6yEUOimZAzukVuJNzBaR g63EB3qRC8JQ17L2jU0v9vb22Gj+kEiB7Djo3FP8cQOIIQPgJVwByU1DxXOpCH7f3oSB zbIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fd3GB+4W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hq7-20020a1709073f0700b007ae832c0b69si10013186ejc.512.2023.01.09.13.35.04; Mon, 09 Jan 2023 13:35:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fd3GB+4W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237772AbjAIVeW (ORCPT + 99 others); Mon, 9 Jan 2023 16:34:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235529AbjAIVdw (ORCPT ); Mon, 9 Jan 2023 16:33:52 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 215F410CE for ; Mon, 9 Jan 2023 13:33:50 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id D6ECBB80FE3 for ; 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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754582357042565050?= X-GMAIL-MSGID: =?utf-8?q?1754582357042565050?= 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);