From patchwork Mon Jan 24 05:17:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12721552 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 4969CC433EF for ; Mon, 24 Jan 2022 05:18:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 89C0A6B0081; Mon, 24 Jan 2022 00:18:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 84BBD6B0083; Mon, 24 Jan 2022 00:18:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 761116B0085; Mon, 24 Jan 2022 00:18:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0120.hostedemail.com [216.40.44.120]) by kanga.kvack.org (Postfix) with ESMTP id 677196B0081 for ; Mon, 24 Jan 2022 00:18:06 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 18AB3181C9D3F for ; Mon, 24 Jan 2022 05:18:06 +0000 (UTC) X-FDA: 79064024172.28.6BD9E2E Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf24.hostedemail.com (Postfix) with ESMTP id 3F568180002 for ; Mon, 24 Jan 2022 05:18:05 +0000 (UTC) Received: by mail-pf1-f172.google.com with SMTP id h5so6379526pfv.13 for ; Sun, 23 Jan 2022 21:18:04 -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:mime-version :content-transfer-encoding; bh=zP36aX2d/bL6wS6rcbFJKrOBtz963Nu2Kl7o23XZalE=; b=u53kMVT1HAOzyAHD6LkcLXv4YmcYTS+naIZ3o73dHyAi/6jxb7xkkx8srkEdgI6wuC 5wqEUbd98o2kB8drLXvSSDVix9X3EGBdn6pvaTxT7RNdEpj645jfE4qxAwASiVAvDXjM ARH8ayPrDE+L+VJvOdCFEy1sDgaNA8hDRliKjCWmZHrR4+w64uAMmPbxQSHSEhdB+REO EytluLz/hkxH9jTtJGnz2GTlGJgren6/ISKvLuDi/HBw464+4Fuw25N1n46hjoT4BG18 LWJkecKpssASBvS1OOY3HltjsmttZchousDfKh2nxLBOfqhseBn3SgMHn4HwaRRPYU7a UNhQ== 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:mime-version :content-transfer-encoding; bh=zP36aX2d/bL6wS6rcbFJKrOBtz963Nu2Kl7o23XZalE=; b=NwTErY2zj7ux6Ar/Dw5UW8NGyxcI/669KsHafJgi3xD+Clc249fgRhTTZBA0I15KW2 N2i9drtkxJ2P1+sNjEn+eCrN+DMySAvlF2rLfB5P2hOmzY4kXWhK5LvY7xxdTAimowhg ozq97ZJ0/QoUK1dQOzUofzxxT0AbnA8cKpqLx8x4CIzPMkrx7fjScodKCvl9Vk71qmIV AOs9qhXjhSvy07xnETIsv4v94DUOxPscl99kzSzrlQPgz0vNydHKDnRN+LcbIXTWavUX /bx0NgxuWcYwFWO0r+o8krKeYiB3jUnR2tIK/pbcCeaBM+FlDWKJnQ0/95vRnbtXMgJO DqHg== X-Gm-Message-State: AOAM533Rvcr2eQj/r2uLdOhyQ3bqT0i5vAevbjo/Z9RjwNVrBsqHWlRU WoKQzEbuB5oqIjd0J/sxKkxBuQ== X-Google-Smtp-Source: ABdhPJy5c5N5VaAzxWc2RK+1xQ2ug8lRSvUjdW/Kex0OEX3SffhRhUWLglgrGGuU4rdCqCEVt41/tQ== X-Received: by 2002:a63:8c59:: with SMTP id q25mr10494273pgn.13.1643001483990; Sun, 23 Jan 2022 21:18:03 -0800 (PST) Received: from FVFYT0MHHV2J.tiktokcdn.com ([139.177.225.234]) by smtp.gmail.com with ESMTPSA id l21sm14263018pfu.120.2022.01.23.21.18.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 21:18:03 -0800 (PST) From: Muchun Song To: akpm@linux-foundation.org, zi.yan@cs.rutgers.edu, kirill.shutemov@linux.intel.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, duanxiongchun@bytedance.com, Muchun Song , Zi Yan Subject: [PATCH v2 1/2] mm: thp: fix wrong cache flush in remove_migration_pmd() Date: Mon, 24 Jan 2022 13:17:51 +0800 Message-Id: <20220124051752.83281-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) MIME-Version: 1.0 X-Rspamd-Queue-Id: 3F568180002 X-Stat-Signature: 8isjhh77aj1c4k5jnc8hu4wohb93z1h9 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=u53kMVT1; spf=pass (imf24.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Rspamd-Server: rspam01 X-HE-Tag: 1643001485-789912 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 flush_cache_page() is supposed to be justified only if the page is already placed in process page table, and that is done right after flush_cache_page(). So using this interface is wrong. And there is no need to invalite cache since it was non-present before in remove_migration_pmd(). So just to remove it. Signed-off-by: Muchun Song Reviewed-by: Zi Yan --- Changes in v2: - Collect Reviewed-by tag. Thanks Zi. mm/huge_memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index f58524394dc1..45ede45b11f5 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3207,7 +3207,6 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) if (pmd_swp_uffd_wp(*pvmw->pmd)) pmde = pmd_wrprotect(pmd_mkuffd_wp(pmde)); - flush_cache_range(vma, mmun_start, mmun_start + HPAGE_PMD_SIZE); if (PageAnon(new)) page_add_anon_rmap(new, vma, mmun_start, true); else @@ -3215,6 +3214,8 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) set_pmd_at(mm, mmun_start, pvmw->pmd, pmde); if ((vma->vm_flags & VM_LOCKED) && !PageDoubleMap(new)) mlock_vma_page(new); + + /* No need to invalidate - it was non-present before */ update_mmu_cache_pmd(vma, address, pvmw->pmd); } #endif From patchwork Mon Jan 24 05:17:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12721553 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 B940AC433F5 for ; Mon, 24 Jan 2022 05:18:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3BA356B0083; Mon, 24 Jan 2022 00:18:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 36B1E6B0085; Mon, 24 Jan 2022 00:18:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20AA26B0087; Mon, 24 Jan 2022 00:18:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0090.hostedemail.com [216.40.44.90]) by kanga.kvack.org (Postfix) with ESMTP id 124936B0083 for ; Mon, 24 Jan 2022 00:18:09 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id BA5538249980 for ; Mon, 24 Jan 2022 05:18:08 +0000 (UTC) X-FDA: 79064024256.22.13CDC8A Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by imf28.hostedemail.com (Postfix) with ESMTP id 48A37C0007 for ; Mon, 24 Jan 2022 05:18:08 +0000 (UTC) Received: by mail-pj1-f45.google.com with SMTP id d5so12878990pjk.5 for ; Sun, 23 Jan 2022 21:18:08 -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=kKp2VsYVshLyXdr/Mm5s2c/ypkad29QD2/BMtkuP4rM=; b=KMFMXHj1seUsAKWZF1wx6B80aQgEMVTjVCw3uuJwzlNCa4fehZo82ctufwGRlAx/nE 1Os6wrArlQlVOMsLzUOXbogYGGXyYCXhFJCR6N0818Utleh/fKrubFUP3fBm0Yubg9CE Jg5ag39IA6Ot0T5y35480iUDQddincDphtjn4Dm4W1Q/lQydpeCDai/soZLgzFhdlVt6 atWJMdpe09b8mWmypGUz28vXNQXZtix3LpaGcXxJBusEaBK8PyoHArik4+PhVetiqkFg cEDufP1xSnLPFQCGYVM3OpQbMKq9lil+I9NBrKu5YeY5kVaEr2LwfkBG8+VqHXWZrgpa tcAg== 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=kKp2VsYVshLyXdr/Mm5s2c/ypkad29QD2/BMtkuP4rM=; b=BYOh2uvNaGfyzMaZQOYejmd3yNXjiUgmPNXEbPJudcihu7x6xkpFFGP/qbETgjoLj5 04WeEipD6wFQNV/+qGgl9WlTznlrFkv0NEhRsB0lTo3T0cGVl0O+hA6YXCpdoHhylBID i9jJtoBJ63ymYVOcsMp2niwquABJ5P+4fkFb9LqNeHXlVD/saEAskgluEh9626MyV74I DVUV8nkazoDtPjpQWX2ClN/KQwqTeALPE0+3N8+6IpguOMGaL5564vyQONC3YPbmsEXD Eh7Fa0IbBKY2S1gYK5Kj9DhliF9uKgavdaOJwbtYZtMbIp/4EoaNJFX45hpusA1I7gmW 74kA== X-Gm-Message-State: AOAM5337GVvjG9kXpMTbutZUzK18qavQHvdPbCX9sGbeXHykLXfgTfln byAGpMTifMzLqH1D3PAL3ki5KA== X-Google-Smtp-Source: ABdhPJxybSZPlRDINVw0aEX2KARMUBoqgQqXKvdvrZKs+UMQM/WyESYd1/uYYZyNkz5zhJm/v1mvFg== X-Received: by 2002:a17:903:24d:b0:149:b68f:579 with SMTP id j13-20020a170903024d00b00149b68f0579mr13534093plh.1.1643001487395; Sun, 23 Jan 2022 21:18:07 -0800 (PST) Received: from FVFYT0MHHV2J.tiktokcdn.com ([139.177.225.234]) by smtp.gmail.com with ESMTPSA id l21sm14263018pfu.120.2022.01.23.21.18.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Jan 2022 21:18:07 -0800 (PST) From: Muchun Song To: akpm@linux-foundation.org, zi.yan@cs.rutgers.edu, kirill.shutemov@linux.intel.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, duanxiongchun@bytedance.com, Muchun Song Subject: [PATCH v2 2/2] mm: fix missing cache flush for all tail pages of THP Date: Mon, 24 Jan 2022 13:17:52 +0800 Message-Id: <20220124051752.83281-2-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220124051752.83281-1-songmuchun@bytedance.com> References: <20220124051752.83281-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Stat-Signature: ax1ioe838beuaeqbnn8q53jw7tmbpnwe Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=KMFMXHj1; spf=pass (imf28.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.45 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 48A37C0007 X-HE-Tag: 1643001488-240226 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 THP. Fix this by not using flush_dcache_folio() since it is not backportable. Fixes: 616b8371539a ("mm: thp: enable thp migration in generic path") Signed-off-by: Muchun Song --- Changes in v2: - Using a for loop instead of the folio variant for backportable. 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;