Messages in this thread | | | Date | Thu, 18 Dec 2008 17:28:56 -0500 | From | "C. Scott Ananian" <> | Subject | Re: [RFC PATCH -v4 12/14] fsnotify: add correlations between events |
| |
On Fri, Dec 12, 2008 at 4:52 PM, Eric Paris <eparis@redhat.com> 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/ )
| |