From patchwork Fri Jan 21 08:13:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12719459 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 0E489C433EF for ; Fri, 21 Jan 2022 08:14:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 96DA06B007E; Fri, 21 Jan 2022 03:14:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 91D626B0080; Fri, 21 Jan 2022 03:14:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 80EA16B0081; Fri, 21 Jan 2022 03:14:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0247.hostedemail.com [216.40.44.247]) by kanga.kvack.org (Postfix) with ESMTP id 73C056B007E for ; Fri, 21 Jan 2022 03:14:23 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 22452180D331F for ; Fri, 21 Jan 2022 08:14:23 +0000 (UTC) X-FDA: 79053582006.10.DF3A76C Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by imf25.hostedemail.com (Postfix) with ESMTP id 4A5D1A000A for ; Fri, 21 Jan 2022 08:14:22 +0000 (UTC) Received: by mail-pj1-f42.google.com with SMTP id n16-20020a17090a091000b001b46196d572so8467754pjn.5 for ; Fri, 21 Jan 2022 00:14:21 -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=NUBLyuZGx9EGOqRiyub00DClmOV9oJNDGNsE24u7OX4=; b=1VYMBBb5mRYIBmY88rfyjbzyYUn6xg4It5vlmh63KVQT0xL3q96ahenBlmXqkOLRgE I0nURUrCD+FKAMs1SxB2dhCEjBKmw9D3eni7sxtMvdzgvep1Uz0FTS/whYpc5iDxYplu tWEdbxhCmuZWdd0UJZLw+BHsvJIqwBdqK3FJ7JiVPbOLKHJzcanyIcB/ApExOF9+YxBf ZX8KiHRKAGAa1d1sYO88TsLJ51zEoH1V09HkeVRQGR8lQ0/dlqlFRxxuLa87vEnNwrhI 7vmAXdSAwwnUTBDbtmhgNfRVvyO/gtF477oRSnwSFlbSqr0kUjfjGvEtlKo9M/QFC4mJ cLGg== 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=NUBLyuZGx9EGOqRiyub00DClmOV9oJNDGNsE24u7OX4=; b=I4vBLlTLle8Qfmhg9OJJ3IviMQ2AYY6K9cZchFOopD9oSwB97BlKRSpRwx/8LXg+0h g4SFa0250VhMxWZZFzP4qIRPJ0g3JAt0f18J3R8JF4UCgs9+Ot4wbZZTz6RopEqdNu/+ YzA9BHnxPOlRAYMJFWsrJqMttJeCBgIXCvrwBKnp7hK5DpF5ypaCiXxVpVAWoYgbZHLN 7qRkiM/rJLNf46z5B0Q8Y75vbGkbl/AUjSa+9fGuHrwZAp2RyQ7cHbrro/Z4jaeMOYtA BYdFQtEN4iRsuV14KrM2HdZ4ZlnGqdQZifRJuvP55Mhfyyuskd9zgvQ+clcrDIcEZdmh gvQw== X-Gm-Message-State: AOAM530pCv6Cb0SQRpF3R3xFPNvGLJRencI4QKW1L3y+1dcp1Uq4mmRI FsHDeddHZmBhtzXMt0y/fR8RlA== X-Google-Smtp-Source: ABdhPJxcpqZv/OlIM7SZY8OGqKI5V0XfZzksOJ1RfFNoYzyXmLezjeSzliK5MeRSIpx/p9UtTE2NUA== X-Received: by 2002:a17:902:cec1:b0:14a:5426:81a with SMTP id d1-20020a170902cec100b0014a5426081amr2784624plg.134.1642752861089; Fri, 21 Jan 2022 00:14:21 -0800 (PST) Received: from FVFYT0MHHV2J.tiktokcdn.com ([139.177.225.230]) by smtp.gmail.com with ESMTPSA id q9sm6191010pfk.137.2022.01.21.00.14.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jan 2022 00:14:20 -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, Muchun Song Subject: [PATCH 1/2] mm: thp: fix wrong cache flush in remove_migration_pmd() Date: Fri, 21 Jan 2022 16:13:44 +0800 Message-Id: <20220121081345.80320-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) MIME-Version: 1.0 X-Rspamd-Queue-Id: 4A5D1A000A X-Stat-Signature: rs3stajno5w5ojf6qereygubizy3giyg Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=1VYMBBb5; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf25.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.42 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Rspamd-Server: rspam03 X-HE-Tag: 1642752862-707752 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 --- 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