]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
epoll: comment + BUILD_BUG_ON to prevent epitem bloat
authorEric Wong <normalperson@yhbt.net>
Wed, 20 Mar 2013 04:07:47 +0000 (15:07 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 20 Mar 2013 04:23:02 +0000 (15:23 +1100)
This will prevent us from accidentally introducing a memory bloat
regression here in the future.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Cc: Davide Libenzi <davidel@xmailserver.org>,
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/eventpoll.c

index 5cc010aa2e95f7252111e6bc5bad19d105538531..c30b016598a1ca1ef14c12f1151a7a11b657bfc0 100644 (file)
@@ -129,6 +129,8 @@ struct nested_calls {
 /*
  * Each file descriptor added to the eventpoll interface will
  * have an entry of this type linked to the "rbr" RB tree.
+ * Avoid increasing the size of this struct, there can be many thousands
+ * of these on a server and we do not want this to take another cache line.
  */
 struct epitem {
        /* RB tree node used to link this structure to the eventpoll RB tree */
@@ -2011,6 +2013,12 @@ static int __init eventpoll_init(void)
        /* Initialize the structure used to perform file's f_op->poll() calls */
        ep_nested_calls_init(&poll_readywalk_ncalls);
 
+       /*
+        * We can have many thousands of epitems, so prevent this from
+        * using an extra cache line on 64-bit (and smaller) CPUs
+        */
+       BUILD_BUG_ON(sizeof(void *) <= 8 && sizeof(struct epitem) > 128);
+
        /* Allocates slab cache used to allocate "struct epitem" items */
        epi_cache = kmem_cache_create("eventpoll_epi", sizeof(struct epitem),
                        0, SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL);