Re: [RFC PATCH -v4 12/14] fsnotify: add correlations between events

From: C. Scott Ananian
Date: Thu Dec 18 2008 - 17:29:14 EST


On Fri, Dec 12, 2008 at 4:52 PM, Eric Paris <eparis@xxxxxxxxxx> wrote:
> inotify sends userspace a correlation between events when they are related
> (aka when dentries are moved). This adds that same support for all
> fsnotify events.
> diff --git a/fs/notify/notification.c b/fs/notify/notification.c
> index 8ed9d32..7243b20 100644
> --- a/fs/notify/notification.c
> +++ b/fs/notify/notification.c
> @@ -34,6 +35,13 @@
>
> static struct kmem_cache *event_kmem_cache;
> static struct kmem_cache *event_holder_kmem_cache;
> +static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
> +
> +u32 fsnotify_get_cookie(void)
> +{
> + return atomic_inc_return(&fsnotify_sync_cookie);
> +}
> +EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
>
> int fsnotify_check_notif_queue(struct fsnotify_group *group)
> {

atomic_inc_return seems rather expensive to put on a hot path in
almost every fs operation. On a multiprocessor system, the cache line
for fsnotify_sync_cookie would be ping-ponging constantly between
processors. The canonical solution is to form the cookie by
concatenating the processor number with a per-processor cookie, so
that generating a new cookie would not require synchronization between
processors. Surely this code already exists to be used somewhere in
Linux.
--scott

--
( http://cscott.net/ )
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/