From patchwork Wed Feb 2 14:33:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12733095 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 BF61DC433F5 for ; Wed, 2 Feb 2022 14:34:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 58AE98D010A; Wed, 2 Feb 2022 09:34:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 514578D00F9; Wed, 2 Feb 2022 09:34:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 390908D010A; Wed, 2 Feb 2022 09:34:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0052.hostedemail.com [216.40.44.52]) by kanga.kvack.org (Postfix) with ESMTP id 26FC68D00F9 for ; Wed, 2 Feb 2022 09:34:34 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DCC898101D20 for ; Wed, 2 Feb 2022 14:34:33 +0000 (UTC) X-FDA: 79098085626.16.AE2E35D Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf14.hostedemail.com (Postfix) with ESMTP id 830FE100007 for ; Wed, 2 Feb 2022 14:34:33 +0000 (UTC) Received: by mail-pj1-f41.google.com with SMTP id oa14-20020a17090b1bce00b001b61aed4a03so6177572pjb.5 for ; Wed, 02 Feb 2022 06:34:33 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=yqTwEL7kOTcKChIBcjkLKs2qIde8K14LqGVT2DBRTU0=; b=QfoqDLtleFoLTKKXN2gEfiVcozG97ChIFEO+Dxb9kfB8mws46ckDiFZ0spHu+3Ckwi KQZam58ZAHqgcYKidzpFN3iPnYbSqMyyJG9+H9OJMKcVySUshYFShTfVPilrnyzKLSYH /hwxBMauDgvjBwXaDv+t8Aigdr4S4kh8m6NusA04i61YrBQTjYU+aXUCrcvJKRfVAtto sw938xa5LtXWuBW9vMuJyLDJ7JhQtLB6VO31Lkk4zgYI1K22xsLAs86nIFN1bdsqem9D b9A0oRcRgZgOiBmtV/hB8lrUnmP7ugc5phBXv7BZKIExxz7n+Io5ja4QbCqxemwNNnNZ LTNA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=yqTwEL7kOTcKChIBcjkLKs2qIde8K14LqGVT2DBRTU0=; b=l3ZNQA5sscbRGBnZC14G7nYrHj0p9jmepBy4kY9Qu1ftIWuhTEgCUrqkKV6zO7BKdK gN3mL8Vwaa+nP1Uj81c1bTljo3D3yabdff0mvE8sxEZemy5ADFfiEgFphvatxfOzcf2r 3zhKS6jzVhiZB3GLQ64G1aGPghmOIXM/wCl3P0yl1ekpgtKt2WUFkHUZqLqUG7TcFOIh gbk/Z3IKVG7+3o/XSIWnXVwe3bqa+hEBzVhmO7/HwYI0LzHwEs2V9ATb0hclJoYEi5sr VXsMjy01StNATLVTow1tAJUIKLxbjcvD0ckzNt3NE8Pe68Hq3AnFnjKDwkDnwGmdOoyO Boog== X-Gm-Message-State: AOAM533W0R5bQzyF1Udnjq/PRl+s4VW1+arW9MyjE/qvTPFJx9nu0JRc R7zbO1tJjydzRfvKWjbbJSVqjw== X-Google-Smtp-Source: ABdhPJzSJUsu2k5lK4qLz9mFNP97HsqVWca02fgKwu6JP8Fe8B9Slwu6HkVpi8yiT/kqkiwV52Yk5Q== X-Received: by 2002:a17:90a:cc07:: with SMTP id b7mr8389698pju.43.1643812472560; Wed, 02 Feb 2022 06:34:32 -0800 (PST) Received: from FVFYT0MHHV2J.tiktokcdn.com ([139.177.225.241]) by smtp.gmail.com with ESMTPSA id s9sm29079268pgm.76.2022.02.02.06.34.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Feb 2022 06:34:32 -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, hch@infradead.org Cc: linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-mm@kvack.org, duanxiongchun@bytedance.com, Muchun Song Subject: [PATCH v2 2/6] dax: fix cache flush on PMD-mapped pages Date: Wed, 2 Feb 2022 22:33:03 +0800 Message-Id: <20220202143307.96282-3-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220202143307.96282-1-songmuchun@bytedance.com> References: <20220202143307.96282-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Rspam-User: nil X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 830FE100007 X-Stat-Signature: 43ck3qdp5sd8feiza9y1e1kdi5qcrc16 Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=QfoqDLtl; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf14.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-HE-Tag: 1643812473-298622 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. Fixes: f729c8c9b24f ("dax: wrprotect pmd_t in dax_mapping_entry_mkclean") Signed-off-by: Muchun Song Reviewed-by: Jan Kara --- fs/dax.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/dax.c b/fs/dax.c index 88be1c02a151..e031e4b6c13c 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -857,7 +857,8 @@ static void dax_entry_mkclean(struct address_space *mapping, pgoff_t index, if (!pmd_dirty(*pmdp) && !pmd_write(*pmdp)) goto unlock_pmd; - flush_cache_page(vma, address, pfn); + flush_cache_range(vma, address, + address + HPAGE_PMD_SIZE); pmd = pmdp_invalidate(vma, address, pmdp); pmd = pmd_wrprotect(pmd); pmd = pmd_mkclean(pmd);