From patchwork Thu Feb 10 12:30: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: 12741872 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 4383DC433F5 for ; Thu, 10 Feb 2022 12:37:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB9306B0074; Thu, 10 Feb 2022 07:37:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B3EC16B0075; Thu, 10 Feb 2022 07:37:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9DFAB6B007B; Thu, 10 Feb 2022 07:37:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 9161F6B0074 for ; Thu, 10 Feb 2022 07:37:26 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 6A97F1214D4 for ; Thu, 10 Feb 2022 12:37:26 +0000 (UTC) X-FDA: 79126820892.01.33F7818 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by imf10.hostedemail.com (Postfix) with ESMTP id 13EBFC0004 for ; Thu, 10 Feb 2022 12:37:25 +0000 (UTC) Received: by mail-pj1-f54.google.com with SMTP id m7so5073987pjk.0 for ; Thu, 10 Feb 2022 04:37:25 -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=JjFFmiBFFspTkoWluz4Y/2OhOC+2cDtbHwUi6Z8G3s5O6jLaI4K+hCvdUcs90RTnTb VZzbBD0KpisBRj8k0XTR/DImFMEN6lbYnM9WDekRGuOQXnKm5v/KFFCA1wP7yp5PeI0v C+DYAamNxNXL8z4lSF6NDBsFbDFTsDn5cWDibf8rPJgyTMdpR/aegPTr3LScOIw320ZH sqJSZSjApl195zpCodCKCZUZ3KK2Il7lDKn9IX13DkmKxsDDQPAnQ+a9yOjE2qFn5wCo RCS7uBuIFUpHMKaPGF2+nbn7Z+voZtzaqSo80Xtu69Fr9csc3qXRTPKMyfc2amzuhODn LyZA== 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=lwZtCgpwySgy6Pnj0CjCqDu7XgtUJGKnBSEFl4GiwhkgM/jk1XS/zOGJ8Nc0RuSzvN W5eh92VVPHI2njbv0v8KU6xV5i/aEyJ4jWPuODQnuQ4kCqLs7OPmcijJ0DZiyxEVmUyI ba3TFTRl4OT0SOE101yhHB+lOFmn8CqJH6ip26RAkHxXVoIunfIGrNGBhW8wXVGDT7i0 z5SzWJOQzaF8RsaGqvPVYa9BCdVL3UDXIumtKmF3WwLvarAfjKRs85gFhbEXKgvFwel0 gfL4+I2EkhnHNVE642wX8hK3XFvkcscxzHcLQW9nG6cTf0Fu7vSDWq7M90bY0iNghYRO NoIw== X-Gm-Message-State: AOAM530sJsbS0ZSMXbMIHEgcbgpNpeb5Xp/VF2/fLzTH0f6pDFk2A571 ztXwz+IbNaNyDOge84+WUA2fOw== X-Google-Smtp-Source: ABdhPJzv8qdSlKpXUXZEnltPAAV/8T3YIxP2tHLDjv5DmIpbC3EC8oCGfwcWkp6oBYuakLpHJH3riQ== X-Received: by 2002:a17:902:cf0c:: with SMTP id i12mr7387028plg.64.1644496645014; Thu, 10 Feb 2022 04:37:25 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 04:37:24 -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 1/7] mm: thp: fix wrong cache flush in remove_migration_pmd() Date: Thu, 10 Feb 2022 20:30:52 +0800 Message-Id: <20220210123058.79206-2-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: imf10.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=JjFFmiBF; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf10.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.54 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Rspamd-Server: rspam03 X-Rspam-User: X-Stat-Signature: 66t96amxujh4wpp9cntenj8oc7suypi4 X-Rspamd-Queue-Id: 13EBFC0004 X-HE-Tag: 1644496645-363382 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