From patchwork Mon Jan 31 16:02:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12730830 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 CE1E5C433FE for ; Mon, 31 Jan 2022 16:04:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2163C6B00C8; Mon, 31 Jan 2022 11:04:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 19BCD8D0001; Mon, 31 Jan 2022 11:04:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 088AA6B00CA; Mon, 31 Jan 2022 11:04:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay028.a.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id DFF2B6B00C8 for ; Mon, 31 Jan 2022 11:04:28 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 4106B60D22 for ; Mon, 31 Jan 2022 16:04:27 +0000 (UTC) X-FDA: 79091054574.03.EADEC34 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf04.hostedemail.com (Postfix) with ESMTP id B419D40041 for ; Mon, 31 Jan 2022 16:04:07 +0000 (UTC) Received: by mail-pl1-f171.google.com with SMTP id z5so12718248plg.8 for ; Mon, 31 Jan 2022 08:04:06 -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=3P2GhQ/A4jZ2vY4MofmwB/at+DQmKpJSp18e9dRfwe4=; b=5URQXSWgeqQ7mckfU4C9lY/dFwxZNhRwVpHK8PF66Zds0N3U5nsrMNbagre+kYdnct +7o8S/vRwiYT6Zw3piBgSLEXOeagAuCSSDt5bYZ8PiiQ1WiJOzuLDBf9kGZ2xrU0DFCI Bj4Qz09SgZvWc8iA9F5vFDGmETHPkYnDxkCsLa8nhEgbbBi5icdAE1eLXYLBh8ZXnLJ1 MjO8vyzTyf6I6AAfmVEXkPHMyN5hET/0/8R3vtzopEPjnTYAD6MjTm+ZVCnuHucvkzT9 R2JPwM4NUEFLkb5Pavb8ubGKAM7YnFbERMPEt5PE/HE28UvrKKlT8px8uUdqmOm8J+sK zXFA== 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=3P2GhQ/A4jZ2vY4MofmwB/at+DQmKpJSp18e9dRfwe4=; b=V2CqICQ+izDczDo7mL5+9MVBOQ6vzRKvJlFrglkE+yO4YlHjjtXgcyPtkIjl3/k4N8 66+YiNmAXNPrfhNPVoy++aNFE36ZTQ5Shloc4oJiSd0hZCsCA5oTPjMOYOq5mwnpBwL6 gpRzYes+WSw2pyt+t6dtLTlNnsBicqfWcOLzsrQVa6izYV7g1dkOW8Ftmsjd9Yd04G1H ZFA2fv70vfcgd9c5TvoO1U3MorHUNdw0c0MJHnUjkBYlSMhrzu0znlvHrq9Kx2LFEiZK TZvtyeO9gvDawlQUUTqWxTwDwTczwNqMx4FYfpDkoedvf6tqDWFGHm8ymvAzXBuQkJdP DJqA== X-Gm-Message-State: AOAM530rapYimK5mAoA0/8Rl3TF1G+lYjj6yyIQazXXRk/BpxmwFnY4h xuRxcoNIB7FqRQ/f9MB2MC9oyQ== X-Google-Smtp-Source: ABdhPJx+s3Ymv7b02lJg4vX/CGJvKlKxbU1nqbdkqUMa4X7q/ZoBsG0DOzq5OgBQhaDtJj5SKTVUgQ== X-Received: by 2002:a17:902:ea06:: with SMTP id s6mr20895751plg.161.1643645045966; Mon, 31 Jan 2022 08:04:05 -0800 (PST) Received: from FVFYT0MHHV2J.tiktokcdn.com ([139.177.225.244]) by smtp.gmail.com with ESMTPSA id n42sm17940716pfv.29.2022.01.31.08.04.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 08:04:05 -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 Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, duanxiongchun@bytedance.com, Muchun Song , Zi Yan Subject: [PATCH v3 1/5] mm: thp: fix wrong cache flush in remove_migration_pmd() Date: Tue, 1 Feb 2022 00:02:50 +0800 Message-Id: <20220131160254.43211-2-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220131160254.43211-1-songmuchun@bytedance.com> References: <20220131160254.43211-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: B419D40041 X-Stat-Signature: nsyz4ccghc8rcq5oi7ajgb668efesjxh Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=5URQXSWg; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf04.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Rspam-User: nil X-HE-Tag: 1643645047-882696 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 --- 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