From patchwork Tue Feb 8 07:36:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12738256 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 1AFF8C433EF for ; Tue, 8 Feb 2022 07:36:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 82A356B0075; Tue, 8 Feb 2022 02:36:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7DA116B0078; Tue, 8 Feb 2022 02:36:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A2006B007B; Tue, 8 Feb 2022 02:36:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0158.hostedemail.com [216.40.44.158]) by kanga.kvack.org (Postfix) with ESMTP id 5CBDE6B0075 for ; Tue, 8 Feb 2022 02:36:39 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 18E069676A for ; Tue, 8 Feb 2022 07:36:39 +0000 (UTC) X-FDA: 79118805318.22.F8AC0F4 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by imf21.hostedemail.com (Postfix) with ESMTP id A3D1F1C000C for ; Tue, 8 Feb 2022 07:36:38 +0000 (UTC) Received: by mail-pj1-f53.google.com with SMTP id ki18-20020a17090ae91200b001b8be87e9abso1049301pjb.1 for ; Mon, 07 Feb 2022 23:36:38 -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=gKFpQhrIc0qg1OGn2vjlbFux2cfH4pwiDVgfg/+s2Gk=; b=aesHRx4mkuJbzEXODBVC2NuJ3XIEly0uKuZ0fmmOCkbIBaQTKzJFrpHLliZ6LydIDC ZC6nmHSeL7VuMK9rDPMrgXApR4hnw1zY9zkx3KRUddNG14JwZrOt0HceyD46+rolqZSx 5HGsRA4wl3xJql/bNDiaoEcP5SL7tVmEM7fgqxVDJXJ0tBSkiUrnWmm8pAaDWr0inTKH A1TNo7Qo7cAjAJwTEXN/9nx4/YP86wP+m5YLCsjmA9PDo8Zwq+CGiG7a8HGwA1yRkFLt ziW2W/YhD7crzFt9s/t23pfDkgrlu90mkwCSBpAoO68ukfznQJvW2mLcsjBEhGGXcioK 9Gsw== 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=gKFpQhrIc0qg1OGn2vjlbFux2cfH4pwiDVgfg/+s2Gk=; b=gJqafxUoqclYYrjetMnJ4Ohq61JPOQHmUUD8fNS8J/fMxhEs5T5IGmMPmGuArWEGq+ 0hS5UR/5mJxARlcQbnSWnR0DHPPGWLvSqHHmhanHQR4VzX2y9Q/Frmrjk2U84b/nh5iC tS7myudnrLrgm3icBPus9XaxBJ8X9vY2CpGpqsRa8ZLiHTPD8wkB2sNqaz3SxGvF3A0b or/HdLn/4iW7Bn8695v5Re5dk0wFvLiAuayST/QNYcIFqL5cxPHD7zKMwFbqhxreLF+8 3owm/eQbFQ7FGn5z47dVSZNcflELMvY+F5AMkulGeMc/KBTCZt3HMgS+RW8M+XSLiIv0 K8OQ== X-Gm-Message-State: AOAM531Ud5FSBua6Dgv+IrZK1S+xdQwYxENbHD4ITLSBOQuuovr/rQod tie2GYU6MqWdmFDGR0TWE1E8Xg== X-Google-Smtp-Source: ABdhPJzEt4E48DQEs4fdQH9qP/j0O1H1fFoyW4x9658/zRKEKEvOfX+7jWzf6rShGjw7nmSjy1Bt3w== X-Received: by 2002:a17:90a:8904:: with SMTP id u4mr2969489pjn.137.1644305797603; Mon, 07 Feb 2022 23:36:37 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 23:36:37 -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 1/5] mm: thp: fix wrong cache flush in remove_migration_pmd() Date: Tue, 8 Feb 2022 15:36:13 +0800 Message-Id: <20220208073617.70342-2-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: bjby89zhrrq6zb71ebuyo1pz5drucp6n Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=aesHRx4m; spf=pass (imf21.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: A3D1F1C000C X-HE-Tag: 1644305798-421627 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_range() is supposed to be justified only if the page is already placed in process page table, and that is done right after flush_cache_range(). 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