All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Eric W. Biederman" <ebiederm@xmission.com>
To: Rik van Riel <riel@surriel.com>
Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com,
	Chris Mason <clm@fb.com>, "Paul E. McKenney" <paulmck@kernel.org>,
	linux-fsdevel@vger.kernel.org,
	Giuseppe Scrivano <gscrivan@redhat.com>,
	Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH][RFC] ipc,fs: use rcu_work to free struct ipc_namespace
Date: Fri, 18 Feb 2022 10:08:05 -0600	[thread overview]
Message-ID: <87iltcf996.fsf@email.froward.int.ebiederm.org> (raw)
In-Reply-To: <20220217153620.4607bc28@imladris.surriel.com> (Rik van Riel's message of "Thu, 17 Feb 2022 15:36:20 -0500")


Maybe I am reading the lifetimes wrong but is there
any chance the code can just do something like the diff below?

AKA have a special version of kern_umount that does the call_rcu?

Looking at rcu_reclaim_tiny I think this use of mnt_rcu is valid.
AKA reusing the rcu_head in the rcu callback.


diff --git a/fs/namespace.c b/fs/namespace.c
index 40b994a29e90..7d7aaef1592e 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -4395,6 +4395,22 @@ void kern_unmount(struct vfsmount *mnt)
 }
 EXPORT_SYMBOL(kern_unmount);
 
+static void rcu_mntput(struct rcu_head *head)
+{
+       struct mount *mnt = container_of(head, struct mount, mnt_rcu);
+       mntput(&mnt->mnt);
+}
+
+void kern_rcu_unmount(struct vfsmount *mnt)
+{
+       /* release long term mount so mount point can be released */
+       if (!IS_ERR_OR_NULL(mnt)) {
+               struct mount *m = real_mount(mnt);
+               m->mnt_ns = NULL;
+               call_rcu(&m->mnt_rcu, rcu_mntput);
+       }
+}
+
 void kern_unmount_array(struct vfsmount *mnt[], unsigned int num)
 {
        unsigned int i;
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 5becca9be867..e54742f82e7d 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -1700,7 +1700,7 @@ void mq_clear_sbinfo(struct ipc_namespace *ns)
 
 void mq_put_mnt(struct ipc_namespace *ns)
 {
-       kern_unmount(ns->mq_mnt);
+       kern_rcu_unmount(ns->mq_mnt);
 }
 
 static int __init init_mqueue_fs(void)

Eric

  parent reply	other threads:[~2022-02-18 16:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-17 20:36 [PATCH][RFC] ipc,fs: use rcu_work to free struct ipc_namespace Rik van Riel
2022-02-17 21:55 ` Paul E. McKenney
2022-02-18  3:29 ` Al Viro
2022-02-18  5:31   ` Paul E. McKenney
2022-02-18 13:01 ` Christian Brauner
2022-02-18 16:08 ` Eric W. Biederman [this message]
2022-02-18 16:41   ` Paul E. McKenney
2022-02-18 16:54   ` Rik van Riel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87iltcf996.fsf@email.froward.int.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=clm@fb.com \
    --cc=gscrivan@redhat.com \
    --cc=kernel-team@fb.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=riel@surriel.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.