From patchwork Fri Jan 21 07:55:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12719427 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 D2889C433EF for ; Fri, 21 Jan 2022 07:56:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3B3476B007E; Fri, 21 Jan 2022 02:56:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 36EB86B0080; Fri, 21 Jan 2022 02:56:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 251776B0081; Fri, 21 Jan 2022 02:56:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0150.hostedemail.com [216.40.44.150]) by kanga.kvack.org (Postfix) with ESMTP id 16A696B007E for ; Fri, 21 Jan 2022 02:56:32 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C25F1181CBDB1 for ; Fri, 21 Jan 2022 07:56:31 +0000 (UTC) X-FDA: 79053536982.06.6B44502 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by imf13.hostedemail.com (Postfix) with ESMTP id 0243320026 for ; Fri, 21 Jan 2022 07:56:30 +0000 (UTC) Received: by mail-pj1-f45.google.com with SMTP id s61-20020a17090a69c300b001b4d0427ea2so12675548pjj.4 for ; Thu, 20 Jan 2022 23:56:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yazOhP0ZHzlY8srvqZA4aBLnRzwBUTc6naQJNmJIPto=; b=l4crWR5N15uNGOzFWkRqNP1rs6DtIDG8844ZqupvfUpmQECG23k+vyhFEhXsny/5xw fa/xQBPl/XEZfrXn6weA7s/O4oobHkUuX/789CQQV8R8YA0k+NweSnP67sj1F9yGUtnq lhTZBXn2zqx4wYNwYucAP7uQmKbAazKl5IbHqaYlIlDJuuHZ1SwITsVBpqVrwUwmA0MU buOQRB0QdA1vPqCn1sNGqJejfqaJrk98h8PnV9IioeIRqu/aPh33qRLDCuSi002egg/N QHkUeqChy7k5tfTqYGUL7a94JmyPPvubU4Xil9E+orA/juejflD69PJiRlrnguXM1pot VnGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yazOhP0ZHzlY8srvqZA4aBLnRzwBUTc6naQJNmJIPto=; b=zi3svl5+pyDTWsO3/Bh6HKaHqqGx2bLNh4VoyiEaZuEJxccIxRwqUsMdllQlhlo8h4 XVORS1gzlq/LCllyQv3GHUaQdJcJj0yqVXYm6AgsT6NBrjrRQRU0J+B2BAMPiNYelsBa WGAltqlSDQn4zBjZjUFnwGQdLfjyUY+IKoJlKjx+lXsgB4Oac+6K8JAQypgTwwdABCYP 9fWa56LttVnfFR/yIVPEcFT/F4s1sEjxS/Tcyvvxby0m6MZwbElxe77sRYvNppULE4ii 2Zdw4n1JJjhCWTKe+IJPkwGimrpFAaHeHcxK/axOm2kS6NDVwOMPQf8xzUfoAcNfUQRG 8Ufg== X-Gm-Message-State: AOAM531g8CVDtR8sr5NeLafTUZp9uqTvjU6ppKvQ4UtS4M0qyIk90W6Q CqKWFb0xFFmqvhyPT31mxRAkOg== X-Google-Smtp-Source: ABdhPJzsnK6W/iuE/aijaL5gz1UJdJ5Uk7MIPGSQiG/0M5loABE5QAM8YgMpA18TTWDghqAi5SCyAA== X-Received: by 2002:a17:902:e54d:b0:14b:1a2b:e842 with SMTP id n13-20020a170902e54d00b0014b1a2be842mr2707933plf.102.1642751789637; Thu, 20 Jan 2022 23:56:29 -0800 (PST) Received: from FVFYT0MHHV2J.tiktokcdn.com ([139.177.225.230]) by smtp.gmail.com with ESMTPSA id t15sm10778178pjy.17.2022.01.20.23.56.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jan 2022 23:56:29 -0800 (PST) From: Muchun Song To: dan.j.williams@intel.com, willy@infradead.org, jack@suse.cz, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, apopple@nvidia.com, shy828301@gmail.com, rcampbell@nvidia.com, hughd@google.com, xiyuyang19@fudan.edu.cn, kirill.shutemov@linux.intel.com, zwisler@kernel.org Cc: linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Muchun Song Subject: [PATCH 1/5] mm: rmap: fix cache flush on THP pages Date: Fri, 21 Jan 2022 15:55:11 +0800 Message-Id: <20220121075515.79311-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) MIME-Version: 1.0 Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=l4crWR5N; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf13.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.45 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Stat-Signature: ni9qnwqnnnaoux6q9xxqb3g7txz7gnni X-Rspamd-Queue-Id: 0243320026 X-Rspamd-Server: rspam12 X-HE-Tag: 1642751790-772336 X-Bogosity: Ham, 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: The flush_cache_page() only remove a PAGE_SIZE sized range from the cache. However, it does not cover the full pages in a THP except a head page. Replace it with flush_cache_range() to fix this issue. At least, no problems were found due to this. Maybe because the architectures that have virtual indexed caches is less. Fixes: f27176cfc363 ("mm: convert page_mkclean_one() to use page_vma_mapped_walk()") Signed-off-by: Muchun Song --- mm/rmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/rmap.c b/mm/rmap.c index b0fd9dc19eba..65670cb805d6 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -974,7 +974,7 @@ static bool page_mkclean_one(struct page *page, struct vm_area_struct *vma, if (!pmd_dirty(*pmd) && !pmd_write(*pmd)) continue; - flush_cache_page(vma, address, page_to_pfn(page)); + flush_cache_range(vma, address, address + HPAGE_PMD_SIZE); entry = pmdp_invalidate(vma, address, pmd); entry = pmd_wrprotect(entry); entry = pmd_mkclean(entry);