From: Dmitry Safonov <dima@arista.com>
To: Christian Brauner <christian.brauner@ubuntu.com>,
Andrei Vagin <avagin@gmail.com>, Dmitry Safonov <dima@arista.com>,
Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: vdso_join_timens() question
Date: Thu, 11 Jun 2020 20:17:12 +0100 [thread overview]
Message-ID: <97732762-de71-e015-3989-b87d6e5c4dd4@arista.com> (raw)
In-Reply-To: <20200611110221.pgd3r5qkjrjmfqa2@wittgenstein>
Hi Christian,
On 6/11/20 12:02 PM, Christian Brauner wrote:
> Hey,
>
> I'm about to finish a patch to add CLONE_NEWTIME support to setns().
> Since setns() now allows to attach to a multiple namespaces at the same
> time I've also reworked it to be atomic (already upstream). Either all
> namespaces are switched or no namespace is switched. All namespaces
> basically now have a commit mode after which installation should ideally
> not fail anymore. That could work for CLONE_NEWTIME too, I think. The
> only blocker to this is vdso_join_timens() which can fail due to
> mmap_write_lock_killable().
>
> Is it possible to change this to mmap_write_lock()? So sm like:
>
> diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c
> index ea7c1f0b79df..5c5b4cc61fce 100644
> --- a/arch/x86/entry/vdso/vma.c
> +++ b/arch/x86/entry/vdso/vma.c
> @@ -144,8 +144,7 @@ int vdso_join_timens(struct task_struct *task, struct time_namespace *ns)
> struct mm_struct *mm = task->mm;
> struct vm_area_struct *vma;
>
> - if (mmap_write_lock_killable(mm))
> - return -EINTR;
> + mmap_write_lock(mm);
>
> for (vma = mm->mmap; vma; vma = vma->vm_next) {
> unsigned long size = vma->vm_end - vma->vm_start;
I think, it should be fine.
I'm thinking if it actually could be downgraded to mmap_read_lock()..
Probably, write lock was being over-cautious.
> vdso_join_timens() is called in two places. Once during fork() and once
> during timens_install(). I would only need the mmap_write_lock() change
> for the latter. So alternatively we could have:
>
> __vdso_join_timens_unlocked()
>
> and then have/expose:
>
> vdso_join_timens_fork()
> {
> if (mmap_write_lock_killable(mm))
> return -EINTR;
> __vdso_join_timens_unlocked()
> mmap_write_unlock(mm);
> }
>
> and
>
> vdso_join_timens_install()
> {
> mmap_write_lock(mm);
> __vdso_join_timens_unlocked()
> mmap_write_unlock(mm);
> }
I think it's not needed. On fork() it's called on creation of new timens:
: if (nsproxy->time_ns == nsproxy->time_ns_for_children)
: return 0;
So the vdso_join_timens() is called on setns() or on creation of new
namespace, which both are quite heavy operations themselves (in sense of
locking).
Thanks,
Dmitry
next prev parent reply other threads:[~2020-06-11 19:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-11 11:02 Christian Brauner
2020-06-11 19:17 ` Dmitry Safonov [this message]
2020-06-12 14:47 ` Christian Brauner
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=97732762-de71-e015-3989-b87d6e5c4dd4@arista.com \
--to=dima@arista.com \
--cc=avagin@gmail.com \
--cc=christian.brauner@ubuntu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®