[PATCH 2/2] fdtable: Avoid fdset cacheline ping-pong.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a performance optimization for the fdtable code. When expanding the
fdtable for a task, we want to allocate at least L1_CACHE_BYTES for the new
fdset memory -- this will ensure that the fdsets of two different tasks will
not share the same cacheline, causing lots of cacheline ping-pongs.

Signed-off-by: Vadim Lobanov <[email protected]>

diff -Npru old/fs/file.c new/fs/file.c
--- old/fs/file.c	2006-10-14 15:40:12.000000000 -0700
+++ new/fs/file.c	2006-10-14 15:50:00.000000000 -0700
@@ -178,7 +178,8 @@ static struct fdtable * alloc_fdtable(un
 	if (!data)
 		goto out_fdt;
 	fdt->fd = (struct file **)data;
-	data = alloc_fdmem(2 * nr / BITS_PER_BYTE);
+	data = alloc_fdmem(max_t(unsigned int,
+				 2 * nr / BITS_PER_BYTE, L1_CACHE_BYTES));
 	if (!data)
 		goto out_arr;
 	fdt->open_fds = (fd_set *)data;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux