From patchwork Fri Jul 21 09:40:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yin Fengwei X-Patchwork-Id: 13321708 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 00372C0015E for ; Fri, 21 Jul 2023 09:41:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0ACE02801AC; Fri, 21 Jul 2023 05:41:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 05C952801A0; Fri, 21 Jul 2023 05:41:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E400C2801AC; Fri, 21 Jul 2023 05:41:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D3EF72801A0 for ; Fri, 21 Jul 2023 05:41:39 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8EACBB114A for ; Fri, 21 Jul 2023 09:41:39 +0000 (UTC) X-FDA: 81035126718.10.63B7311 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by imf11.hostedemail.com (Postfix) with ESMTP id 4CBC04000E for ; Fri, 21 Jul 2023 09:41:37 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=IQ4OQMpU; spf=pass (imf11.hostedemail.com: domain of fengwei.yin@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=fengwei.yin@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689932497; 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=apzMRyTxT/YpU0tZgW/dawYoZpV0o4D5ZoL/b9Sz3J8=; b=kVLQcaWIGtmeESl+O09Kh04K1mj35oSedESotg6LETez36l0UQxTofSLNH4y6terwBepP1 rtVC+duH6rhTE4bQHsXz7v+PmzAT79BKsw6ZWmmL2pbuTwQBiw/oxtnDMrLkLmWIRg8SWZ RFVPiP5D077Gaf977d0VqiwE4M+m1NE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689932497; a=rsa-sha256; cv=none; b=iZGRgPmql9Q9a7W6e6et8poaBwfwUFZOOWc0MaShC1C0hm2QJkgbzQUmcvu/WQsy42iFiI 1A55CFla8uHiwPNYSYyHfxw9bajC2COBHcGbAsIyC2vP1iKlZjHPS0Cbadhw6vJ0IZHZg4 s9J01MERdfTQ03zfYxpEnMVBgBrBQ5I= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=IQ4OQMpU; spf=pass (imf11.hostedemail.com: domain of fengwei.yin@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=fengwei.yin@intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689932497; x=1721468497; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cu8lT3oOEGsTcv6kJqkYTpbtDaklUJpbsDBtNyUKlKw=; b=IQ4OQMpU3blp7bbrJDxW1aQqXGbor3hoIhbK7cYiyFOCkOeBvyXM4CpQ XP3Hx4d7orp6XtlGA1lubFcmZgwNedW0QSDcq2eK/LE7f2qQBUmpcdCEh rY2bU1Ib0wgFSZemKM3Hy8GSOcgtrqklbIdCJPUQ2IGlKPi1kksKjje1o p8TTQBZ4zGRbPpcZVgcdsXeCWPoCUQj2ecwDHbiiKWxwYHDOfKHETHGmi YC9C8SDUy8dh4+N8q8+IyJUysyIyQR1tH3U9NuHnaF1OewtFP6KzeQTA0 66nSWeIqW9GAs8LVMviFOMmFG64xafxHVi323yJBMIW3qb5bbozCFTjDa g==; X-IronPort-AV: E=McAfee;i="6600,9927,10777"; a="397874365" X-IronPort-AV: E=Sophos;i="6.01,220,1684825200"; d="scan'208";a="397874365" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2023 02:41:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10777"; a="971386942" X-IronPort-AV: E=Sophos;i="6.01,220,1684825200"; d="scan'208";a="971386942" Received: from fyin-dev.sh.intel.com ([10.239.159.32]) by fmsmga006.fm.intel.com with ESMTP; 21 Jul 2023 02:40:59 -0700 From: Yin Fengwei To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, minchan@kernel.org, yuzhao@google.com, willy@infradead.org, david@redhat.com, ryan.roberts@arm.com, shy828301@gmail.com Cc: fengwei.yin@intel.com Subject: [RFC PATCH v2 2/4] madvise: Use notify-able API to clear and flush page table entries Date: Fri, 21 Jul 2023 17:40:41 +0800 Message-Id: <20230721094043.2506691-3-fengwei.yin@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230721094043.2506691-1-fengwei.yin@intel.com> References: <20230721094043.2506691-1-fengwei.yin@intel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4CBC04000E X-Rspam-User: X-Stat-Signature: nwtkf1xt389mn3cs9dum41kw9ox8mnpi X-Rspamd-Server: rspam03 X-HE-Tag: 1689932497-272248 X-HE-Meta: U2FsdGVkX18J95nUbX6fgt9HzVrR/uRknA1Gluch6xeFkSZK04hFfBVgEefx6imdrxFrZi4PQMgjA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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: Currently, in function madvise_cold_or_pageout_pte_range(), the young bit of pte/pmd is cleared notify subscripter. Using notify-able API to make sure the subscripter is signaled about the young bit clearing. Signed-off-by: Yin Fengwei --- mm/madvise.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/mm/madvise.c b/mm/madvise.c index f12933ebcc24..b236e201a738 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -403,14 +403,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, return 0; } - if (pmd_young(orig_pmd)) { - pmdp_invalidate(vma, addr, pmd); - orig_pmd = pmd_mkold(orig_pmd); - - set_pmd_at(mm, addr, pmd, orig_pmd); - tlb_remove_pmd_tlb_entry(tlb, pmd, addr); - } - + pmdp_clear_flush_young_notify(vma, addr, pmd); folio_clear_referenced(folio); folio_test_clear_young(folio); if (folio_test_active(folio)) @@ -496,14 +489,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, VM_BUG_ON_FOLIO(folio_test_large(folio), folio); - if (pte_young(ptent)) { - ptent = ptep_get_and_clear_full(mm, addr, pte, - tlb->fullmm); - ptent = pte_mkold(ptent); - set_pte_at(mm, addr, pte, ptent); - tlb_remove_tlb_entry(tlb, pte, addr); - } - + ptep_clear_flush_young_notify(vma, addr, pte); /* * We are deactivating a folio for accelerating reclaiming. * VM couldn't reclaim the folio unless we clear PG_young.