Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2789157rwd; Fri, 2 Jun 2023 15:00:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5T1w1ukUbqt6Hd8XUduGEto2av7QCF1bd2CLXh/lNfVXIRDK/Pudoq+LjZU1xX8Dt/TLgu X-Received: by 2002:a05:6358:4317:b0:127:c478:6418 with SMTP id r23-20020a056358431700b00127c4786418mr9579906rwc.30.1685743255201; Fri, 02 Jun 2023 15:00:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685743255; cv=none; d=google.com; s=arc-20160816; b=YeHMZl3XuxwRyOGlgpDaaINN5fdlPWETmn7/599+/YukxZ+4xXhYbA0ylaTmCWIxb/ FpdlCMjHFtRgKyl3aeI8AOO/SPR/O/7PpBW+/uM2vgBIEDhXh7MQezasb5sG/TrM1FA0 U4kCQJN2rqhvfDhJc4MvvbZuwbcf8HIt5r1U2H4l02fSg/rj9ZF8OGuX9UseTh/czO5b POBHGGcpotElI1Prlpj1CZh86sDwKg0AGs8IclntIRiKTzPfBQeVIY2fBRWieOZzX3Ot +hT/RmFvnpWQnmuO36GrGmvgvce1RFIc/Bt2RgQUsChNjnYgYvav/TCSxobK4UYERuuG Nc/w== 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=rsQmmpFXe4OtG+wko/YD2llGj7Jd2Kn8PQboFyQHwK0=; b=yd4fvwk0ktaJE/6zUlYSiSCD5ahe5PloytZVfMWZXNq0qZ8/C6loteYC87BHsOMy/6 93d9e0ZKHytuCBI+2NRtG1VmiI5ga5KbIVcGWGR/m4CYGZAU8sv/YtCziSLHL4JdyobW hYC4RyKJppVmlDs0vstNN/hTkAWkw+biQuFUjNNxXFWROyLqdMyPO7Pgmr+jvD5Lbvry H49C2JqFbJ126n4AaPQfTruNYT3rwH1PnGHeBJrZTmUSOjanz01jg3VASL3D4a/07HCe kJyPyS6xelPyvLGoAu3t7g/XLlTKHqQ9o6cvQHahKISQ7N5Cu2GPZX7RrjZGluDKTATs PWGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ts7sAD57; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v29-20020a63b95d000000b0051b9a1e823csi1556828pgo.137.2023.06.02.15.00.42; Fri, 02 Jun 2023 15:00:55 -0700 (PDT) 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=ts7sAD57; 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 S236128AbjFBVy6 (ORCPT + 99 others); Fri, 2 Jun 2023 17:54:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236256AbjFBVyx (ORCPT ); Fri, 2 Jun 2023 17:54:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFB7E1A5 for ; Fri, 2 Jun 2023 14:54:52 -0700 (PDT) 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 539F961EF8 for ; Fri, 2 Jun 2023 21:54:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A68E5C4339B; Fri, 2 Jun 2023 21:54:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685742891; bh=gCs8lv7QzbHnoWxQdwszcYV+QYvUCCO1/czQtJohcFU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ts7sAD57zMu7vNGEpDIixZvsiCJOZ80qVMELZ4CaImTurenx2HP26g13kCMI3Bffm 3UiQfr0XQOhK3uV65sXsNKniBv0Vq7wHx/6q3alx5oUnt97bTptVmunhDmaIp5AT10 JayT2NdmOxOq2na3VbRxvvCYCAsW+cPy+p+Ks1iIFHud46AI2g5vvwwcwrvAlj0CNi YYkAzjXX67DfIU7VbUAP7EXfYc4vKM7qx6EzIsqM5uMM33aytyfGTP5WsK1/xlOX/d P/oaziCvx8iFLG+gxDhd2tm4HrV/dbkLrcGUhoYm4IVNrvgLB288ByElyoY/Ch9SJT hyCq98DJScunQ== From: SeongJae Park To: Ryan Roberts Cc: Andrew Morton , SeongJae Park , Christoph Hellwig , "Matthew Wilcox (Oracle)" , "Kirill A. Shutemov" , Lorenzo Stoakes , Uladzislau Rezki , Zi Yan , Yu Zhao , Mike Rapoport , linux-kernel@vger.kernel.org, linux-mm@kvack.org, damon@lists.linux.dev Subject: Re: [PATCH v3 3/4] mm/damon/ops-common: Refactor to use {pte|pmd}p_clear_young_notify() Date: Fri, 2 Jun 2023 21:54:49 +0000 Message-Id: <20230602215449.107659-1-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230602092949.545577-4-ryan.roberts@arm.com> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.3 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,T_SCC_BODY_TEXT_LINE 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 Hi Ryan, On Fri, 2 Jun 2023 10:29:48 +0100 Ryan Roberts wrote: > With the fix in place to atomically test and clear young on ptes and > pmds, simplify the code to handle the clearing for both the primary mmu > and the mmu notifier with a single API call. > > Signed-off-by: Ryan Roberts Reviewed-by: SeongJae Park Thanks, SJ > --- > mm/damon/ops-common.c | 22 ++-------------------- > 1 file changed, 2 insertions(+), 20 deletions(-) > > diff --git a/mm/damon/ops-common.c b/mm/damon/ops-common.c > index acc264b97903..d4ab81229136 100644 > --- a/mm/damon/ops-common.c > +++ b/mm/damon/ops-common.c > @@ -39,21 +39,12 @@ struct folio *damon_get_folio(unsigned long pfn) > > void damon_ptep_mkold(pte_t *pte, struct vm_area_struct *vma, unsigned long addr) > { > - bool referenced = false; > struct folio *folio = damon_get_folio(pte_pfn(*pte)); > > if (!folio) > return; > > - if (ptep_test_and_clear_young(vma, addr, pte)) > - referenced = true; > - > -#ifdef CONFIG_MMU_NOTIFIER > - if (mmu_notifier_clear_young(vma->vm_mm, addr, addr + PAGE_SIZE)) > - referenced = true; > -#endif /* CONFIG_MMU_NOTIFIER */ > - > - if (referenced) > + if (ptep_clear_young_notify(vma, addr, pte)) > folio_set_young(folio); > > folio_set_idle(folio); > @@ -63,21 +54,12 @@ void damon_ptep_mkold(pte_t *pte, struct vm_area_struct *vma, unsigned long addr > void damon_pmdp_mkold(pmd_t *pmd, struct vm_area_struct *vma, unsigned long addr) > { > #ifdef CONFIG_TRANSPARENT_HUGEPAGE > - bool referenced = false; > struct folio *folio = damon_get_folio(pmd_pfn(*pmd)); > > if (!folio) > return; > > - if (pmdp_test_and_clear_young(vma, addr, pmd)) > - referenced = true; > - > -#ifdef CONFIG_MMU_NOTIFIER > - if (mmu_notifier_clear_young(vma->vm_mm, addr, addr + HPAGE_PMD_SIZE)) > - referenced = true; > -#endif /* CONFIG_MMU_NOTIFIER */ > - > - if (referenced) > + if (pmdp_clear_young_notify(vma, addr, pmd)) > folio_set_young(folio); > > folio_set_idle(folio); > -- > 2.25.1 > >