From mboxrd@z Thu Jan 1 00:00:00 1970 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 7A478C433EF for ; Tue, 8 Feb 2022 07:36:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 125086B0078; Tue, 8 Feb 2022 02:36:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D5A46B007B; Tue, 8 Feb 2022 02:36:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EDED06B007D; Tue, 8 Feb 2022 02:36:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0074.hostedemail.com [216.40.44.74]) by kanga.kvack.org (Postfix) with ESMTP id E098D6B0078 for ; Tue, 8 Feb 2022 02:36:43 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A1C4C181DF74E for ; Tue, 8 Feb 2022 07:36:43 +0000 (UTC) X-FDA: 79118805486.20.F8CD757 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by imf19.hostedemail.com (Postfix) with ESMTP id 43E9C1A0002 for ; Tue, 8 Feb 2022 07:36:43 +0000 (UTC) Received: by mail-pl1-f177.google.com with SMTP id t9so10947481plg.13 for ; Mon, 07 Feb 2022 23:36:43 -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=I/ARb1Au1FcGhHT5OSe5P8uQ767qWIf49sbqK0ZF8no=; b=hIUCyUYTQeWIyj0y3xa/lyJzJfBL9YeIpDkgIOVfa9Clb0wtstmPR610H1IH10cyNC IG+zGUOO/ZeEVHE8BfrdZHeMAPXZJrhPIZ5Fm2Tamk5Xsyp2QOnEPsMIAJkaPCHR1gfa U32l7A+wL1flsdi7qlpHY+HbrTGtygA2afkAodp9Xx4VKZDhbKB5Md2FpFPw1lKz1Us7 lJvwf8JjE0koHnrQ1fNx3hwWEWzZMKQl0hl921uE1+/CB+qidA3V6kqFUA7qx1owiBSo ZKfSFuUUUODfiZlV0CGELceZ3dOxNuZQUzREfn5T/pI5Po6WOrr2dQ3HwuByV8LbMakC SBYQ== 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=I/ARb1Au1FcGhHT5OSe5P8uQ767qWIf49sbqK0ZF8no=; b=X7/nSgGn+kKd7e1YHu5Izp/Yk8DuwEnOlryN6JhALoGQ2uAOOiXtyJr0Pr9QlI7ItH qbGKCj8IUpITFJ5wNCpeHv5BffuwdlObwxdLwcH0WEOlTCeUurZkWflFccErDkgaKivW xFSLuIa+dikmDLot504l/qaGVIyXmwqXpy1Hrgi4sVAPh0UC0AQ1CEqo7RJdaOun0Snf XvmQPIUdtHLQBABn+E1Rl2C7IuVJzfPh1btYuMK8jQ4oKEKEKLIV7OsRidtTk50vLG/Y E17sHpn2Lv35EMNZTH5uOjzQJKGewVUagml9MsLoEIsE7dw6MALun9oe+ZIE3Jk/utyW 8FOQ== X-Gm-Message-State: AOAM530yT8P3XMu0TIZlSOgoLf9iuMMdy2BaCwKTrc7wD2jMzP7409rt Q2orydbt0rbYheyIxLI618UcZw== X-Google-Smtp-Source: ABdhPJwsZdtiU96OKE7UAsec4IC2Z4kjKKWlUx3J30L+vHnc5YKdB/6S38QvVd5szKB7Y7RVjoAr2w== X-Received: by 2002:a17:902:bf4a:: with SMTP id u10mr3025261pls.113.1644305802222; Mon, 07 Feb 2022 23:36:42 -0800 (PST) Received: from FVFYT0MHHV2J.tiktokcdn.com ([139.177.225.225]) by smtp.gmail.com with ESMTPSA id gx10sm1621017pjb.7.2022.02.07.23.36.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 23:36:41 -0800 (PST) From: Muchun Song To: akpm@linux-foundation.org, zi.yan@cs.rutgers.edu, kirill.shutemov@linux.intel.com, rientjes@google.com, lars.persson@axis.com, mike.kravetz@oracle.com, ziy@nvidia.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, duanxiongchun@bytedance.com, fam.zheng@bytedance.com, Muchun Song Subject: [PATCH v4 2/5] mm: fix missing cache flush for all tail pages of compound page Date: Tue, 8 Feb 2022 15:36:14 +0800 Message-Id: <20220208073617.70342-3-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220208073617.70342-1-songmuchun@bytedance.com> References: <20220208073617.70342-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Stat-Signature: ujahozoj8wkg79qkfchfff5dm4tg7szi X-Rspam-User: Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=hIUCyUYT; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf19.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.214.177 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 43E9C1A0002 X-HE-Tag: 1644305803-34685 Content-Transfer-Encoding: quoted-printable 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 D-cache maintenance inside move_to_new_page() only consider one page, there is still D-cache maintenance issue for tail pages of compound page (e.g. THP or HugeTLB). THP migration is only enabled on x86_64, ARM64 and powerpc, while powerpc and arm64 need to maintain the consistency between I-Cache and D-Cache, which depends on flush_dcache_page() to maintain the consistency between I-Cache and D-Cache. But there is no issues on arm64 and powerpc since they already considers the compound page cache flushing in their icache flush function. HugeTLB migration is enabled on arm, arm64, mips, parisc, powerpc, riscv, s390 and sh, whil= e arm has handled the compound page cache flush in flush_dcache_page(), but most others do not. In theory, the issue exists on many architectures. Fix this by not using flush_dcache_folio() since it is not backportable. Fixes: 290408d4a250 ("hugetlb: hugepage migration core") Signed-off-by: Muchun Song Reviewed-by: Zi Yan --- mm/migrate.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index c9296d63878d..c418e8d92b9c 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -933,9 +933,12 @@ static int move_to_new_page(struct page *newpage, st= ruct page *page, if (!PageMappingFlags(page)) page->mapping =3D NULL; =20 - if (likely(!is_zone_device_page(newpage))) - flush_dcache_page(newpage); + if (likely(!is_zone_device_page(newpage))) { + int i, nr =3D compound_nr(newpage); =20 + for (i =3D 0; i < nr; i++) + flush_dcache_page(newpage + i); + } } out: return rc; --=20 2.11.0