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 763BDC433FE for ; Wed, 2 Nov 2022 21:17:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DD1818E0003; Wed, 2 Nov 2022 17:17:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D81908E0001; Wed, 2 Nov 2022 17:17:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4A058E0003; Wed, 2 Nov 2022 17:17:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B4AB98E0001 for ; Wed, 2 Nov 2022 17:17:26 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8DD24141369 for ; Wed, 2 Nov 2022 21:17:26 +0000 (UTC) X-FDA: 80089763292.09.5E93660 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf28.hostedemail.com (Postfix) with ESMTP id CD1EBC000A for ; Wed, 2 Nov 2022 21:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667423845; 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=IHTGds9MfIzizVOKWUvyRmvhOQ74hdBvvx9ULgkSqlk=; b=LSP8sABILh6QIdV83IhySaMWwtt77AUim6lJJFxBlNgU71xs77XpF6wVJUpgj42IjJkdij xCGrt/waciz3Ml71M9ZqatJ2gyM8vgOZ8WhBu3+tWUrFHKc9JW5aVw/yj50utr2Q45wfgc rL4Qfe/ZyPGXZwf8yhrLrwBMJQV14pU= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-630-ksEg-RzGOEGuiVVze71YZg-1; Wed, 02 Nov 2022 17:17:24 -0400 X-MC-Unique: ksEg-RzGOEGuiVVze71YZg-1 Received: by mail-qt1-f200.google.com with SMTP id ff5-20020a05622a4d8500b003a526107477so204855qtb.9 for ; Wed, 02 Nov 2022 14:17:24 -0700 (PDT) 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=IHTGds9MfIzizVOKWUvyRmvhOQ74hdBvvx9ULgkSqlk=; b=L3FjbpPWXlnCGIlpMvM0iHqAp7YK28GN2gEXqidrJXAbpoy8tTbpys8SOa8Zote0ez tK++RJ9rEFnNPK8vrjS1RIrmpLRWfU/pokirY7pQOevmSI0L11KUHiq1afALstdh4NUJ oKSuHrThvGQudmTTX3l4GWuIts3WT3870rR/OveUGrdV4gVoZl134r/6XXuN2UawVdVt X8d/ZwbYwLJEY8eWGfWY/tQf8aZGP0vH2wgi/4y2hrJqMyB/673rAcLsVROTKi68TEEd nBeufaLM/PzUWQaW6ko/qjc+8zOwhRzxWA2iSDSI4YoiIErWZiZyTT7qjm+LqiAVQXJe 0ihA== X-Gm-Message-State: ACrzQf32V1CkyEti7181lt7xefnhH0PsTjLES5Zh/InTrCULIHOo91du tDTHhotbDshPBKvOT1D5TgQ7mKUSx1qr0PhNdnR5DMSHW3xhE55SA2rD1tZTBEevn/2W9fiyvrG B9KN40oYvUvA= X-Received: by 2002:a05:620a:17a4:b0:6ee:bf6f:2e3a with SMTP id ay36-20020a05620a17a400b006eebf6f2e3amr19497761qkb.690.1667423843384; Wed, 02 Nov 2022 14:17:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7DXTVoVuZ6bnlwcHndCdDko8cEy6gHXoM/8e0hFqLoiKB6Vl89LbBpxAIz4NOIjKzTfbX+uQ== X-Received: by 2002:a05:620a:17a4:b0:6ee:bf6f:2e3a with SMTP id ay36-20020a05620a17a400b006eebf6f2e3amr19497742qkb.690.1667423843163; Wed, 02 Nov 2022 14:17:23 -0700 (PDT) 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 bp6-20020a05620a458600b006cf9084f7d0sm9177478qkb.4.2022.11.02.14.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 14:17:22 -0700 (PDT) Date: Wed, 2 Nov 2022 17:17:20 -0400 From: Peter Xu To: James Houghton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Miaohe Lin , David Hildenbrand , Muchun Song , Andrea Arcangeli , Nadav Amit , Mike Kravetz , Rik van Riel Subject: Re: [PATCH RFC 04/10] mm/hugetlb: Make userfaultfd_huge_must_wait() RCU-safe Message-ID: References: <20221030212929.335473-1-peterx@redhat.com> <20221030212929.335473-5-peterx@redhat.com> 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667423846; 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=IHTGds9MfIzizVOKWUvyRmvhOQ74hdBvvx9ULgkSqlk=; b=yvrsqdGDLR54EpDQdRdbg7IcyrFi7AxK+1NYsK01USIgxpJb4usuQ3NazGjlz/bsLEId0a gFrcjoBmq4IqKFg29KI28bYjudqXwPxmuqO6u9kSxlh26IO2dpwUOFKbKiWeUNGNVJ2NMa A66w/ApBoT14wEzNgQZ6pZYt0/E7hk8= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LSP8sABI; spf=pass (imf28.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.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=1667423846; a=rsa-sha256; cv=none; b=UQg8av2wrZ1B8ZFoMOUNFqgiHrEMEPgOFqZE0lmEBvrlxGAGQXO+mkQsM0261R3MwBut9c f2VAjo5DCRvx/VIKp6ORpXmfafV0IBIt/sUfXRDxG74L2RDg0ADnB5vW1IhnzLvPC9o0/k C/6b0qnWVkm+BS5OP3kXAsh4RbB2LSY= Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LSP8sABI; spf=pass (imf28.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Stat-Signature: s7ca96j1cw6mc9tsgr645ddcmjp1otqp X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: CD1EBC000A X-HE-Tag: 1667423845-425408 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 Wed, Nov 02, 2022 at 11:06:16AM -0700, James Houghton wrote: > On Sun, Oct 30, 2022 at 2:29 PM Peter Xu wrote: > > > > RCU makes sure the pte_t* won't go away from under us. Please refer to the > > comment above huge_pte_offset() for more information. > > > > Signed-off-by: Peter Xu > > --- > > fs/userfaultfd.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c > > index 07c81ab3fd4d..4e813e68e4f8 100644 > > --- a/fs/userfaultfd.c > > +++ b/fs/userfaultfd.c > > @@ -243,6 +243,9 @@ static inline bool userfaultfd_huge_must_wait(struct userfaultfd_ctx *ctx, > > > > mmap_assert_locked(mm); > > > > + /* For huge_pte_offset() */ > > + rcu_read_lock(); > > userfaultfd_huge_must_wait is called after we set the task's state to > blocking. Is it always safe to call rcu_read_lock (and > rcu_read_unlock) in this case? (With my basic understanding of RCU, > this seems like it should be safe, but I'm not sure.) I'm not aware of an issue here, but please shoot if you have any further concerns or clues, because I'm definitely not a rcu person so I can overlook things. What I remember is my smoke test should be with LOCKDEP, it didn't trigger anything so far I think. -- Peter Xu