From: Oleg Nesterov <oleg@redhat.com>
To: Andrey Wagin <avagin@gmail.com>, Al Viro <viro@zeniv.linux.org.uk>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
LKML <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
David Howells <dhowells@redhat.com>
Subject: Re: [PATCH 1/1] move exit_task_namespaces() outside of exit_notify()
Date: Mon, 15 Apr 2013 17:33:07 +0200 [thread overview]
Message-ID: <20130415153307.GA15817@redhat.com> (raw)
In-Reply-To: <CANaxB-wb3h9zb1C38W=pSjg_sf4RiRbpUHRU2pKppohmDy5Dtg@mail.gmail.com>
On 04/15, Andrey Wagin wrote:
>
> It looks good for me. I have tested it a bit and don't find any problem.
> Oleg, thank you.
>
> Acked-by: Andrew Vagin <avagin@gmail.com>
Thanks Andrey and Eric.
> > --- x/kernel/exit.c
> > +++ x/kernel/exit.c
> > @@ -649,7 +649,6 @@ static void exit_notify(struct task_stru
> > * jobs, send them a SIGHUP and then a SIGCONT. (POSIX 3.2.2.2)
> > */
> > forget_original_parent(tsk);
> > - exit_task_namespaces(tsk);
> >
> > write_lock_irq(&tasklist_lock);
> > if (group_dead)
> > @@ -795,6 +794,7 @@ void do_exit(long code)
> > exit_shm(tsk);
> > exit_files(tsk);
> > exit_fs(tsk);
> > + exit_task_namespaces(tsk);
> > exit_task_work(tsk);
I do not see any problems with this patch too... but still I am worried.
Even if fput() can work correctly after exit_task_namespaces(), this limits
the usage of task_work_add(). Probably this is fine, but can't we at least
discuss another change?
We can change fput() so that it can always work, even after exit_task_work(),
void fput(struct file *file)
{
if (atomic_long_dec_and_test(&file->f_count)) {
struct task_struct *task = current;
unsigned long flags;
file_sb_list_del(file);
if (likely(!in_interrupt() && !(task->flags & PF_KTHREAD))) {
init_task_work(&file->f_u.fu_rcuhead, ____fput);
if (!task_work_add(task, &file->f_u.fu_rcuhead, true))
return;
}
spin_lock_irqsave(&delayed_fput_lock, flags);
list_add(&file->f_u.fu_list, &delayed_fput_list);
schedule_work(&delayed_fput_work);
spin_unlock_irqrestore(&delayed_fput_lock, flags);
}
}
Al, what do you think?
Untested patch below.
Oleg.
--- x/fs/file_table.c
+++ x/fs/file_table.c
@@ -306,17 +306,19 @@ void fput(struct file *file)
{
if (atomic_long_dec_and_test(&file->f_count)) {
struct task_struct *task = current;
+ unsigned long flags;
+
file_sb_list_del(file);
- if (unlikely(in_interrupt() || task->flags & PF_KTHREAD)) {
- unsigned long flags;
- spin_lock_irqsave(&delayed_fput_lock, flags);
- list_add(&file->f_u.fu_list, &delayed_fput_list);
- schedule_work(&delayed_fput_work);
- spin_unlock_irqrestore(&delayed_fput_lock, flags);
- return;
+ if (likely(!in_interrupt() && !(task->flags & PF_KTHREAD))) {
+ init_task_work(&file->f_u.fu_rcuhead, ____fput);
+ if (!task_work_add(task, &file->f_u.fu_rcuhead, true))
+ return;
}
- init_task_work(&file->f_u.fu_rcuhead, ____fput);
- task_work_add(task, &file->f_u.fu_rcuhead, true);
+
+ spin_lock_irqsave(&delayed_fput_lock, flags);
+ list_add(&file->f_u.fu_list, &delayed_fput_list);
+ schedule_work(&delayed_fput_work);
+ spin_unlock_irqrestore(&delayed_fput_lock, flags);
}
}
next prev parent reply other threads:[~2013-04-15 15:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-12 19:27 [PATCH] kernel: move exit_task_work() past exit_notify() Andrey Vagin
2013-04-13 14:22 ` Oleg Nesterov
2013-04-13 15:54 ` [PATCH 0/1] (Was: kernel: move exit_task_work() past exit_notify()) Oleg Nesterov
2013-04-13 15:55 ` [PATCH 1/1] move exit_task_namespaces() outside of exit_notify() Oleg Nesterov
2013-04-14 1:52 ` Eric W. Biederman
2013-04-15 9:57 ` Andrey Wagin
2013-04-15 15:33 ` Oleg Nesterov [this message]
2013-06-13 9:24 ` Andrew Vagin
2013-06-14 13:19 ` Oleg Nesterov
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=20130415153307.GA15817@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=avagin@gmail.com \
--cc=dhowells@redhat.com \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--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.