Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1413545pxb; Fri, 21 Jan 2022 18:06:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3pCD15le5mvCiPJdMfa6GdQS/MwK2C+JqDZm04lbWq/FNYulEIUchSpqRPcLNyya4IFPx X-Received: by 2002:aa7:8393:0:b0:4bc:b311:edec with SMTP id u19-20020aa78393000000b004bcb311edecmr6071328pfm.26.1642817197720; Fri, 21 Jan 2022 18:06:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642817197; cv=none; d=google.com; s=arc-20160816; b=wipBL4mbuSUK0gwmHrgIleZPomX/pITnpbw3KwPmxQ8MdTM2PTdnO7USaGHlfLPnSQ yQkqfRmBzZG+Fo9tJmCc/7cZqsIkr0js2SKyiTdeEBq2YFFCwQ+VTfRggbELVrf9KM6u zMfVGWxaXA0ge48a8tIS969QFyir19rV7UjW3mqQ6OwmHqE++nCxPecJW39xrhBnhMNi P3ZT1rykbAaBp9q8vdnz6aJcMtWNpKXst92cIJGqG9BPjM371QyuFpUjgLSKiWnXu4e/ NZM4tB+/XJKzcqFG6c4QLNL48q2+7GVtQdyuzOtYdFEu/Ez+sb4HCZeIRUA4WASKWBpm HQGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=HB00Dk4BxVgWeQmFduo2LILaD1FFGYAEdZ3PebPBEBw=; b=Ho4dKRbYyryyr69IzdmdBnWXHETVBwz4jjovzYtRwe4McYZ2DvQADGaBdG2QHOQP5h h2iJWct5wdnh97PDrG9hKwdDAUvb9+9bddtHajdXpKBeBPSKqZiH3PlzoyYMWLdhw0YV mECBUFh1AM85K+Wkc7IXpyoZqcka1Q0Kgrjud75ARYBFbcoqCfy+ByhbkrPG0QZr3uP4 4M3U3KJALZQTk/dcvApEaaP01nQsYrCDD0ZY759kIZiUIxb58qAhb3dKbDi2S7+v84vx A0Bq89fIi+UtGHL+a17K1vxyprNCGpEbR5pPunYe+94El3xt0lZyAbAgRnrWZF9Lbc+3 2ljg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="btFmWrH/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s17si7255753pgm.852.2022.01.21.18.06.16; Fri, 21 Jan 2022 18:06:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="btFmWrH/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243813AbiAUSGH (ORCPT + 99 others); Fri, 21 Jan 2022 13:06:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239373AbiAUSGF (ORCPT ); Fri, 21 Jan 2022 13:06:05 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CFE7C06173B; Fri, 21 Jan 2022 10:06:05 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id h7so2243952ejf.1; Fri, 21 Jan 2022 10:06:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HB00Dk4BxVgWeQmFduo2LILaD1FFGYAEdZ3PebPBEBw=; b=btFmWrH/V9v5abyka+eab1Rs3zrpPn0nci4AUiouqLNDpjw/NkYUFUhvw773WCVIAk xVmqjmn/xkl65jW4CpvfWhM1dxlKUEOH+mZCaCYyhd3lampu7yFeaohMhgJxOLABmYK2 0sgxwzihFGSQPijTrND8NtNoGE8QvLZsgDbb2u0jCFaiMSvU8eaXk992+0Fs/m8gK2i+ dW9hP3ZqPsSXfA2BbKSsAN3XxXk1xRi2PsGpzdmTfbm/tAAg4TFXNNL6U3UECgd/ag2J 5N6t40/gB1LtQRaV0K3wOggY/uAWuhlL/2gu3bKqYOK3tbn4edp4axjVfBashkqM4zQI xYTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HB00Dk4BxVgWeQmFduo2LILaD1FFGYAEdZ3PebPBEBw=; b=aJwjgfhuIcKYYqsAE2Hg+KPN4ocLmK4hyijj0FRxSsEcSS9g3bdLTEqec9Y5/NC+5I PfR5zwrrvjhCQADjeg0f32mVABF/br5Vk7SFkBU5t6kDVpp5F6kccMQs8D0xtjbeyYA1 aFOfkk9/ZJiZjp9Set2lyFV6nPs4cnuCgj8SMX+8I2xBxy3k6Xc5In4nUQOUGDYtF0t/ zuciEhwR1HT+bh4/dDsbp/zRt9bu3FzpUZdCg74I/G6y+iXfjuoZNqTRFDGkjR96oBtv RqFqizlRhripbWsTMy1U6J8PuZpJFs6a7Zgk+Hh3xSRdkbsyxpneZ2mdnuNcUt3oQcqP /xIA== X-Gm-Message-State: AOAM532MNSiq9gaeMlvD1wDJwv9vUVuNMktOzvhjAHjWXBNNKGqTwkv/ hJfAY2CGMMbtvU5CjISk2zwaGR3JJQsHzQYb48o= X-Received: by 2002:a17:907:94c9:: with SMTP id dn9mr4119453ejc.270.1642788363547; Fri, 21 Jan 2022 10:06:03 -0800 (PST) MIME-Version: 1.0 References: <20220121075515.79311-1-songmuchun@bytedance.com> In-Reply-To: <20220121075515.79311-1-songmuchun@bytedance.com> From: Yang Shi Date: Fri, 21 Jan 2022 10:05:51 -0800 Message-ID: Subject: Re: [PATCH 1/5] mm: rmap: fix cache flush on THP pages To: Muchun Song Cc: Dan Williams , Matthew Wilcox , Jan Kara , Alexander Viro , Andrew Morton , Alistair Popple , Ralph Campbell , Hugh Dickins , xiyuyang19@fudan.edu.cn, "Kirill A. Shutemov" , zwisler@kernel.org, Linux FS-devel Mailing List , nvdimm@lists.linux.dev, Linux Kernel Mailing List , Linux MM Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 20, 2022 at 11:56 PM Muchun Song wrote: > > 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. Yeah, actually flush_cache_page()/flush_cache_range() are no-op for the most architectures which have THP supported, i.e. x86, aarch64, powerpc, etc. And currently just tmpfs and read-only files support PMD-mapped THP, but both don't have to do writeback. And it seems DAX doesn't have writeback either, which uses __set_page_dirty_no_writeback() for set_page_dirty. So this code should never be called IIUC. But anyway your fix looks correct to me. Reviewed-by: Yang Shi > > 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); > -- > 2.11.0 >