From patchwork Thu Jun 10 06:54:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 12311983 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AC64C47094 for ; Thu, 10 Jun 2021 06:54:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 06E5D613DE for ; Thu, 10 Jun 2021 06:54:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 06E5D613DE Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 918656B0036; Thu, 10 Jun 2021 02:54:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A13E6B006E; Thu, 10 Jun 2021 02:54:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6F3906B0070; Thu, 10 Jun 2021 02:54:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 381796B0036 for ; Thu, 10 Jun 2021 02:54:50 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C89A7180AD81D for ; Thu, 10 Jun 2021 06:54:49 +0000 (UTC) X-FDA: 78236901498.28.1D56DFA Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by imf22.hostedemail.com (Postfix) with ESMTP id 78497C005A20 for ; Thu, 10 Jun 2021 06:54:44 +0000 (UTC) Received: by mail-qt1-f173.google.com with SMTP id a15so5917186qtx.13 for ; Wed, 09 Jun 2021 23:54:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=zujSa+nymJg/DkygOzBqfFRpvoPGGLvQoUzC9rD2EmM=; b=d+CHzx9kx2FW5+g+wRTEglrZHDD2va0NJeQznMTqavHkJKp8sIQAoV4Xl6VPkL/21a GQeN3iyeoaNEmvPVwRrrGCrG6C8d6PZbBDxVmEyxIgTXugm3GmBDemitSpPAF8c4I8iU rhlfqQRvxv244TvuzRX2C190uZyOlY5zGSVwvdz2Zs7F9UAZyU3xADhczznWRvYlpZRm ALXo36ZKcmd8MTCNDLR51p1ZO9TF30Cg1VH7dw7T7Z44WunIOIV9cIhr9+rsiNeG4/VS UtwMtJ8r4/tj/Vmp+gDCrtzjuM3wf6vtEeN27WC6LLMmQZXQPKpKPv3YKoKpS9NpptTM 0XdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=zujSa+nymJg/DkygOzBqfFRpvoPGGLvQoUzC9rD2EmM=; b=eU8WhSQpMj6MjTKmkyyS+ifp0Db0g2YVvIU5gmuIzv1rN8EPcgf52lmpNWiGoLRAun hpRbJaE1Lsps0G5ZIXYEZLeXQ3PshyVAB7gVbsPTH/g/MEdEwrlAP0iavEUXTTsvX1bT Vkattb3QLkcLDQ07EcuGHdS1VGMsHHPPUSHVZ2FsdoIPwCnztexhWJ4Pd3x+ZaZUul5P /3maqlgzJRQvgnqkzQfU61Vx9ZeAOCskigAfXhcdhzhV3hCAqpH4tVINgQ5LsE5eq1V7 N/5hk5iedDJZtuZL69l/VnXGxblkuaPYLpPprmNNYGa2Kp85OC3beIP4pttLUq0kmf+0 ir6Q== X-Gm-Message-State: AOAM531kaXrUtOZp6OXQqyTV3XvUxBgEXaC10SB1mzsvGXCj3KfQ5DEk sIYZXJ+lgQufbSBuTAhXz1ES2g== X-Google-Smtp-Source: ABdhPJyWmrIYtT3Hki5va0KGk1YyG5yE6G/KbTu0XqJoO/SiXciAA8VL5O7uhLNqek19ZMtnb91BBw== X-Received: by 2002:ac8:47c2:: with SMTP id d2mr3771672qtr.128.1623308088731; Wed, 09 Jun 2021 23:54:48 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id u3sm1611578qtg.16.2021.06.09.23.54.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 23:54:48 -0700 (PDT) Date: Wed, 9 Jun 2021 23:54:46 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: Andrew Morton cc: Hugh Dickins , "Kirill A. Shutemov" , Yang Shi , Wang Yugui , Matthew Wilcox , Alistair Popple , Ralph Campbell , Zi Yan , Peter Xu , Will Deacon , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/11] mm/thp: another PVMW_SYNC fix in page_vma_mapped_walk() In-Reply-To: <589b358c-febc-c88e-d4c2-7834b37fa7bf@google.com> Message-ID: <1bdf384c-8137-a149-2a1e-475a4791c3c@google.com> References: <589b358c-febc-c88e-d4c2-7834b37fa7bf@google.com> MIME-Version: 1.0 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=d+CHzx9k; spf=pass (imf22.hostedemail.com: domain of hughd@google.com designates 209.85.160.173 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: to11toyqsuajjrg3jtb9km6gh14iu8nw X-Rspamd-Queue-Id: 78497C005A20 X-Rspamd-Server: rspam06 X-HE-Tag: 1623308084-197452 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: Aha! Shouldn't that quick scan over pte_none()s make sure that it holds ptlock in the PVMW_SYNC case? That too might have been responsible for BUGs or WARNs in split_huge_page_to_list() or its unmap_page(), though I've never seen any. Fixes: ace71a19cec5 ("mm: introduce page_vma_mapped_walk()") Signed-off-by: Hugh Dickins Cc: Acked-by: Kirill A. Shutemov Tested-by: Wang Yugui --- mm/page_vma_mapped.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index 6eb2f1863506..7ae4a016304b 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -277,6 +277,10 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) goto restart; } pvmw->pte++; + if ((pvmw->flags & PVMW_SYNC) && !pvmw->ptl) { + pvmw->ptl = pte_lockptr(mm, pvmw->pmd); + spin_lock(pvmw->ptl); + } } while (pte_none(*pvmw->pte)); if (!pvmw->ptl) {