From patchwork Mon Jan 9 21:33:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 41168 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2392220wrt; Mon, 9 Jan 2023 13:35:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXvp7MuKauuDLYySc/99jHqUYFYsg+hw3TZDVlo0TwizFehBY3NEiCKjgtPgq3zdvJG+AXrX X-Received: by 2002:a17:903:2647:b0:192:e32e:7472 with SMTP id je7-20020a170903264700b00192e32e7472mr20442424plb.64.1673300110795; Mon, 09 Jan 2023 13:35:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673300110; cv=none; d=google.com; s=arc-20160816; b=uLnEAymmRb2WfpfCcXZISJQ3JbfBzoJ0cq0voJS0mfPLha2qqwHrM2XxFzjbtGEsJs jIICgFEDZs6n+HjztqcRO5KdVwhNJZ5Pl6J2K/9NQWoIIeNgUrHX5yhgqQGFanGxeibB xP1axsNsf/3dE9IE9JFegtFOU1GZE+2IAiuudNbh4Jg2BADmCi9TfjqX/gDF8VTTMaJb o7g5EvFSDMRhAgaeXunI4L54ZO7ryTW3soSYAWP/PKUkwf4lX3a36fH/R+34Kmtek9AM Gja6/T8PfbHq1Xf6B+rma533PNp/hY8CN04uETD36teCu/ipsL9O7mhTYz9G03H5DPwd 1bpg== 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=o7gimKyLLJw9A6V//eR1L6zJuoDP3fS3F+7uvlkamiA=; b=fvoXKnEM8x6DHu15mtDmcQfA15wrhTbD1Mc+bXw2DjWPNLWGgW0/aoYUNMqPrjQRTR vBn1TJFRpaitooHihH9eoFHOXSp/FVnM8qVhl8EBEPSxrKmiQL3oiwHN25RiEWwu8czK vr38ElgP/X7GMs+dfB83jG10Nlu+5WqzqG2BFDKgBkqQB2+Vy9KjV5MNlTb9ns4Yfu3h yHnA/ndC55EHHqiWAe/naNlW5UAj0qDXsk5jx/ol06CrPqRFb/BAXRS2Jr5k72FZudID TF7uOSKXorml4I18O430Ko00J5Mx/fe2yco885eGcjTBchqOrPoGjuGTLzJKpBGPA4VI /vcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iI0kvQY1; 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 t18-20020a170902b21200b00174eef66680si9055549plr.120.2023.01.09.13.34.57; Mon, 09 Jan 2023 13:35:10 -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=iI0kvQY1; 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 S237453AbjAIVeC (ORCPT + 99 others); Mon, 9 Jan 2023 16:34:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235023AbjAIVdv (ORCPT ); Mon, 9 Jan 2023 16:33:51 -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 0D005D67 for ; Mon, 9 Jan 2023 13:33:48 -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 B2064B80D50 for ; Mon, 9 Jan 2023 21:33:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F18BDC433F1; Mon, 9 Jan 2023 21:33:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673300026; bh=8zePhCnELAS1QJzxrjEP75j3wPseZorjwjhVisLqJLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iI0kvQY14VYnZdX+nOXPYkE3NYQ684HNWh99BZ3HGSB44hAC1XoKXeyhI00O79K6w baT02EhqlaaajEh5EOvLemJQ/HQvCXaL6sXFaCAqhiR5TnV4vHFxqkYJsxwHwsiUbL RRxzElNee++MXz9VfFsYQ8CR47R+UgOqES3k8M4JMiDSkcE+7rSG6/r4dpWWLTprUL DXXWH5WGqOtB3POAMRJ/7HmiW0iPUezsF6QKlwQVYwZcYHaD93ZvADEpOP5D6eBoO1 rDzq6VTp6zIC3RvJ28SRNRMF5F3miHkJE18KNJl7SuBX8OaT9jC4tF4OzqsUfIcI9O vCW3K43C/4img== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] mm/damon/vaddr: rename 'damon_young_walk_private->page_sz' to 'folio_sz' Date: Mon, 9 Jan 2023 21:33:30 +0000 Message-Id: <20230109213335.62525-2-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?1754582336836963857?= X-GMAIL-MSGID: =?utf-8?q?1754582336836963857?= DAMON's virtual address space monitoring operations set is using folio now. Rename 'damon_pa_access_chk_result->page_sz' to reflect the fact. Signed-off-by: SeongJae Park --- mm/damon/vaddr.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index 9d92c5eb3a1f..d6cb1fca1769 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -422,7 +422,8 @@ static void damon_va_prepare_access_checks(struct damon_ctx *ctx) } struct damon_young_walk_private { - unsigned long *page_sz; + /* size of the folio for the access checked virtual memory address */ + unsigned long *folio_sz; bool young; }; @@ -452,7 +453,7 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr, if (pmd_young(*pmd) || !folio_test_idle(folio) || mmu_notifier_test_young(walk->mm, addr)) { - *priv->page_sz = HPAGE_PMD_SIZE; + *priv->folio_sz = HPAGE_PMD_SIZE; priv->young = true; } folio_put(folio); @@ -474,7 +475,7 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr, goto out; if (pte_young(*pte) || !folio_test_idle(folio) || mmu_notifier_test_young(walk->mm, addr)) { - *priv->page_sz = PAGE_SIZE; + *priv->folio_sz = PAGE_SIZE; priv->young = true; } folio_put(folio); @@ -504,7 +505,7 @@ static int damon_young_hugetlb_entry(pte_t *pte, unsigned long hmask, if (pte_young(entry) || !folio_test_idle(folio) || mmu_notifier_test_young(walk->mm, addr)) { - *priv->page_sz = huge_page_size(h); + *priv->folio_sz = huge_page_size(h); priv->young = true; } @@ -524,10 +525,10 @@ static const struct mm_walk_ops damon_young_ops = { }; static bool damon_va_young(struct mm_struct *mm, unsigned long addr, - unsigned long *page_sz) + unsigned long *folio_sz) { struct damon_young_walk_private arg = { - .page_sz = page_sz, + .folio_sz = folio_sz, .young = false, }; @@ -547,18 +548,18 @@ static void __damon_va_check_access(struct mm_struct *mm, struct damon_region *r, bool same_target) { static unsigned long last_addr; - static unsigned long last_page_sz = PAGE_SIZE; + static unsigned long last_folio_sz = PAGE_SIZE; static bool last_accessed; /* If the region is in the last checked page, reuse the result */ - if (same_target && (ALIGN_DOWN(last_addr, last_page_sz) == - ALIGN_DOWN(r->sampling_addr, last_page_sz))) { + if (same_target && (ALIGN_DOWN(last_addr, last_folio_sz) == + ALIGN_DOWN(r->sampling_addr, last_folio_sz))) { if (last_accessed) r->nr_accesses++; return; } - last_accessed = damon_va_young(mm, r->sampling_addr, &last_page_sz); + last_accessed = damon_va_young(mm, r->sampling_addr, &last_folio_sz); if (last_accessed) r->nr_accesses++; From patchwork Mon Jan 9 21:33:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 41169 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2392221wrt; Mon, 9 Jan 2023 13:35:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXs2xjEKNy4VQ0oz/3feTBhfbC1SphXOmGTetKUKt5B9xnyEMteNuQwleQry4bSgZtFz4c3x X-Received: by 2002:a17:902:9b90:b0:192:8cd1:5e79 with SMTP id y16-20020a1709029b9000b001928cd15e79mr46986544plp.41.1673300110924; Mon, 09 Jan 2023 13:35:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673300110; cv=none; d=google.com; s=arc-20160816; b=Im9HP1baDBz+2HQrDG3aj1IECihNL/Eq24OMpSITK02LTckH4jIs1TM9Q0cjiPlkCU jT1GAYO3quBLl+fy02zz6Z8ebNCZjP4JA09Lo+nJzVAIQwG8zgmuk4HMkmGlvS6G4QNr fmqwMKGaKbvComLVmIrZIwtxl2o8MpEIfrM1zC932jOiWs2t/Ro9jf5l9FR+DrL+IgCE Kk0Stf5/JYWiwQ4CpyL/KGFt1IYWZ3GIf7yNXHcIntV+NvDd1gBP+detEGHYKsZxzC5U FdSms/ZlOfAHAwpm2lSgOFn5cs0BEoujSA6ki5+iNOLOmyEVCxKXP5ejQcgjbSPPT8Wn vldg== 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=MGUu9cOvc1HuAi4ImywWxr6yj31JHAQ/zFkqT9+UlA4=; b=tTGAJoVWKW/jFgYFyKJDt8MVJjiqzxaEIFmi4LQISfiHeOqWdgRs3b7oEzC3eiU2a3 3ULzjDtUut0ypU/FFSa+LMRu+VUl8Y/Ht4xrwdaS4vGr7KSSWSiMhR5bskmi0ZoEvZ0+ iVqm6rNip+KQd/iR/3Y9XsXy/Yuvnfc/tYO9nmnYqRg1rErgCV48Sai1I1e8HLjWZODK vwvKwB1nTg+vEh2YpL9ShlYftq2QtKNiTs15vtWDS9yqvoOcnB9MxFN3Ufq0kvfIgMVb s2McB6P/lqt0NmcK7Lg1DGn9vtBBIbMfKjcSNBxcEI3eLs5dum50z5zu1Eg3WzXL6qyW dOhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jRDHdTCz; 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 u7-20020a17090341c700b00193353fb086si2983936ple.383.2023.01.09.13.34.57; Mon, 09 Jan 2023 13:35:10 -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=jRDHdTCz; 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 S234992AbjAIVdz (ORCPT + 99 others); Mon, 9 Jan 2023 16:33:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231220AbjAIVdv (ORCPT ); Mon, 9 Jan 2023 16:33:51 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 257E1DD0 for ; Mon, 9 Jan 2023 13:33:48 -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 dfw.source.kernel.org (Postfix) with ESMTPS id AB40D6140C for ; Mon, 9 Jan 2023 21:33:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95EB2C43392; Mon, 9 Jan 2023 21:33:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673300026; bh=S9qpLQ77vZLkX0Fi/FnXthnFg4be2LJbk3/kO/j1qTI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jRDHdTCz4fpg4pSg+atnuiWHPSzA34OuiyN0y4hpkdydvPbEXc5zQNd2rmXYtLG3R 3qnhCqhu0s5e6yY71KGAHWgxIuU/eKP9xpeghcLzTaHoAiaNpS1AV6Ixh21DKD0orM uSzwGl7Itp0qOi0SAjUWVJgo6gllE3SdJ2Tfo53cV7OsSDL+n310BVjzmPDIcm0XMO p8wPGPwVOXBEM6ivtFSJskAo1VQNvggSIM9GNleCP4uRobOuMxdi9GBMueeRyyR1Rr BEaar4UIe6j/wPq/l0eaX6+bLZBckUQuURSfg9NUCEN8MXUiJ4raIz5tcuKTpBcfsR BUGNJ394IFnhg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] mm/damon/vaddr: support folio of neither HPAGE_PMD_SIZE nor PAGE_SIZE Date: Mon, 9 Jan 2023 21:33:31 +0000 Message-Id: <20230109213335.62525-3-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?1754582337524775890?= X-GMAIL-MSGID: =?utf-8?q?1754582337524775890?= DAMON virtual address space monitoring operations set treats folios having non-HPAGE_PMD_SIZE size as having PAGE_SIZE size. Use the exact size of the folio. Signed-off-by: SeongJae Park --- mm/damon/vaddr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index d6cb1fca1769..c7b192006fe6 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -475,7 +475,7 @@ static int damon_young_pmd_entry(pmd_t *pmd, unsigned long addr, goto out; if (pte_young(*pte) || !folio_test_idle(folio) || mmu_notifier_test_young(walk->mm, addr)) { - *priv->folio_sz = PAGE_SIZE; + *priv->folio_sz = folio_size(folio); priv->young = true; } folio_put(folio); 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); From patchwork Mon Jan 9 21:33:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 41166 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2392154wrt; Mon, 9 Jan 2023 13:35:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXuhcJtKk9phXLQbm+cjLQIKBQiDGrd/Ux1lgfhuZXnlSSCns4zBcT8hPZmtefuQxGkn9auH X-Received: by 2002:a17:902:9888:b0:192:ce7e:93b7 with SMTP id s8-20020a170902988800b00192ce7e93b7mr28633691plp.49.1673300099892; Mon, 09 Jan 2023 13:34:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673300099; cv=none; d=google.com; s=arc-20160816; b=gHJyqDmFv1sfJNMHRvQtKQwYCrhyREZ3Ty3JIQ6emR1k5odXj0hrYrz002iiyQ8CHw ROX+3SiqZ9kaJylhet+WeJNHNlK9e2SBdXZQHUIToxuyQ8yRpf6cAQcqUBSf6JDU2tbS +9OhwFxfro2pb8q+O/Wr00odjPy+Kfn0ws8Sgv0e+CYUINjru7OUkUY4vQtRnfMzQXs1 LcLWFh/GLs/N5L3nTGxPpvHX7dwtPTdD3+aqjq2SeOSUooCmpWbaVakX4v4MUiVM3OK4 G6UxrseB6vyUiklORFYJ79Kpv8PRcSwxhPnMsiVyHLKKuysl1UVf4/N5aDlgmVZpjZSL pcrw== 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=N0iiOREKjAiI6kLAk02vCa4VECye4nwxU8RPiP9HoGQ=; b=wnDWqm2K5nRtnukVpGCJyqsqHTtvzpnrz3Scc2+mu/QIIkOPa9xwNeeKzstugTihYW 9HXlM1K+G7CEcoNTLUMoIphYEuwOW8oIbnRbEwMgZsUTi6DzpDKRRn3BgydGX//vE4zS QukoByS/MmU+k+37xaJFkeb3uvbawBujlgCjmrNbE13AI4mzly2I7AFgcplKM2LwUdac mOahCm177H3hjoadP0izCaxET8k8Ga3r1zh5Ce6N6s0C+1hsA7bgWodF11OJyY23lo/c 1Kjd8XmvF+mvNcm2bgiNmlyWBpXs1V6dUngEcXCR2I2CQdl32WucHE/Zh30aop/HhIwP JGkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CkayMLf4; 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 x1-20020a170902b40100b00179cf094dccsi8932737plr.526.2023.01.09.13.34.46; Mon, 09 Jan 2023 13:34:59 -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=CkayMLf4; 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 S230341AbjAIVdx (ORCPT + 99 others); Mon, 9 Jan 2023 16:33:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbjAIVdt (ORCPT ); Mon, 9 Jan 2023 16:33:49 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8CA3E2E for ; Mon, 9 Jan 2023 13:33:48 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 6599E61414 for ; Mon, 9 Jan 2023 21:33:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3813C433F2; 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=1673300028; bh=CFEeibNvvYAHsooB/GZxZzGLeG1gUo5uWWp85VJYZOI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CkayMLf4IhwPE5yfzgDGZfwtnsgWnvEkfeAXD5O25NOF846s/PGNbZIBST+o9XJfu YTzFb7YVkNVDpiaxedFNYwJ5bGBdaSZlzL0dJifZseNQaZ9fVWqVQmyDdHhV+vKXja HASc/1EM1sgLdlweKLpxJWF0NKPshrKc8IjLEngSJK+LCP2VWTSJxuduVYw99ul/ij NzCuJU0/oB5GhgMqwXkr0/VEu2XMLuavwrhnAr0bYcTbsg9oa3xyQuy7Jd7rGl+BIG b/Aw174M8zeE6Hi9q4YH1GA+PwK7bX+GynKfII38j5rrg51mvQfOX0XcBjXRTshqIX 7XmdlB/xwMVHg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] mm/damon/paddr: rename 'damon_pa_access_chk_result->page_sz' to 'folio_sz' Date: Mon, 9 Jan 2023 21:33:33 +0000 Message-Id: <20230109213335.62525-5-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?1754582325374633191?= X-GMAIL-MSGID: =?utf-8?q?1754582325374633191?= DAMON's physical address space monitoring operations set is using folio now. Rename 'damon_pa_access_chk_result->page_sz' to reflect the fact. Signed-off-by: SeongJae Park --- mm/damon/paddr.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 99d4c357ef2b..65c1e0f91535 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -80,7 +80,8 @@ static void damon_pa_prepare_access_checks(struct damon_ctx *ctx) } struct damon_pa_access_chk_result { - unsigned long page_sz; + /* size of the folio for the access checked physical memory address */ + unsigned long folio_sz; bool accessed; }; @@ -91,7 +92,7 @@ static bool __damon_pa_young(struct folio *folio, struct vm_area_struct *vma, DEFINE_FOLIO_VMA_WALK(pvmw, folio, vma, addr, 0); result->accessed = false; - result->page_sz = PAGE_SIZE; + result->folio_sz = PAGE_SIZE; while (page_vma_mapped_walk(&pvmw)) { addr = pvmw.address; if (pvmw.pte) { @@ -103,7 +104,7 @@ static bool __damon_pa_young(struct folio *folio, struct vm_area_struct *vma, result->accessed = pmd_young(*pvmw.pmd) || !folio_test_idle(folio) || mmu_notifier_test_young(vma->vm_mm, addr); - result->page_sz = HPAGE_PMD_SIZE; + result->folio_sz = HPAGE_PMD_SIZE; #else WARN_ON_ONCE(1); #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ @@ -118,11 +119,11 @@ static bool __damon_pa_young(struct folio *folio, struct vm_area_struct *vma, return !result->accessed; } -static bool damon_pa_young(unsigned long paddr, unsigned long *page_sz) +static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) { struct folio *folio = damon_get_folio(PHYS_PFN(paddr)); struct damon_pa_access_chk_result result = { - .page_sz = PAGE_SIZE, + .folio_sz = PAGE_SIZE, .accessed = false, }; struct rmap_walk_control rwc = { @@ -157,25 +158,25 @@ static bool damon_pa_young(unsigned long paddr, unsigned long *page_sz) folio_put(folio); out: - *page_sz = result.page_sz; + *folio_sz = result.folio_sz; return result.accessed; } static void __damon_pa_check_access(struct damon_region *r) { static unsigned long last_addr; - static unsigned long last_page_sz = PAGE_SIZE; + static unsigned long last_folio_sz = PAGE_SIZE; static bool last_accessed; /* If the region is in the last checked page, reuse the result */ - if (ALIGN_DOWN(last_addr, last_page_sz) == - ALIGN_DOWN(r->sampling_addr, last_page_sz)) { + if (ALIGN_DOWN(last_addr, last_folio_sz) == + ALIGN_DOWN(r->sampling_addr, last_folio_sz)) { if (last_accessed) r->nr_accesses++; return; } - last_accessed = damon_pa_young(r->sampling_addr, &last_page_sz); + last_accessed = damon_pa_young(r->sampling_addr, &last_folio_sz); if (last_accessed) r->nr_accesses++; From patchwork Mon Jan 9 21:33:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 41170 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2392249wrt; Mon, 9 Jan 2023 13:35:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXudp+hXCt5kc6GiJgzsB5UcCermhdxlRtL7Hll+VTcOzOoXNyB2ISYZiiTIpS7M4XJrjQWo X-Received: by 2002:a05:6a20:7d9b:b0:b5:9d81:4171 with SMTP id v27-20020a056a207d9b00b000b59d814171mr12031465pzj.24.1673300114832; Mon, 09 Jan 2023 13:35:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673300114; cv=none; d=google.com; s=arc-20160816; b=uyzOZnoc0RswDoEdru5JmLZ4wDItiqsC+BjwxIhxiQX9uc7+yP9JtOyCNxY5sPvHL4 vCVCkqHtAqgg6n1fVTAp7E2RF5vZiafnTUf0fc2zjxHpITpcg0CGTukfnM0e6Rxqxq0j EtVOaN1t5dkGIYAUAUscCr73Xl/tYTP1/XrrxCeJGu+7gead6W1NfozI8bHMk/03DgcY 5LVDrsfC25yaDY5JH22YY4MHNu1uVzrjz8oV+WNxk9A7WE5rVAL3+VR2FRe0FCWb8zgx v6Vw/qFkJJPUWo7chsq4Mp38NiLZhKDnzyANxVg732yBDSOTHA7cVBtKqw1zhNxq9aYt 25hQ== 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=Gp9jxI98TdehfVr+BQlKXHYvyV+gppw6/OlU3NW3LPk=; b=ti/lrmWRsgn04eRA0/7nPZQph4ZgsDs6NXfJyqvuoMpDVWIk2VjnsYbOc0ZamozsDd yB5GjI32U4PIJCVNOgDExZgh8j5WTPMyC6EpzWAAVyOfUcucPfLsySx2h472Q8agq5cs AIJmNGbDUfA74B1N6lFrBAQRvO2xidFMGHcPu7pIXoRKYa25A+2AyX0F0hFqmNpDX16+ eLhbghysPO0rqLgashMIjYtoyW3SGVc080rv8arFLgJI/7f5sBWdgAqHkCsuHq8jmVPb nyEw2U+exT2u3dodP7XEKMUUA6DgGdZjxWMK1DMg9W3MeNClGChO2G7E7g5dcuf2RqAX Ipcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q25whl2K; 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 g27-20020a63521b000000b00491ad1ca2f2si9816369pgb.835.2023.01.09.13.35.01; Mon, 09 Jan 2023 13:35:14 -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=Q25whl2K; 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 S237729AbjAIVeQ (ORCPT + 99 others); Mon, 9 Jan 2023 16:34:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235477AbjAIVdw (ORCPT ); Mon, 9 Jan 2023 16:33:52 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A9A6F59 for ; Mon, 9 Jan 2023 13:33:49 -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 dfw.source.kernel.org (Postfix) with ESMTPS id F1AFB6141D for ; Mon, 9 Jan 2023 21:33:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 673A3C433D2; Mon, 9 Jan 2023 21:33:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673300028; bh=SYYr0BTjmOo642m5NR3wSprE6Rj/MW96ULPD1Kbq3N4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q25whl2K6ubCd0mSRCAhV2abNV6arYJzypS9C6dgW1BHriuFbw8yu2UNtObHkGoo5 gFh4wNew0WdzD5BDISr8G2JEaOWrmiWYJgLs/1Aqt8Nz50eVSW7uGSGy/N+9aXgEi4 6zW0OwgSDQ7zGALkkf3vCQx5muQaAmlvxH4ry1T+cYP8sS7SXLaxvgSoXehUok9YU0 UQsVBtCxtIJUszstXt735cqzC5YQJtPCO95WNtN0kf2zXGXXExj0kBoBkwAYFQPXDs AjPDe8OGaczVaic7Pcma+e9e/jShrhySjFSw1EUGzgUl5hJ7PZczmNBCXnoEIgfmFe 2+MH0CMWBrBUQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] mm/damon/paddr: remove folio_sz field from damon_pa_access_chk_result Date: Mon, 9 Jan 2023 21:33:34 +0000 Message-Id: <20230109213335.62525-6-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?1754582340961049159?= X-GMAIL-MSGID: =?utf-8?q?1754582340961049159?= DAMON physical address space monitoring operations set gets and saves size of the folio for a given physical address inside rmap walks, but it can be directly caluclated outside of the walks. Remove the 'folio_sz' field from 'damon_pa_access_chk_result struct' and calculate the size directly from outside of the walks. Signed-off-by: SeongJae Park --- mm/damon/paddr.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index 65c1e0f91535..b51606519bbd 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -80,8 +80,6 @@ static void damon_pa_prepare_access_checks(struct damon_ctx *ctx) } struct damon_pa_access_chk_result { - /* size of the folio for the access checked physical memory address */ - unsigned long folio_sz; bool accessed; }; @@ -92,7 +90,6 @@ static bool __damon_pa_young(struct folio *folio, struct vm_area_struct *vma, DEFINE_FOLIO_VMA_WALK(pvmw, folio, vma, addr, 0); result->accessed = false; - result->folio_sz = PAGE_SIZE; while (page_vma_mapped_walk(&pvmw)) { addr = pvmw.address; if (pvmw.pte) { @@ -104,7 +101,6 @@ static bool __damon_pa_young(struct folio *folio, struct vm_area_struct *vma, result->accessed = pmd_young(*pvmw.pmd) || !folio_test_idle(folio) || mmu_notifier_test_young(vma->vm_mm, addr); - result->folio_sz = HPAGE_PMD_SIZE; #else WARN_ON_ONCE(1); #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ @@ -123,7 +119,6 @@ static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) { struct folio *folio = damon_get_folio(PHYS_PFN(paddr)); struct damon_pa_access_chk_result result = { - .folio_sz = PAGE_SIZE, .accessed = false, }; struct rmap_walk_control rwc = { @@ -158,7 +153,7 @@ static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) folio_put(folio); out: - *folio_sz = result.folio_sz; + *folio_sz = folio_size(folio); return result.accessed; } From patchwork Mon Jan 9 21:33:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 41172 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2392464wrt; Mon, 9 Jan 2023 13:35:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXuSu/EoQw4RjxXBiCsCPFpUbt4B6Y6W7qR10906NFBuw2JZ+l7dFVzTC37LHH/R9kiYtZ8Y X-Received: by 2002:a17:907:c58c:b0:82c:3642:79b5 with SMTP id tr12-20020a170907c58c00b0082c364279b5mr57465024ejc.58.1673300151307; Mon, 09 Jan 2023 13:35:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673300151; cv=none; d=google.com; s=arc-20160816; b=dyyWEwEiwlqf8JlSlrGYTTb5Mab+8/4yiWJpmOe2eXdpr4c8rXzTyj9jgbknAHCa64 3mDZOs+qdcrv0LKLOawW+S6Vo+fIZxm4kUGn4aCVCWgjRREpbe0GCFX4rc9be8nELIiI my4mRggWjL+wYBAT7xLzEJ+v3DsBDqxJIgqHvc4RuXIWwHBYxpAu1m5lOmzZRhbv5W2x BUqwa2NB1RXHQY4mzYZt/HeQeOPQHYROFXk6X63MHTGqxb2B7/nN8fbrexG38QM+JLbE +TsafwJlcsXoTQA0NZTwVN0ozLI1UOgJIfhgnWAqr/PpOfOGtYBVCnS16zDXpR4X7Mvc /X8Q== 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=5UmaNQkviwl/rYu/RYe5B9vXm/PCU7e36YbIXUEXTFM=; b=KiMegcgd1DKIRAkMYq4SdyGXFTbTQcMt/M9RqoBq3zIJEXc/QEzD100x7NT/V8KAM2 KZbnIOdpzZjtOTjWUYa9/6+QK0xbur/rwNust6+I2pNo5U3/7PQqoYHBghdGtzOhojvb SL2Z8//VdL00xaCJ5oaTL+4Rf9Hs8rheafAWcrKmFjrMtwmojLM0xKoXndfsCNiUqRM7 mC4qQU3nS+GX58PNdvthZIfj8b8ivCnU3WZ7Qpwd1s+I0jp4A3lzxClEsj5RFlXWdjUo SqO7EeoOSA2M5qtup3ln2U++Hpp+T/awQic41ZxmN8ZdIUrmuWauOf7H86uOaQxxFcVq /BrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BAy7p9Oo; 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 hb8-20020a170907160800b0084d459379a1si4326118ejc.381.2023.01.09.13.35.27; Mon, 09 Jan 2023 13:35:51 -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=BAy7p9Oo; 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 S237616AbjAIVe0 (ORCPT + 99 others); Mon, 9 Jan 2023 16:34:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235360AbjAIVdx (ORCPT ); Mon, 9 Jan 2023 16:33:53 -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 E8645F07 for ; Mon, 9 Jan 2023 13:33:51 -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 A51B2B80FEA for ; Mon, 9 Jan 2023 21:33:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2A46C433EF; Mon, 9 Jan 2023 21:33:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673300029; bh=yyLlHJ6cCbnE9uJxOcQpPH/RrlJ6RvTE2YIE61/Wx0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BAy7p9Oo4rnxI8GLrmgFxMW8bg3bc0a6rhboNr/pDoTXUJa/1WuxNkcfwiaTal5Qj cJeU1YtDugehNEgYy10tXVIP9704KyIcYqgJB1XPyih1XgdwGsY3yB1jlftCqwGFkh b1BCNiOtBjwFb+W6p7BgsdAx/mZCc5js7lQHXm714dhd8gRHbQG2IVCI8+78jzBRAO mzwvSfk9tmeqxo4dZ2KZ0aYfYzBBBs2Rem1exKOEDzeCUHJ0A5WeVud90fEjHQDPdT wDwFO+awaMRvsIHUIyMf7D6mnO+NeNg60nJs3ADcB6MYMFW9ilQdwN4vbeyLBvwOkd B/ImoIfbYK7iA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] mm/damon/paddr: remove damon_pa_access_chk_result struct Date: Mon, 9 Jan 2023 21:33:35 +0000 Message-Id: <20230109213335.62525-7-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?1754582379244161422?= X-GMAIL-MSGID: =?utf-8?q?1754582379244161422?= 'damon_pa_access_chk_result' struct contains only one field. Use a variable instead. Signed-off-by: SeongJae Park --- mm/damon/paddr.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c index b51606519bbd..b4df9b9bcc0a 100644 --- a/mm/damon/paddr.c +++ b/mm/damon/paddr.c @@ -79,50 +79,44 @@ static void damon_pa_prepare_access_checks(struct damon_ctx *ctx) } } -struct damon_pa_access_chk_result { - bool accessed; -}; - static bool __damon_pa_young(struct folio *folio, struct vm_area_struct *vma, unsigned long addr, void *arg) { - struct damon_pa_access_chk_result *result = arg; + bool *accessed = arg; DEFINE_FOLIO_VMA_WALK(pvmw, folio, vma, addr, 0); - result->accessed = false; + *accessed = false; while (page_vma_mapped_walk(&pvmw)) { addr = pvmw.address; if (pvmw.pte) { - result->accessed = pte_young(*pvmw.pte) || + *accessed = pte_young(*pvmw.pte) || !folio_test_idle(folio) || mmu_notifier_test_young(vma->vm_mm, addr); } else { #ifdef CONFIG_TRANSPARENT_HUGEPAGE - result->accessed = pmd_young(*pvmw.pmd) || + *accessed = pmd_young(*pvmw.pmd) || !folio_test_idle(folio) || mmu_notifier_test_young(vma->vm_mm, addr); #else WARN_ON_ONCE(1); #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ } - if (result->accessed) { + if (*accessed) { page_vma_mapped_walk_done(&pvmw); break; } } /* If accessed, stop walking */ - return !result->accessed; + return *accessed == false; } static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) { struct folio *folio = damon_get_folio(PHYS_PFN(paddr)); - struct damon_pa_access_chk_result result = { - .accessed = false, - }; + bool accessed = false; struct rmap_walk_control rwc = { - .arg = &result, + .arg = &accessed, .rmap_one = __damon_pa_young, .anon_lock = folio_lock_anon_vma_read, }; @@ -133,9 +127,9 @@ static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) if (!folio_mapped(folio) || !folio_raw_mapping(folio)) { if (folio_test_idle(folio)) - result.accessed = false; + accessed = false; else - result.accessed = true; + accessed = true; folio_put(folio); goto out; } @@ -154,7 +148,7 @@ static bool damon_pa_young(unsigned long paddr, unsigned long *folio_sz) out: *folio_sz = folio_size(folio); - return result.accessed; + return accessed; } static void __damon_pa_check_access(struct damon_region *r)