Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp276539pxj; Wed, 9 Jun 2021 23:57:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdyX2FClJYTikv+4LsCMAK+uRplBSFmd4pMAG8iWFIl+C5do2qLF3VOeBOrpQkx6YDXigb X-Received: by 2002:a50:cc0b:: with SMTP id m11mr3137409edi.297.1623308256874; Wed, 09 Jun 2021 23:57:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623308256; cv=none; d=google.com; s=arc-20160816; b=CxYjkqL60SjGXlzismBMvbJIS2kgBKebNeyJgbq9wRNQf2Jw9iZXIGmnQSdnLlb0kE YN0+pTHIZ6YzT61fEg4Tup+rrho9N3aS+AD1EZRvOcKB/Vb0rQnRFLJ0W64TVLUeEn5K ERA0uOENs64N/AMni2dakik4l745Ir8M9L1/DygujzWClv3dukEwpWD4Z0b2HyhzvXAG bmf//Hm/FqAHLG4qTUD+cD9xHcHWbxBHKOopSzldtZaw5C92eduCkB6DntLGxnkwlZ2n 1uoIKpY6dy0S9hymg5A1lj4haCbWQJmblQLitvlYBJ44u9+JtqC52wMf4EOep+TRRblr ewSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=zujSa+nymJg/DkygOzBqfFRpvoPGGLvQoUzC9rD2EmM=; b=mT5epy4Q7N9YcpEfm7V/GxftB4+MYfgRizkHY9PgpbhULdkXxhTt2jip2by5t24/D2 D7CaaL8f9+6b7i22rZ0ZNi4LWVarAbJbpz5eLZ/JsHfO8Ci0jlWTiYmYJdrzA8TX/WtY lAsS0Cc7Lce8u7tOJoFkkd1TGil3sO0PXzE/vBawzWQuch06RK+fneNOnuyj6T0xJ0KF 2wGmpxzJFqCnhWnvZyhOIF28D4e9V3Aebgy/26I9lwDTF+kBplBndnF6THyxuEppea5r Tzp1QqHvSl+tnJQKjfjnKDN2MM4G8SjjUqmkw0G9SnMeixx7USUIF+5hCBVNc8Wa3Tqa 0pDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=d+CHzx9k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 19si1756772edw.341.2021.06.09.23.57.13; Wed, 09 Jun 2021 23:57:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=d+CHzx9k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229808AbhFJG6C (ORCPT + 99 others); Thu, 10 Jun 2021 02:58:02 -0400 Received: from mail-qt1-f178.google.com ([209.85.160.178]:45572 "EHLO mail-qt1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229778AbhFJG6B (ORCPT ); Thu, 10 Jun 2021 02:58:01 -0400 Received: by mail-qt1-f178.google.com with SMTP id l17so16016563qtq.12 for ; Wed, 09 Jun 2021 23:55: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=sQELR0OKM+30Ktu/ayRrZlw6MI8m3Qk2crf0t7t+Wka3UoEF+xJOwqMK0/G2Y9qtSa 7JrVhdFz8bWPIsIIRRkwcE/EMcaxOub44gpElhyShEHu37Nc6uAgLES0+grNYivpweRs vpsBLOJgfc6fHa/gldI+MtXYmdd4HDwW0FemSoPfmhomyhdwYjbtyx7spe8QaQ5HoqPP tF1jJoV60w/vFI4CNjwiSDZPyX+i4ifKuaMg+EFNe7VuQcbW+HKRY6oM9yh1Cx7sCHZq Wmunlqy40Rw6ceS9LQmgbOGEmzsHb5XM0o2QsnIXA412LXd2AzPWRnAkiVi0Y5SnlJwl KQew== X-Gm-Message-State: AOAM533pB6LderD/dx/jXKj+VMOtULLZLFb4L72pilnKH2104o+yEo9u DmDEXoXCdWrzamtGsostwHn5Cg== 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 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: --- 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) { -- 2.26.2