Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp69205rdb; Sun, 28 Jan 2024 14:17:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGgEkhP+ByyKQtv/syRrPuSnUttXwU42Bik5VEe3/nKQQUyNkQAcYKKz+j/f+Y1hgLWUDM5 X-Received: by 2002:a17:906:374b:b0:a2f:1cd5:94f1 with SMTP id e11-20020a170906374b00b00a2f1cd594f1mr2979896ejc.67.1706480269497; Sun, 28 Jan 2024 14:17:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706480269; cv=pass; d=google.com; s=arc-20160816; b=dafcumIc8A05ztpI8O2FVmLHyiEPLPLvQF462UbY27zv/TIqZzsVmGMQAGpOMr1E89 Fit21DIDd/wR/VZ75ilT7oQV2T93Svq4doTPfsYuPHC5h5Xd5me036v4Mo+kKJXmMfu9 HDdOdQzFjxz8+Q6zR2X8h396DviQYMZ2t7zMers1tyk+vMdkPR3uDW+6fwyi8GA9P57a B+QzftidYWqJbxL/EJQSIzP6XkEpfUjAT4wQtV1Ahg0H0VCS2/9OyWfGqjgo/+usgVuB 3FVs294I9dvUT5/LAxNey/mq8yvhbDQfETf/NDIZUTsjHOsDZtEkacF6Qb/9ufCauVhZ 2t2g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date; bh=Eet3+E2W+3Ylgg0HQB1GsAZ1ZZjV7To+8EgcH8adQWw=; fh=+NHEOwOI8sgHa/emZ3nIKC4IhKoRFLn6O7wLrfs7tlM=; b=vQK8k5JzJoTxf4Glcb176pBkqRWtt1O8onlgRT/XDPrHoUlY2SM9I0iR9XGODTOmrP maJN3ISGGeUWr5Q33PTYcW4bxmadSsa3DEw6tRXg6j9In3/OU1Ti2OGQQpem8gblLEaf W9JRaDFG6xDlEdSJoOCH5+WWRvVTqKNUl4gqnNYiBMAPeo9+eefD3Ytho3MrIXHndAWv rVN+lV5GLz3vIuJCS4CLZO4mCa9A07MjcFH0IE79rHjiym2NCtdCVJiPu1mH0Fak4DW8 oJ5IRhIh2K75ex7iVnuQJigw8w9vqwXdcMh7Rr+UU/GZq/KqH+zn7qXbWtRzbgprvbbM DqjQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-41982-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41982-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id an15-20020a17090656cf00b00a2a73607836si2689326ejc.1026.2024.01.28.14.17.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 14:17:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41982-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-41982-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41982-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 444C21F225E1 for ; Sun, 28 Jan 2024 22:17:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B6F613C49D; Sun, 28 Jan 2024 22:17:36 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2AEC23C46B; Sun, 28 Jan 2024 22:17:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706480256; cv=none; b=FXhVTl3iFox2q5NaoSi4sVm91Y3sc8sbS0YOgNEk7t4A28ernq0IlN/TAMijuKcU9Zpa0J+OfG674yUCXOheOWkr2W27s/ESB0Y+NGJ0NBP15aHpumPeCkzEX8YP5rq+2uZgVaAPEwU9OgKBkkCYIcqMmTeERZLgerGGhIxjeVM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706480256; c=relaxed/simple; bh=BUSERkOvlG2VoJBGGXoB3teG6OEEWG8bRMj3RwYf988=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=i+RPg/9FwgDC/PzdwV6rG51arrO5ImCTVhp9/6SBLe3IIXYGejEKiyiTrUwHnLT5vyw72/4H6WsX5EWP3ztIecxGeg+U4dN2jEwLx60lNbiN2V1I78OCOeMu3Vbj264/+pOOST83/se5PJO/5c2f5q5P9DXxOTYvZ1vw8NYxObM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A581C433C7; Sun, 28 Jan 2024 22:17:34 +0000 (UTC) Date: Sun, 28 Jan 2024 17:17:33 -0500 From: Steven Rostedt To: Linus Torvalds Cc: Masami Hiramatsu , Mathieu Desnoyers , LKML , Linux Trace Devel , Christian Brauner , Ajay Kaher , Geert Uytterhoeven , linux-fsdevel Subject: Re: [PATCH] eventfs: Have inodes have unique inode numbers Message-ID: <20240128171733.2ba41226@rorschach.local.home> In-Reply-To: References: <20240126150209.367ff402@gandalf.local.home> <20240126162626.31d90da9@gandalf.local.home> <20240128151542.6efa2118@rorschach.local.home> <20240128161935.417d36b3@rorschach.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sun, 28 Jan 2024 14:07:49 -0800 Linus Torvalds wrote: > On Sun, 28 Jan 2024 at 13:43, Linus Torvalds > wrote: > > > > That's just wrong. > > > > Either you look things up under your own locks, in which case the SRCU > > dance is unnecessary and pointless. > > > > Or you use refcounts. > > > > In which case SRCU is also unnecessary and pointless. > > So from what I can see, you actually protect almost everything with > the eventfs_mutex, but the problem is that you then occasionally drop > that mutex in the middle. > > The one valid reason for dropping it is the readdir callback, which > does need to write to user space memory. > > But no, that's not a valid reason to use SRCU. It's a very *bad* > reason to use SRCU. > > The thing is, you can fix it two ways: > > - either refcount things properly, ie when you do that lookup under your lock: > > mutex_lock(&eventfs_mutex); > ei = READ_ONCE(ti->private); > if (ei && ei->is_freed) > ei = NULL; > mutex_unlock(&eventfs_mutex); > > you just go "I now have a ref" to the ei, and you increment the > refcount like you should, and then you dcrement it at the end when > you're done. > > Btw, what's with the READ_ONCE()? You have locking. > > The other option is to simply re-lookup the ei when you re-get the > eventfs_mutext anyway. > > Either of those cases, and the SRCU is entirely pointless. It really > looks wrong, because you seem to take that eventfs_mutex everywhere > anyway. The original code just used the mutex, but then we were hitting deadlocks because we used the mutex in the iput() logic. But this could have been due to the readdir logic causing the deadlocks. A lot of the design decisions were based on doing the dentry creation in the readdir code. Now that it's no longer there, I could go back and try taking the eventfs_mutex for the entirety of the lookup and see if lockdep complains again about also using it in the iput logic. Then yes, we can get rid of the SRCU as that was added as a way to get out of that deadlock. -- Steve