From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: Lai Jiangshan <laijs@cn.fujitsu.com>, Eric Paris <eparis@parisplace.org>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, Eric Paris <eparis@redhat.com>,
Lino Sanfilippo <LinoSanfilippo@gmx.de>,
Naohiro Aota <naota@elisp.net>, Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH 7/9] fsnotify: use existed call_srcu()
Date: Fri, 05 Apr 2013 15:34:23 +0800 [thread overview]
Message-ID: <515E7E7F.1000606@cn.fujitsu.com> (raw)
In-Reply-To: <1363366257-4886-8-git-send-email-laijs@cn.fujitsu.com>
[Ping]
Hi, Eric Paris
Could you review this patch?
Thanks,
Lai
On 03/16/2013 12:50 AM, Lai Jiangshan wrote:
> fsnotify implements its own call_srcu() by:
> dedicated thread + synchronize_srcu()
>
> But srcu provides call_srcu() now, so we should convert them to use
> existed call_srcu() and remove the thread.
>
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
> Cc: Eric Paris <eparis@parisplace.org>
> ---
> fs/notify/mark.c | 59 ++++++-------------------------------
> include/linux/fsnotify_backend.h | 2 +-
> 2 files changed, 11 insertions(+), 50 deletions(-)
>
> diff --git a/fs/notify/mark.c b/fs/notify/mark.c
> index aeededc..af5f0e1 100644
> --- a/fs/notify/mark.c
> +++ b/fs/notify/mark.c
> @@ -98,9 +98,6 @@
> #include "fsnotify.h"
>
> DEFINE_SRCU(fsnotify_mark_srcu);
> -static DEFINE_SPINLOCK(destroy_lock);
> -static LIST_HEAD(destroy_list);
> -static DECLARE_WAIT_QUEUE_HEAD(destroy_waitq);
>
> void fsnotify_get_mark(struct fsnotify_mark *mark)
> {
> @@ -116,6 +113,14 @@ void fsnotify_put_mark(struct fsnotify_mark *mark)
> }
> }
>
> +static void fsnotify_destroy_mark_rcu(struct rcu_head *rcu)
> +{
> + struct fsnotify_mark *mark;
> +
> + mark = container_of(rcu, struct fsnotify_mark, rcu);
> + fsnotify_put_mark(mark);
> +}
> +
> /*
> * Any time a mark is getting freed we end up here.
> * The caller had better be holding a reference to this mark so we don't actually
> @@ -155,10 +160,7 @@ void fsnotify_destroy_mark_locked(struct fsnotify_mark *mark,
> /* release lock temporarily */
> mutex_unlock(&group->mark_mutex);
>
> - spin_lock(&destroy_lock);
> - list_add(&mark->destroy_list, &destroy_list);
> - spin_unlock(&destroy_lock);
> - wake_up(&destroy_waitq);
> + call_srcu(&fsnotify_mark_srcu, &mark->rcu, fsnotify_destroy_mark_rcu);
> /*
> * We don't necessarily have a ref on mark from caller so the above destroy
> * may have actually freed it, unless this group provides a 'freeing_mark'
> @@ -273,11 +275,7 @@ err:
> atomic_dec(&group->num_marks);
>
> spin_unlock(&mark->lock);
> -
> - spin_lock(&destroy_lock);
> - list_add(&mark->destroy_list, &destroy_list);
> - spin_unlock(&destroy_lock);
> - wake_up(&destroy_waitq);
> + call_srcu(&fsnotify_mark_srcu, &mark->rcu, fsnotify_destroy_mark_rcu);
>
> return ret;
> }
> @@ -342,40 +340,3 @@ void fsnotify_init_mark(struct fsnotify_mark *mark,
> atomic_set(&mark->refcnt, 1);
> mark->free_mark = free_mark;
> }
> -
> -static int fsnotify_mark_destroy(void *ignored)
> -{
> - struct fsnotify_mark *mark, *next;
> - LIST_HEAD(private_destroy_list);
> -
> - for (;;) {
> - spin_lock(&destroy_lock);
> - /* exchange the list head */
> - list_replace_init(&destroy_list, &private_destroy_list);
> - spin_unlock(&destroy_lock);
> -
> - synchronize_srcu(&fsnotify_mark_srcu);
> -
> - list_for_each_entry_safe(mark, next, &private_destroy_list, destroy_list) {
> - list_del_init(&mark->destroy_list);
> - fsnotify_put_mark(mark);
> - }
> -
> - wait_event_interruptible(destroy_waitq, !list_empty(&destroy_list));
> - }
> -
> - return 0;
> -}
> -
> -static int __init fsnotify_mark_init(void)
> -{
> - struct task_struct *thread;
> -
> - thread = kthread_run(fsnotify_mark_destroy, NULL,
> - "fsnotify_mark");
> - if (IS_ERR(thread))
> - panic("unable to start fsnotify mark destruction thread.");
> -
> - return 0;
> -}
> -device_initcall(fsnotify_mark_init);
> diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h
> index d5b0910..3d435eb 100644
> --- a/include/linux/fsnotify_backend.h
> +++ b/include/linux/fsnotify_backend.h
> @@ -296,7 +296,7 @@ struct fsnotify_mark {
> #define FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY 0x08
> #define FSNOTIFY_MARK_FLAG_ALIVE 0x10
> unsigned int flags; /* vfsmount or inode mark? */
> - struct list_head destroy_list;
> + struct rcu_head rcu;
> void (*free_mark)(struct fsnotify_mark *mark); /* called on final put+free */
> };
>
next prev parent reply other threads:[~2013-04-05 7:31 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-15 16:50 [PATCH 0/9 for-3.10] srcu: use-site fix and cleanups Lai Jiangshan
2013-03-15 16:50 ` [PATCH 1/9] powerpc,kvm: fix imbalance srcu_read_[un]lock() Lai Jiangshan
2013-03-15 16:50 ` Lai Jiangshan
2013-03-15 16:50 ` Lai Jiangshan
2013-03-17 21:26 ` Paul Mackerras
2013-03-17 21:26 ` Paul Mackerras
2013-03-17 21:26 ` Paul Mackerras
2013-04-11 21:51 ` Paul E. McKenney
2013-04-11 21:51 ` Paul E. McKenney
2013-04-11 21:51 ` Paul E. McKenney
2013-03-15 16:50 ` [PATCH 2/9] events: use DEFINE_STATIC_SRCU() to define pmus_srcu Lai Jiangshan
2013-03-15 16:50 ` [PATCH 3/9] mmu_notifier: use DEFINE_STATIC_SRCU() to define srcu struct Lai Jiangshan
2013-03-15 16:50 ` Lai Jiangshan
2013-03-15 16:50 ` [PATCH 4/9] netpoll: use DEFINE_STATIC_SRCU() to define netpoll_srcu Lai Jiangshan
2013-03-17 16:43 ` David Miller
2013-03-15 16:50 ` [PATCH 5/9] tomoyo: use DEFINE_SRCU() to define tomoyo_ss Lai Jiangshan
2013-03-15 16:50 ` [PATCH 6/9] fsnotify: use DEFINE_SRCU() for srcu_struct Lai Jiangshan
2013-03-15 16:50 ` [PATCH 7/9] fsnotify: use existed call_srcu() Lai Jiangshan
2013-04-05 7:34 ` Lai Jiangshan [this message]
2013-03-15 16:50 ` [PATCH 8/9] fsnotify: use BUILD_BUG_ON() to test the weight of ALL_FSNOTIFY_EVENTS Lai Jiangshan
2013-03-15 16:50 ` [PATCH 9/9] fsnotify: remove fsnotify_init() Lai Jiangshan
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=515E7E7F.1000606@cn.fujitsu.com \
--to=laijs@cn.fujitsu.com \
--cc=LinoSanfilippo@gmx.de \
--cc=akpm@linux-foundation.org \
--cc=eparis@parisplace.org \
--cc=eparis@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=naota@elisp.net \
--cc=paulmck@linux.vnet.ibm.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.