Re: inotify limits - thousands (tens of thousands?) of watches

From: hooanon05
Date: Wed May 20 2009 - 09:58:40 EST



Marcin Krol:
> I'm not a kernel programmer, but I want to develop a program that would
> watch modifications in *all* user directories on a busy server using
> inotify.
:::
> 1. is it safe? that is, will it not lock the kernel up, or cause
> excessive memory consumption?
>
> 2. is it economic in terms of CPU time and RAM? I have no idea how to
> even measure such a thing happening in the kernel..

The maximum number of inotify instances per user is limited to
/proc/sys/fs/inotify/max_user_instances which is 128 by default.
And also the number of watches per user is limited by
/proc/sys/fs/inotify/max_user_watches (8192 by defaut).
Theoretically you may be able to monitor 8192 directories, but it
consumes memory.

If periodical rsync is out of question for you, how about kprobe?
While I don't think it is a beautiful solution, to set a hook to
vfs_mkdir, vfs_unlink, etc and to compare the target super_block may
work for you.
See Documentation/kprobe.txt in detail.


J. R. Okajima
--
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/