Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1000346rwb; Thu, 8 Dec 2022 05:45:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf5BspkLbuMs6hRqDxtbCLo/eTVgqS7vIQ7WUu+Fyp5E4GD730s66w5tWowprUW37kZyRveD X-Received: by 2002:a17:902:ce06:b0:188:fd3f:cb06 with SMTP id k6-20020a170902ce0600b00188fd3fcb06mr76948114plg.23.1670507105248; Thu, 08 Dec 2022 05:45:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670507105; cv=none; d=google.com; s=arc-20160816; b=wD2WvX11typUR2DGKHi/Y3M7oNUXsJOr2tan8YA54u5Ko/7Z7J2M2f5RzuELkQbL95 XuI4/QP972iU1593nbluT1L4tb7Rq7obFAqzTted/6WWwJFpIQII+7Ah2CnDnkIoebx0 ww9l9JYztQ9ZFWX9pyWi9ETOIpDQOSHu7T3dj99aAQggNd1FT/j8tWvDVdiBbq8pEAvp 8oNrZtw34swUl+N+sA6jgavJPGnx0ZqUImOI0jC8nCOdICPt3vmVatLus4K0mrjTAM5Q WdtGAREG875lvE/hppKc66xUjNiZB9TJ6TFNwmFkvFLZ5a6Fcvduwg2uvV1Zrk8X7ZA7 IUjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=neWLwjcyNjI8ZbLG+eysMC72AXD8ev/7q1C2nUvKC3k=; b=zmq9kEjm1KiP02D6ibvDbl/XEtAxjm9Jch+yeUIr1MTsA8yf8Rx5n3FJMwYIfoCcV0 PHl1AfEqQ+ZgYL1hT45FWjMzpwWrQ58CB28LOwJBScpmiPqtGGzuV90BGKCxIKHt1DeK v/61BN2akBewJEBsxKfImFsWCitg/iDIOv/e/hcsVV77XlNCdLgGznBN/uAwy5QY7xeo pKwWtF8oLzWsQA1T9E83DuxdMI/3HaYfdJjddCQ74FaWywZjOGXKj0gCGHGzOhAUa4+t T1k6bdWiUuyyspaxa0iPjd4JwZxnnZmryOfwFNBemzUDAjbP18Xivg0vjr63f4EV+yio wg6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PNoMsKw9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w4-20020a656944000000b00477e0e4d2fbsi23035458pgq.412.2022.12.08.05.44.56; Thu, 08 Dec 2022 05:45:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PNoMsKw9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230162AbiLHNR0 (ORCPT + 72 others); Thu, 8 Dec 2022 08:17:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230209AbiLHNRR (ORCPT ); Thu, 8 Dec 2022 08:17:17 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC7C092FDC for ; Thu, 8 Dec 2022 05:16:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670505368; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=neWLwjcyNjI8ZbLG+eysMC72AXD8ev/7q1C2nUvKC3k=; b=PNoMsKw9ZZ+OzsWDRal7QugrhSNFpqkUnEQoCcBQC/KfI0lvM695cpUz1+p0G2oTjT7AP/ HloYJI53wyb720NNJAcb3OCHhDHHXMae5O8V+B6nJ5dDhg/IdGwrieyHNHjP/Go+qpg6Ub Lyw+tl+l+hwpuKEsh2MVYF6+FvxtOAo= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-465-IscL99eoMS-qNa6BGtnDXw-1; Thu, 08 Dec 2022 08:16:06 -0500 X-MC-Unique: IscL99eoMS-qNa6BGtnDXw-1 Received: by mail-wm1-f72.google.com with SMTP id bi19-20020a05600c3d9300b003cf9d6c4016so2386309wmb.8 for ; Thu, 08 Dec 2022 05:16:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=neWLwjcyNjI8ZbLG+eysMC72AXD8ev/7q1C2nUvKC3k=; b=3VdM92kog8tafweWwCW7lo3+cK9ozghOU34XsytZdKeviqKvmnXXL0gFW0AcCvBdRa yD3VnH3f6vnNiEUAcn2H24xAPTE0D+j8Rc0pbi0SDepZXcQxTOueynMT7NIJFexhUf64 nQV6M7O9+Id+tzTbZxLczyRLUXEFwkcnZ3htv+2pUjJvTCHl5BhXqEeUfcxKb2Ner87Q OhrKvgQ+B5YyiZ+VDhdX6X3uxkMTI33wsx6QKupJiyCjOsbbuUp7Ije+WPNvEJuUXe6H /gEkYGgVkaZDhphRSAzYagvTslUyZ6r6BoTQn91MInqVZlKZoigeRiH0CdHrKK8q2g98 2K2g== X-Gm-Message-State: ANoB5pmefvQ/4rFZWzVJcQ8KeXMkzDfADv0KNK/fVsiV66yYqdlfW3SA 6ojRVyFbTpPcCRqldhqEU3SE0ufosF/4/BahAUsQ9zdDhCFrWrdgLU98xzVyoHgmbHtRi46g0JO qqjESQlrlWvsDS2/Fp8VOirVP X-Received: by 2002:a1c:5406:0:b0:3d1:e3ba:3bb6 with SMTP id i6-20020a1c5406000000b003d1e3ba3bb6mr9123508wmb.29.1670505365093; Thu, 08 Dec 2022 05:16:05 -0800 (PST) X-Received: by 2002:a1c:5406:0:b0:3d1:e3ba:3bb6 with SMTP id i6-20020a1c5406000000b003d1e3ba3bb6mr9123496wmb.29.1670505364741; Thu, 08 Dec 2022 05:16:04 -0800 (PST) Received: from ?IPV6:2a09:80c0:192:0:5dac:bf3d:c41:c3e7? ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with ESMTPSA id k32-20020a05600c1ca000b003b4ff30e566sm11743772wms.3.2022.12.08.05.16.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Dec 2022 05:16:04 -0800 (PST) Message-ID: <799d6831-2af3-72c1-84b2-1f0454a46c07@redhat.com> Date: Thu, 8 Dec 2022 14:16:03 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH v2 10/10] mm/hugetlb: Document why page_vma_mapped_walk() is safe to walk Content-Language: en-US To: Peter Xu , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Jann Horn , Andrea Arcangeli , James Houghton , Rik van Riel , Miaohe Lin , Nadav Amit , John Hubbard , Mike Kravetz , Andrew Morton , Muchun Song References: <20221207203034.650899-1-peterx@redhat.com> <20221207203158.651092-1-peterx@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20221207203158.651092-1-peterx@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07.12.22 21: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. > + */ > pvmw->pte = hugetlb_walk(vma, pvmw->address, size); > if (!pvmw->pte) > return false; Would it make sense to squash that into the previous commit? -- Thanks, David / dhildenb