From patchwork Thu Feb 10 12:30:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12741873 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 381B8C433EF for ; Thu, 10 Feb 2022 12:37:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E1516B0075; Thu, 10 Feb 2022 07:37:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 990826B007B; Thu, 10 Feb 2022 07:37:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 88BC56B007D; Thu, 10 Feb 2022 07:37:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0028.hostedemail.com [216.40.44.28]) by kanga.kvack.org (Postfix) with ESMTP id 7A4806B0075 for ; Thu, 10 Feb 2022 07:37:31 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 33A14181F6CB5 for ; Thu, 10 Feb 2022 12:37:31 +0000 (UTC) X-FDA: 79126821102.29.2268B59 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf04.hostedemail.com (Postfix) with ESMTP id D141340007 for ; Thu, 10 Feb 2022 12:37:30 +0000 (UTC) Received: by mail-pf1-f178.google.com with SMTP id x15so7546377pfr.5 for ; Thu, 10 Feb 2022 04:37:30 -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=vH5ZsS3PT2z/Kj1kRUC91t3vQ/3r4wzvj9kOFOgiv2XuirXjyqCONSJ/51PQ+9kRrK me7yzHej8KCOSngIj9caZ8TYmD6yjv+OipS0Zh++ztGJnNTQv16Q7RRYXhTYPGAmroqD 8m5j3krUJ5T7ngC61kzmUoO7LQUaIz2LEx+1pTMuFaVjauZ+az7YgVOMXYNt/EgUzglJ CeNzs5L0I0SGoqAREdYhRiJAtewRFVJhmU7qPU751vHJEyUnYbv9HmWNYc2VVD/9t+9P RXlLPEDx6qiWtpgfwcD3oePkZ1C9Ng9PvZ1jiTdIVXdZgfWlIljgvFq369BTQ+OK00/n CUjg== 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=qqUYhIaGKGop7sbqId+sIYSjP7oK0pWU57pqUkABgqsd64WRDY5Kp0ZrPeUTvAAw0r L6ukfjT68o4uzg6yq74W9JQeYi1MsEn61phQbRrMVxWQj+xD/eBa/asin9fqAJEljuUf KTtyVI88FlblK61DuV2qMqg0PadU3QPK9sXULWWTtzHyhi8MJ7uQm9iYRB1e3ovLSeUv 24RXfSf24wdY+JzTpUTFhzbWjSp0t0ME5dtYugfGARKkbht38aIPnlE4n/jRqEStnlpO I1rxgUDFD2hznxgfktw4Ub/nCIo0ThagBXVTP2H9R4hJ4cU1sr6wSJ0j9u6WIB0wPAKE 6q8g== X-Gm-Message-State: AOAM530WtYhTGoK3StVjVmVelq9ClUIfYxn4bJ0A98F+EjLM2ejM2UxE K/KCBbHePar4L40spa88vQkTRJ6oADVWlggg X-Google-Smtp-Source: ABdhPJwl1X1ncYwB3dcpyVNk3GZyIIA7yD1CzabbhXJpnxAOqkc97+qhRQDMOf2nz7oIH9laIqf+NA== X-Received: by 2002:a65:681a:: with SMTP id l26mr5933154pgt.365.1644496649737; Thu, 10 Feb 2022 04:37:29 -0800 (PST) Received: from FVFYT0MHHV2J.tiktokcdn.com ([139.177.225.237]) by smtp.gmail.com with ESMTPSA id i8sm11767812pgf.94.2022.02.10.04.37.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 04:37:29 -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 v5 2/7] mm: fix missing cache flush for all tail pages of compound page Date: Thu, 10 Feb 2022 20:30:53 +0800 Message-Id: <20220210123058.79206-3-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220210123058.79206-1-songmuchun@bytedance.com> References: <20220210123058.79206-1-songmuchun@bytedance.com> MIME-Version: 1.0 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=vH5ZsS3P; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf04.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Rspam-User: X-Rspamd-Queue-Id: D141340007 X-Stat-Signature: zpt8wgzp5tq5ycqfja4oxyac41d3tztm X-Rspamd-Server: rspam07 X-HE-Tag: 1644496650-279582 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, while 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, struct page *page, if (!PageMappingFlags(page)) page->mapping = NULL; - if (likely(!is_zone_device_page(newpage))) - flush_dcache_page(newpage); + if (likely(!is_zone_device_page(newpage))) { + int i, nr = compound_nr(newpage); + for (i = 0; i < nr; i++) + flush_dcache_page(newpage + i); + } } out: return rc;