All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Mimi Zohar <zohar@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	". James Morris" <jmorris@namei.org>,
	linux-security-module@vger.kernel.org,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: deferring __fput()
Date: Sat, 23 Jun 2012 10:20:49 +0100	[thread overview]
Message-ID: <20120623092049.GH14083@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1340369098.2464.20.camel@falcor>

On Fri, Jun 22, 2012 at 08:44:58AM -0400, Mimi Zohar wrote:
> Al,
> 
> I really appreciate all of the work that has gone into making __fput()
> lockless - making the syscalls use get/put_light(), signal changes, and
> using Oleg's task_work_add() to defer processes. 
> 
> Currently, when unmapping a file after closing it, I'm not getting the
> mmap_sem/i_mutex lockdep any more.  This seems due to Tyler Hick's
> commit 978d6d8 "vfs: Correctly set the dir i_mutex lockdep class",
> rather than the above changes.
> 
> Although the mmap_sem/i_mutex lockdep doesn't exist anymore, before
> upstreaming IMA-appraisal, the issue with __fput() should probably be
> resolved. :)   What else needs to be done to make __fput() lockless?
> How can I help?

Deadlock is still there.  I'll resurrect the patch switching the final fput()
to task_work_add() and throw it into #for-next tomorrow; the main question is
what to do with fput() from kernel threads and whether we want to allow it
from interrupts - solution for the former (definitely needed) would cover
the latter as well.  I suspect that we want to go for "just use
schedule_work()" for these cases; among other things, that would allow
to simplify aio.c quite a bit.

Somewhat curious part is what to do with daemonize() - by the time we do
(potentially) piles of fput() in there, we *are* a kernel thread.  We won't
be doing any task_work() handling anymore.  So it's "do the final fput()
ourselves" or "have them done asynchronously".  OTOH, daemonize()
probably needs to be killed anyway - it had all callers in mainline
removed, only to get one more in drivers/staging.  Which caller looks like
it ought to be switched to kthread_create(), along with other callers
of kernel_thread() in there...

What I have in mind is something like
	if (unlikely(in_atomic() || current->flags & PF_KTHREAD))
		move file to global list, use schedul_work() to have it dealt with
	else
		move to per-task list, do task_work_add() if it was empty (i.e.
		if we hadn't scheduled its emptying already).
The latter is completely thread-synchronous, so we shouldn't need any locking
whatsoever.  The former... I'd probably go for a single list, protected by
spin_lock_irq(), keeping the possibility to switch to per-CPU lists if we
find a load that gets serious contention on that list.  In any case, worker will
start with taking the list contents, emptying the list and then killing the
suckers off one by one.

  reply	other threads:[~2012-06-23  9:20 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-22 12:44 deferring __fput() Mimi Zohar
2012-06-23  9:20 ` Al Viro [this message]
2012-06-23 19:45   ` Al Viro
2012-06-23 20:38     ` Oleg Nesterov
2012-06-23 21:01       ` Al Viro
2012-06-23 21:11         ` Al Viro
2012-06-24  4:16         ` Al Viro
2012-06-24 10:09           ` Al Viro
2012-06-24 16:54             ` Oleg Nesterov
2012-06-24 15:33           ` Oleg Nesterov
2012-06-25  6:03             ` Al Viro
2012-06-25 15:18               ` Oleg Nesterov
2012-06-27 18:37                 ` [PATCH 0/4] Was: " Oleg Nesterov
2012-06-27 18:37                   ` [PATCH 1/4] task_work: use the single-linked list to shrink sizeof(task_work) Oleg Nesterov
2012-06-27 18:37                   ` [PATCH 2/4] task_work: don't rely on PF_EXITING Oleg Nesterov
2012-06-27 18:38                   ` [PATCH 3/4] task_work: deal with task_work callbacks adding more work Oleg Nesterov
2012-06-27 18:38                   ` [PATCH 4/4] task_work: kill task_work->data Oleg Nesterov
2012-06-27 19:05                     ` Oleg Nesterov
2012-06-28  4:38                   ` [PATCH 0/4] Was: deferring __fput() Al Viro
2012-06-28 16:22                     ` Oleg Nesterov
2012-06-28 16:45                       ` Oleg Nesterov
2012-06-30  6:24                         ` Al Viro
2012-06-30 17:41                           ` Oleg Nesterov
2012-06-29  5:30                     ` Mimi Zohar
2012-06-29  8:33                       ` Al Viro
2012-06-29 13:02                         ` Mimi Zohar
2012-06-29 17:41                           ` Al Viro
2012-06-29 21:38                             ` Mimi Zohar
2012-06-29 23:56                               ` Mimi Zohar
2012-06-30  5:02                                 ` Al Viro
2012-07-01 19:50                                   ` Mimi Zohar
2012-07-01 20:57                                     ` Al Viro
2012-07-02  1:46                                       ` Mimi Zohar
2012-07-02  3:43                                         ` Al Viro
2012-07-02  5:11                                           ` Al Viro
2012-07-02 11:49                                             ` Mimi Zohar
2012-07-02 12:02                                               ` Al Viro
2012-07-02 13:01                                                 ` Mimi Zohar
2012-07-02 13:33                                                   ` Al Viro
2012-07-02 14:50                                                     ` Mimi Zohar
2012-08-21 13:05                                                       ` [PATCH] task_work: add a scheduling point in task_work_run() Eric Dumazet
2012-08-21 20:37                                                         ` Mimi Zohar
2012-08-21 21:32                                                           ` Eric Dumazet
2012-08-22  3:13                                                             ` Mimi Zohar
2012-08-22  5:27                                                         ` Michael Wang
2012-08-22  5:38                                                           ` Al Viro
2012-06-23 20:57     ` deferring __fput() Al Viro
2012-06-23 21:33       ` Al Viro
2012-06-24 15:20       ` Oleg Nesterov
2012-06-24 18:11         ` Oleg Nesterov
2012-06-25 12:03       ` Peter Zijlstra
2012-06-25 12:14         ` Al Viro
2012-06-25 13:19           ` Peter Zijlstra
2012-06-25 13:53             ` Al Viro

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=20120623092049.GH14083@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=zohar@linux.vnet.ibm.com \
    /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.