Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp465716pxm; Wed, 2 Mar 2022 02:03:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJxGFBeFTGaQbdN8FJ9TKOqN1x/MLxWry3ydGRRn4tL90AUEuxMzU/XuIAzv1MK+dWOYtOtS X-Received: by 2002:a17:90b:609:b0:1be:cb41:5b6a with SMTP id gb9-20020a17090b060900b001becb415b6amr10006959pjb.169.1646215420562; Wed, 02 Mar 2022 02:03:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646215420; cv=none; d=google.com; s=arc-20160816; b=B9tc+iTlOFH3Gb71h+95P8ydIVQq5YOMnr65/XY/j9/iQpczYBTjo2ONJhdSf0Yet+ 6PVMByQII0HqjZhhiFbBfQZdt/9bT84deHeRN+X3DQTzcju59xY0ojA+yl5E/IxOWrRP MiVC2rGdvuMre5OQD0r+r/s2JZNpkuOLveLcmVThxFx0rG9ZKKUUCftDw+GLrUx/GMSh xb9NGlGNmqhwuEhi/nrYkRrK4aExdy0uNT4gGJBJx4n4A0hIBwZeDUnHYLbnz+oWd4gx 1c1LDgABDnwchNkLMj5y7leXXqFXASzg1JBK4s3kGjCFzgxAjsjONlvfoqPeCOKfsGc7 SLfg== 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=dOhvmpBLieRVF+NKQPb4pdavGDEjnXCIzLlMLWWpOKA=; b=YS+zi4K30hX630IvQWAxU2yRxPxlKSGSQVaUvCJLmj+9hFS/ks4Be1q/3WvWCJMsQo OY5Zqi+CKiNrx7k7DaQyxPXMpVuRYzU2EQKGRqtvtm6Wy7+47fCbckrtbsE47x2Wp8Sw 9YfmxuW2B3UekPYl3HuUd0ruViTH5DH4Qc0HdjiZEhN/gVXGCC++t6fo4ib/lJedpfZo tqwRx7Jlo7OYHVtxB7IXldD2y7vckwXH2gymV3pzBpmX6w8CmwIyGdnZn57HxR5BNSgk qVQ+HA3moLwkyH19wwvrYrN5AfKK8vIjvtEJaLeoDFd5FR/VduxGmqdlBRzaP8eLQiG/ m4lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=Eqy9IPjb; 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 f3-20020a63de03000000b003703e3b2f08si14692528pgg.149.2022.03.02.02.03.25; Wed, 02 Mar 2022 02:03:40 -0800 (PST) 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=Eqy9IPjb; 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 S240124AbiCBIaG (ORCPT + 99 others); Wed, 2 Mar 2022 03:30:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240101AbiCBI37 (ORCPT ); Wed, 2 Mar 2022 03:29:59 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2044CB82E9 for ; Wed, 2 Mar 2022 00:29:13 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id p3-20020a17090a680300b001bbfb9d760eso4163281pjj.2 for ; Wed, 02 Mar 2022 00:29:13 -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=dOhvmpBLieRVF+NKQPb4pdavGDEjnXCIzLlMLWWpOKA=; b=Eqy9IPjbLYYbIstc/J+JZ8WTf619n0h2r8uqKqJ+e6S9Uv+eWqpcul4UbryOb5p+/u MaSxXNwLLByowHTqGTJmAsxIcHxjSri8rtIKgWnK7dAxgThGETtK7a3vlVgTsAIso5ar jz6a8FaGafuyrVazLBfr548UwTAKf5gemmCc1q/mdgh/EBxhT2Wvwoij1uyTH3KARIXd jcdjAZ9+pZL04jxy94vLnK5/fYv2dad6VTjRS0mMTD7NNmpGZHjiGq1JUbhrnPSfBT1F 4WAiWLScu72rwaHUnfiXZdJgAL3fWS9Qcg6grtWwG0Zxwea9ard9epbbCH3a5Is0pfue VlFw== 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=dOhvmpBLieRVF+NKQPb4pdavGDEjnXCIzLlMLWWpOKA=; b=ePJxzRFNOB7Ofhm6EeoQrRgMF5Czpy+iZM8PMXR+qGBLQCLFTDATgWS4F2XUfaZ3uW kV08quvMVR6O490pu8EB1y87kX56F6Yc9iSXTRZwIUaG0fRyt966tzokRJGRYYmWfYfU ikW6WkcxywPi2KMn6EvoIXlDjOHSSNedg49pkfUZvg89BIcREPzsyvWM5Ia5RO4EqJzh Sswqry3OXpz7KtG/zQRaxvSGrfoPfAJo099fudYmbMylTHWY06cmTUirXO5XOeybjteq Plh06KuvBz2j8IKMEZwGxX5w8dtG0DcMLX1Jbk11uBWEEZF8P8xDOEinml6M9WlXt8ee dSgg== X-Gm-Message-State: AOAM531Dhp70Qn8qUo+obtwahmoxiidk4sSqZ+XTRsfICctN9MNIcBWV HmKmgOwWTVnkdfRXGNBaX/24pQ== X-Received: by 2002:a17:90a:ec09:b0:1bc:d7c2:b2d5 with SMTP id l9-20020a17090aec0900b001bcd7c2b2d5mr25500689pjy.22.1646209752693; Wed, 02 Mar 2022 00:29:12 -0800 (PST) Received: from FVFYT0MHHV2J.bytedance.net ([61.120.150.70]) by smtp.gmail.com with ESMTPSA id a20-20020a056a000c9400b004f396b965a9sm20922228pfv.49.2022.03.02.00.29.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 00:29:12 -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, smuchun@gmail.com, Muchun Song Subject: [PATCH v4 1/6] mm: rmap: fix cache flush on THP pages Date: Wed, 2 Mar 2022 16:27:13 +0800 Message-Id: <20220302082718.32268-2-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220302082718.32268-1-songmuchun@bytedance.com> References: <20220302082718.32268-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. 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 Reviewed-by: Yang Shi --- mm/rmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/rmap.c b/mm/rmap.c index fc46a3d7b704..723682ddb9e8 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -970,7 +970,8 @@ static bool page_mkclean_one(struct folio *folio, struct vm_area_struct *vma, if (!pmd_dirty(*pmd) && !pmd_write(*pmd)) continue; - flush_cache_page(vma, address, folio_pfn(folio)); + flush_cache_range(vma, address, + address + HPAGE_PMD_SIZE); entry = pmdp_invalidate(vma, address, pmd); entry = pmd_wrprotect(entry); entry = pmd_mkclean(entry); -- 2.11.0