Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2567514pxb; Sun, 3 Apr 2022 11:38:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzMr9hZU2rR+ZDoUyMnk0R09OFXxkhmDF54BEjhSEAh9XOqZJAVnmf6uLaSQl4ooC4S+zs X-Received: by 2002:a17:907:6d82:b0:6d6:da31:e542 with SMTP id sb2-20020a1709076d8200b006d6da31e542mr7682219ejc.135.1649011130465; Sun, 03 Apr 2022 11:38:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649011130; cv=none; d=google.com; s=arc-20160816; b=OIqRd/Gh/4GIrKgsYYpeRw9xMbbijdbUAh2MY4M27PExh/CeBqTHf4dpZv/4biAJhj ohFxH/NrElGnlU5I5Nx8kJxIg1WJ2iZSjL00YtqXintl8FwExOQml4d+2C7pWrrVNKCG isaeczPsoTHNghW7+MZ2qcAyGAfImTyonURtsElxSTsXYLlg1IQdCjJHs42pAuts9JwV ocsF7uSrS8c10A5FmBuT7y73qf0rN+vY4XtdylF5kT2pRrfuXrTP+yjj05HButXQGD3u SnB47LYeMt2awjDULzSg++6wpZhPTZK0C7bmi2vi658P+NLDc7ay8+GfJidzqc6Myz1N wulg== 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=qCp2b48ULThIjDs7kZ69Cjh0BLYiJwB01qLpS62xP+w=; b=uPFv9kOZ0EobJei+5PIFOe3KMNQjL97ApMF/nqL3rr4XLH7B5HZDisvwb/NLcF19q5 oMCdBDNVbZJjZ9lFnB5YE/OEeXCXR6YP9KsB7v+EQDZbpi0K1SI7LkCSb3l1Qe/PA/nC IsA1W0Q5tSzm0DQ8dSZQPGKE8fLq/2gQTj2dQGZbL/hRZWXjdrZxq7kseBPBRF0ivQWN pkdvH8v8D4HciQp3t0TKm0Iyz2tVSzYMoU630T9sk9TjnW8CAr6YuvPqmEODLyfUWmKR 21o890K50iDF5b0v56zERMXOoreKEpDcdqOkJC0F5dlG4siWgSX4Tq+VJrpUidsI9vtg 4qxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=lwrBARs+; 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=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m15-20020a17090679cf00b006e7e8a3352asi1192840ejo.582.2022.04.03.11.38.26; Sun, 03 Apr 2022 11:38:50 -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=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=lwrBARs+; 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=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238584AbiDCFn1 (ORCPT + 99 others); Sun, 3 Apr 2022 01:43:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238730AbiDCFnU (ORCPT ); Sun, 3 Apr 2022 01:43:20 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C0D2381B3 for ; Sat, 2 Apr 2022 22:41:25 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id o3-20020a17090a3d4300b001c6bc749227so6121171pjf.1 for ; Sat, 02 Apr 2022 22:41:25 -0700 (PDT) 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=qCp2b48ULThIjDs7kZ69Cjh0BLYiJwB01qLpS62xP+w=; b=lwrBARs+/7DTDJPCPDkO87hzSIKPt6GQ3BJuVqyr1LMMRf0ELecQkoLiSNJjbiZdpd OOw8+jdaEjkrKEkQOCmLvwQJzHLz27JTlGJ5zE2dn5Jip53qlttwM0FkCYZueUeb7zeF RVGdSY44kEkFd3NNdpkbB9EPEooKpn6V9VAwbVH27fUkD5jUhTGJPGtIrzGx+IUgXU/O uu1GRfpRmgRGEwvWhRZtaM7CW/f27In9HxOfBsluDtGcV56/sxLL1FJ//gEuOidep45r /RAHUxBOsm5BUtauhEFj88JE1ydBVybi1r2rzExNbwhHo6EWG1darzCFI36vXEKt9WKC z0qQ== 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=qCp2b48ULThIjDs7kZ69Cjh0BLYiJwB01qLpS62xP+w=; b=3pMrNldeshdUBlTVQPUSHs85TjCCI9MOYe4Vwn0CrFVQ942jhu26Rq8+FI/jtT7u5c h+T1OjdwC/ceiqNpMxNdi2/Mo8zJ6QZ2ncTNrTiQyrXetPNv2V7Ld5bQk+im2WzlEMF3 i0lkpBpMqLEXbo/4o8HxUMzDbKSqGMbD+neeKx1Ram8qb2EMkhfMVssxtvtR6p0iugsc BNWFVDZqdnsLNcBsF+nLzSQK8Rr83IXMhm243Wo55x3tkQU7GhWdRNTyXi9BXQ+u8QSO 2R7ITkyQg+T77dNsBVtMDxx6D6sNR5+eeyKygvETeZKtA7q6Uwexkbbe2hJKH9KsF5Aq B1YQ== X-Gm-Message-State: AOAM533ucUoEUtKyabsuUF1Ocq9xUxrPhINrmn8mbbR0flgyDM0cg37w k0SozByWjJu7cWA/U39xELxcFQ== X-Received: by 2002:a17:90b:4b42:b0:1c7:3f6a:5d97 with SMTP id mi2-20020a17090b4b4200b001c73f6a5d97mr19591035pjb.27.1648964484666; Sat, 02 Apr 2022 22:41:24 -0700 (PDT) Received: from FVFYT0MHHV2J.bytedance.net ([139.177.225.245]) by smtp.gmail.com with ESMTPSA id a38-20020a056a001d2600b004f70d5e92basm8262479pfx.34.2022.04.02.22.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Apr 2022 22:41:24 -0700 (PDT) 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, smuchun@gmail.com, Muchun Song , Christoph Hellwig Subject: [PATCH v7 2/6] dax: fix cache flush on PMD-mapped pages Date: Sun, 3 Apr 2022 13:39:53 +0800 Message-Id: <20220403053957.10770-3-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220403053957.10770-1-songmuchun@bytedance.com> References: <20220403053957.10770-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,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 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. This is just a documentation issue with the respect to properly documenting the expected usage of cache flushing before modifying the pmd. However, in practice this is not a problem due to the fact that DAX is not available on architectures with virtually indexed caches per: commit d92576f1167c ("dax: does not work correctly with virtual aliasing caches") Fixes: f729c8c9b24f ("dax: wrprotect pmd_t in dax_mapping_entry_mkclean") Signed-off-by: Muchun Song Reviewed-by: Dan Williams Reviewed-by: Christoph Hellwig --- fs/dax.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/dax.c b/fs/dax.c index 67a08a32fccb..a372304c9695 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -845,7 +845,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); -- 2.11.0