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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D88D7C4332F for ; Thu, 8 Dec 2022 21:05:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 459258E0003; Thu, 8 Dec 2022 16:05:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BB1D8E0001; Thu, 8 Dec 2022 16:05:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 234998E0003; Thu, 8 Dec 2022 16:05:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0E2AF8E0001 for ; Thu, 8 Dec 2022 16:05:21 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id DE1A11A07D6 for ; Thu, 8 Dec 2022 21:05:20 +0000 (UTC) X-FDA: 80220369600.10.F186217 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 0AD981C001B for ; Thu, 8 Dec 2022 21:05:18 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="BKop/Wb+"; spf=pass (imf20.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670533519; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=p90updOgwd1USYq0liDeFfcravRUaF2Ej7MYlbLmcPw=; b=pkxD/0Gt9+6C+4sYyBl9NEmmRJmR2uM0HEJZP1+8t7LIl/cuA5XcRUtg7SFg7JeHKD2sPu fxB7avXnxeeTjY+jTs+Y9O4suM2abcAUoJStu1uzE2pHNYuela0WfBYD9wTyqazyje1c96 1zieicZjS+zhIO9bKFOSEJkDVWoAiIM= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="BKop/Wb+"; spf=pass (imf20.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670533519; a=rsa-sha256; cv=none; b=4SSZiXYX2PJw4PnBzFYL47UazexcT8ybzFD2iKkROp9AMLkENeTTxyCLU463IkC10VV8dH ncXhr0hxe0ltyx30DzLJUsN7mfqfpykIN+uIZRf4GAhBSMF1yS4VWf9QNBymy9xMbaC0Se K9poz38zBTmTLKYqM5J78NwN+JUKZ0o= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670533518; 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=p90updOgwd1USYq0liDeFfcravRUaF2Ej7MYlbLmcPw=; b=BKop/Wb+EXRO9yi+rVzAIZX/V4TlYOqEaR81vLnezKX3ATFeKoLgWKNEJ41jsZXX26vhxP Gi7B34m5N9L9+70HRdM7f0Vtw0w0wzsjQhTtKs8080aZ087LA8iOfj3KOBNcUG+khrT2sy T/bhWOiMjBfmHmw06gc4NqPUp5tB1uo= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-475-ngjJc9XgPgCSRJ2Nt4BH1w-1; Thu, 08 Dec 2022 16:05:16 -0500 X-MC-Unique: ngjJc9XgPgCSRJ2Nt4BH1w-1 Received: by mail-qt1-f198.google.com with SMTP id hg24-20020a05622a611800b003a66175d924so2537805qtb.1 for ; Thu, 08 Dec 2022 13:05:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=p90updOgwd1USYq0liDeFfcravRUaF2Ej7MYlbLmcPw=; b=Ycpq6fHtSFp9vBwEL6N4m61hwN3lDk+dQmQ2Lf4Juzki9FT3N8uIdkIEDMS6fmlIi8 whXs7TJfGqx9CvepAaI7cZONVv3AQt9R5COPDRLQw+D/yxPK0Cn2lUFzNulwNIVw6vOl Y3/ZygfoLVlK2sETCVaM+mCiev7VMMESYG7VIh4NV/hYlOme3txNovYbNU4xX/Gwe5KJ ZH4elKKxbzHmZlNz7n8/yzT2nXkePadhPVLxzSulDVI7ryljCkQIsroT4oIdGbFLETAZ MFN20XOnSyjEShae9Thfn0meZ4UZhJYW/7SQwhOxNog4njv4xg6NDfyasp2rLXcmH05+ +img== X-Gm-Message-State: ANoB5pllyWn9QGflV0bvZxsnSE7gPqmtORHmji5t3Pq3J0PPLqIrc6T+ kHAFryg21A26lsYKYcuduTaP3zR5Fl4uzxD4cF77x1Bp7iQlS016bDUHuRQmSQ2RPqbKOsWTxpS 1hStQtGOZXKA= X-Received: by 2002:ac8:774d:0:b0:3a5:7ab0:e1c4 with SMTP id g13-20020ac8774d000000b003a57ab0e1c4mr4649235qtu.35.1670533511910; Thu, 08 Dec 2022 13:05:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf5O9YmWRgmJW2ZnxZNg83hBfPnP8RFzwN69nU4apaBGReiFXz1mF8FR0BzprN2mwE/Jjr6CmQ== X-Received: by 2002:ac8:774d:0:b0:3a5:7ab0:e1c4 with SMTP id g13-20020ac8774d000000b003a57ab0e1c4mr4649209qtu.35.1670533511650; Thu, 08 Dec 2022 13:05:11 -0800 (PST) Received: from x1n (bras-base-aurron9127w-grc-46-70-31-27-79.dsl.bell.ca. [70.31.27.79]) by smtp.gmail.com with ESMTPSA id p18-20020ac87412000000b0039cba52974fsm7942735qtq.94.2022.12.08.13.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 13:05:11 -0800 (PST) Date: Thu, 8 Dec 2022 16:05:09 -0500 From: Peter Xu To: John Hubbard Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Jann Horn , Andrea Arcangeli , James Houghton , Rik van Riel , Miaohe Lin , Nadav Amit , Mike Kravetz , David Hildenbrand , Andrew Morton , Muchun Song Subject: Re: [PATCH v2 10/10] mm/hugetlb: Document why page_vma_mapped_walk() is safe to walk Message-ID: References: <20221207203034.650899-1-peterx@redhat.com> <20221207203158.651092-1-peterx@redhat.com> <6a970de6-e3da-f57d-14fd-55f65ddcb27d@nvidia.com> MIME-Version: 1.0 In-Reply-To: <6a970de6-e3da-f57d-14fd-55f65ddcb27d@nvidia.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 0AD981C001B X-Stat-Signature: ra8isazzoky3c36zbmxkoxw886r7oeho X-HE-Tag: 1670533518-158382 X-HE-Meta: U2FsdGVkX19L2g72sIFWkqy9/+WF6XXRAcPkLFl2arM36zebEs9an9iWQ/N+pOv2R3iduRDU4t4nbpcQP9D27u/TLR/Dyu6tJZdjLJ2QR0g/vmAhrxVhAUnoMmX7OccdKoReKA/pYmEC52VegUz9Il/3RuqBND4duVMy1h/6P/1DptYJ5/K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2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Dec 07, 2022 at 04:16:11PM -0800, John Hubbard wrote: > On 12/7/22 12:31, Peter Xu wrote: > > Taking vma lock here is not needed for now because all potential hugetlb > > walkers here should have i_mmap_rwsem held. Document the fact. > > > > Reviewed-by: Mike Kravetz > > Signed-off-by: Peter Xu > > --- > > mm/page_vma_mapped.c | 10 ++++++++-- > > 1 file changed, 8 insertions(+), 2 deletions(-) > > > > diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c > > index e97b2e23bd28..2e59a0419d22 100644 > > --- a/mm/page_vma_mapped.c > > +++ b/mm/page_vma_mapped.c > > @@ -168,8 +168,14 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) > > /* The only possible mapping was handled on last iteration */ > > if (pvmw->pte) > > return not_found(pvmw); > > - > > - /* when pud is not present, pte will be NULL */ > > + /* > > + * NOTE: we don't need explicit lock here to walk the > > + * hugetlb pgtable because either (1) potential callers of > > + * hugetlb pvmw currently holds i_mmap_rwsem, or (2) the > > + * caller will not walk a hugetlb vma (e.g. ksm or uprobe). > > + * When one day this rule breaks, one will get a warning > > + * in hugetlb_walk(), and then we'll figure out what to do. > > + */ > > Confused. Is this documentation actually intended to refer to hugetlb_walk() > itself, or just this call site? If the former, then let's move it over > to be right before hugetlb_walk(). It is for this specific code path not hugetlb_walk(). The "holds i_mmap_rwsem" here is a true statement (not requirement) because PVMW rmap walkers always have that. That satisfies with hugetlb_walk() requirements already even without holding the vma lock. -- Peter Xu