From mboxrd@z Thu Jan 1 00:00:00 1970 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=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 3FF06C07E94 for ; Fri, 4 Jun 2021 14:48:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E2C32613FF for ; Fri, 4 Jun 2021 14:48:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E2C32613FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 76F876B008C; Fri, 4 Jun 2021 10:48:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7465E6B0093; Fri, 4 Jun 2021 10:48:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E73E6B0095; Fri, 4 Jun 2021 10:48:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0234.hostedemail.com [216.40.44.234]) by kanga.kvack.org (Postfix) with ESMTP id 2F9326B008C for ; Fri, 4 Jun 2021 10:48:54 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B07FF18021B8B for ; Fri, 4 Jun 2021 14:48:53 +0000 (UTC) X-FDA: 78216323346.21.966FCB7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id D9565900073F for ; Fri, 4 Jun 2021 14:48:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622818122; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=jp1+wVSB+7vvWzgBMXFHA8qcBIuZi+O0ew+V7NeqdBE=; b=N3hdyJh0EA6baVF+QSLY1givJ/TK/CHo6o2pn9udQuaUw7ht5D80SBfwztBPder8FJuhdY CcHYs7Mub7NzNIxqLuZzkFf+faDRt4JQ9iN7BGA+NgGdT7MqwD3YGIGwN+ss9qh7FW8NLU 5GhASpaXd26zFLTTTivLPhdsJ5YE7Iw= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-360-Usn9Qd7fPZiNTawcwedrbg-1; Fri, 04 Jun 2021 10:48:40 -0400 X-MC-Unique: Usn9Qd7fPZiNTawcwedrbg-1 Received: by mail-qv1-f71.google.com with SMTP id n4-20020ad44a240000b029021cbf9668daso6821234qvz.23 for ; Fri, 04 Jun 2021 07:48:40 -0700 (PDT) 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:message-id:references :mime-version:content-disposition:in-reply-to; bh=jp1+wVSB+7vvWzgBMXFHA8qcBIuZi+O0ew+V7NeqdBE=; b=dYadBhCQ+I3PFIq8nfqS0iKlstwPzr47LBjHWsR4SPGZrG7riShGYcuR8j4Mmuu7Lc dkCWKj8eazhwCFOyrCvbmkmyaEvzlZMPG6oDtnIpjod2n9GidH6sakWMl7Z7Vbn6AvZ9 1JUg4dHZU8dPlDpGrcRubVlOEmRRaTgYNf+koDOQJWyOyeVYTQz+nvSKtuIcFiX2o6qh 8IBL7syNGS7akB9BaXQSGXSSLaRww2/pa3xwsA9BvaMVuR0K2sX5ENUgh6k3OcQNkZO3 vrxRGhg4AfJg5qRrVzjT8wj3gxBDFtsc4xi8zj2CjRtSjoK7XvGncCVEDqcCMtUKoGeB wzbA== X-Gm-Message-State: AOAM530slDm1Nr0KILb7vfvaty7a/lz/kMr/saokfBlF+Y9+o0vGJk8j e7001zdwOklE33YC61hTCQxt/KrSLDt4Wyn57jU3f8CDshZYjUB8oqX8BmMo0V14m3Ym0X6EKeE 8qBIiQMS7KhU= X-Received: by 2002:ac8:5a44:: with SMTP id o4mr4892952qta.189.1622818119987; Fri, 04 Jun 2021 07:48:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsTsGcW0ow0eBZ3bFuOemTwfuhys1mG+/ypvjMRj/HwVPu8NxHqgNg+Df85d1TH9IvofYboQ== X-Received: by 2002:ac8:5a44:: with SMTP id o4mr4892931qta.189.1622818119759; Fri, 04 Jun 2021 07:48:39 -0700 (PDT) Received: from t490s (bras-base-toroon474qw-grc-61-184-147-118-108.dsl.bell.ca. [184.147.118.108]) by smtp.gmail.com with ESMTPSA id 85sm4038779qko.14.2021.06.04.07.48.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 07:48:38 -0700 (PDT) Date: Fri, 4 Jun 2021 10:48:37 -0400 From: Peter Xu To: Hugh Dickins Cc: Andrew Morton , "Kirill A. Shutemov" , Yang Shi , Wang Yugui , Matthew Wilcox , Naoya Horiguchi , Alistair Popple , Ralph Campbell , Zi Yan , Miaohe Lin , Minchan Kim , Jue Wang , Jan Kara , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/7] mm/thp: try_to_unmap() use TTU_SYNC for safe DEBUG_VM splitting Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=N3hdyJh0; spf=none (imf19.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam03 X-Stat-Signature: azwonc479eknrkjooy7q8jx5tqda6f84 X-Rspamd-Queue-Id: D9565900073F X-HE-Tag: 1622818107-410570 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: On Thu, Jun 03, 2021 at 07:54:11PM -0700, Hugh Dickins wrote: > On Thu, 3 Jun 2021, Peter Xu wrote: > > On Tue, Jun 01, 2021 at 02:07:53PM -0700, Hugh Dickins wrote: > > > diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c > > > index 2cf01d933f13..b45d22738b45 100644 > > > --- a/mm/page_vma_mapped.c > > > +++ b/mm/page_vma_mapped.c > > > @@ -212,6 +212,14 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) > > > pvmw->ptl = NULL; > > > } > > > } else if (!pmd_present(pmde)) { > > > + /* > > > + * If PVMW_SYNC, take and drop THP pmd lock so that we > > > + * cannot return prematurely, while zap_huge_pmd() has > > > + * cleared *pmd but not decremented compound_mapcount(). > > > + */ > > > + if ((pvmw->flags & PVMW_SYNC) && > > > + PageTransCompound(pvmw->page)) > > > + spin_unlock(pmd_lock(mm, pvmw->pmd)); > > > return false; > > > } > > > if (!map_pte(pvmw)) > > > > Sorry if I missed something important, but I'm totally confused on how this > > unlock is pairing with another lock().. > > I imagine you're reading that as spin_unlock(pmd_lockptr(blah)); > no, the lock is right there, inside spin_unlock(pmd_lock(blah)). Heh, yeah... Sorry about that. > > > > > And.. isn't PVMW_SYNC only meaningful for pte-level only (as I didn't see a > > reference of it outside map_pte)? > > But you are pointing directly to its reference outside map_pte()! Right, I was trying to look for the lock() so I needed to look at all the rest besides this one. :) I didn't follow Yang's patch, but if Yang's patch can make kernel not crashing and fault handling done all well, then I'm kind of agree with him: having workaround code (like taking lock and quickly releasing..) only for debug code seems an overkill to me, not to mention that the debug code will be even more strict after this patch, as it means it's even less likely that one can reproduce one production host race with DEBUG_VM.. Normally debugging code would affect code execution already, and for this one we're enlarging that gap "explicitly" - not sure whether it's good. This also makes me curious what if we make !DEBUG_VM strict too - how much perf we'll lose? Haven't even tried to think about it with details, but just raise it up. Say, is there any chance we make the debug/non-debug paths run the same logic (e.g. of SYNC version)? -- Peter Xu