Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] inotify speedup

Bypass an inotify-related fastpath spinlock and several function calls on
systems which have no inotify watches registered.

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

John McCutchan and committed by
Linus Torvalds
820249ba 19306059

+7
+7
fs/inotify.c
··· 37 37 #include <asm/ioctls.h> 38 38 39 39 static atomic_t inotify_cookie; 40 + static atomic_t inotify_watches; 40 41 41 42 static kmem_cache_t *watch_cachep; 42 43 static kmem_cache_t *event_cachep; ··· 423 422 get_inotify_watch(watch); 424 423 425 424 atomic_inc(&dev->user->inotify_watches); 425 + atomic_inc(&inotify_watches); 426 426 427 427 return watch; 428 428 } ··· 456 454 list_del(&watch->d_list); 457 455 458 456 atomic_dec(&dev->user->inotify_watches); 457 + atomic_dec(&inotify_watches); 459 458 idr_remove(&dev->idr, watch->wd); 460 459 put_inotify_watch(watch); 461 460 } ··· 534 531 { 535 532 struct dentry *parent; 536 533 struct inode *inode; 534 + 535 + if (!atomic_read (&inotify_watches)) 536 + return; 537 537 538 538 spin_lock(&dentry->d_lock); 539 539 parent = dentry->d_parent; ··· 1049 1043 inotify_max_user_watches = 8192; 1050 1044 1051 1045 atomic_set(&inotify_cookie, 0); 1046 + atomic_set(&inotify_watches, 0); 1052 1047 1053 1048 watch_cachep = kmem_cache_create("inotify_watch_cache", 1054 1049 sizeof(struct inotify_watch),