Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1964258rwd; Fri, 2 Jun 2023 02:49:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ntlPX8Q/R+h/OcjHzrTinOCR9HLIR3VI6Y1KpTzIgSH/Eg53EIt2F0MsD9COYYis8HEry X-Received: by 2002:a05:6358:3421:b0:125:9a49:d879 with SMTP id h33-20020a056358342100b001259a49d879mr11164340rwd.20.1685699397767; Fri, 02 Jun 2023 02:49:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685699397; cv=none; d=google.com; s=arc-20160816; b=MUSzvY/mOLvEyS6bjam1+wkCjfw+8+N/8eMBDKzsA9+dzERBVADC3bhsVPlwhJmEo6 V0YVJnZq5WvTAAnEWdrslf7tIgJYi47HlQ9bPbFYHOBNrbRDnQaRqTSDbiZ+wFVdlTCO kroXRMizr02TcNE5WAlmjJE1BkSpoq/fA/D4iWcVUTYWKdTUD/5SVJfpnrmZhfjYLfEw 0DVtwRp/dcUPpQbZN8i+gKe8DL3ml9uXbZaqpVb1403r8xkOr91g7E8/jGLO3YbHKqTF 8NiAGTIUC2uKpzCut1M9AsMgDX3vmrvRYdHecUmrk94+uIaSG9m6TvpsfODss1agPE6j p8gg== 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; bh=VKRNb17rmx4CrscdLqv68+7Swb2k3gEeCrh0aTpL6lk=; b=twP7lxIa9CBqxmU3Ajf38WCyzaaeABiRyeE2ymBTm1OTkeabIY4UcdYJfbovTng1Ff GZLphBWEHV3xvCrnweFWCbiqT6R0UpVbrHL5twC9SFassjNQ2E1HG4EhLQHDCZYtXZKi Tn82CU9Tm4aZrcxVNqAl9f87V0guizYY0YHELZb9yTHsriUlxtZ6uz4V/ZitNmmXxqpu /LLW8tu5v7CTgVgi2UCcjMbLmhWspNzzcevE58yu14wWArHl/bePJ8mzlClpQW42zuPM c4OFe9vfF51yPCSkwwGNhXMHvlk+jNCQOkk/JCaDWy92cDLfovtsnJo6U2QU6JKJgNF3 Acmg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bm18-20020a656e92000000b005418b187c59si706057pgb.633.2023.06.02.02.49.46; Fri, 02 Jun 2023 02:49:57 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235080AbjFBJbW (ORCPT + 99 others); Fri, 2 Jun 2023 05:31:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234695AbjFBJal (ORCPT ); Fri, 2 Jun 2023 05:30:41 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CD8B910F3 for ; Fri, 2 Jun 2023 02:30:09 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0D42D176A; Fri, 2 Jun 2023 02:30:55 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D73083F7BD; Fri, 2 Jun 2023 02:30:07 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , SeongJae Park , Christoph Hellwig Cc: Ryan Roberts , "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: [PATCH v3 3/4] mm/damon/ops-common: Refactor to use {pte|pmd}p_clear_young_notify() Date: Fri, 2 Jun 2023 10:29:48 +0100 Message-Id: <20230602092949.545577-4-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230602092949.545577-1-ryan.roberts@arm.com> References: <20230602092949.545577-1-ryan.roberts@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,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 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 --- 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