linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ravikiran G Thirumalai <kiran@scalex86.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>, shai@scalex86.org
Subject: [rfc] [patch 2/2 ] Sysctl to turn on/off private futex hash tables for private futexes
Date: Fri, 20 Mar 2009 21:52:51 -0700	[thread overview]
Message-ID: <20090321045251.GB7278@localdomain> (raw)
In-Reply-To: <20090321044637.GA7278@localdomain>

The following patch introduces a sysctl to control whether process private
hashtable will be used for process private futexes.

Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
Signed-off-by: Shai Fultheim <shai@scalex86.org>

Index: linux-2.6.28.6/include/linux/futex.h
===================================================================
--- linux-2.6.28.6.orig/include/linux/futex.h	2009-03-18 16:59:27.000000000 -0800
+++ linux-2.6.28.6/include/linux/futex.h	2009-03-18 17:49:02.000000000 -0800
@@ -179,6 +179,7 @@ static inline void exit_pi_state_list(st
 
 #ifdef CONFIG_PROCESS_PRIVATE_FUTEX
 extern void free_futex_htb(struct mm_struct *mm);
+extern int sysctl_private_hash;
 #else
 static inline void free_futex_htb(struct mm_struct *mm)
 {
Index: linux-2.6.28.6/kernel/futex.c
===================================================================
--- linux-2.6.28.6.orig/kernel/futex.c	2009-03-18 17:36:04.000000000 -0800
+++ linux-2.6.28.6/kernel/futex.c	2009-03-18 17:57:13.000000000 -0800
@@ -154,14 +154,16 @@ void free_futex_htb(struct mm_struct *mm
 
 static void alloc_htb(struct mm_struct *mm)
 {
-	struct futex_hash_bucket *htb;
 	int i;
+	struct futex_hash_bucket *htb = NULL;
 	/*
 	 * Allocate and install a private hash table of the
 	 * same size as the global hash table.  We fall
-	 * back onto the global hash on allocation failure
+	 * back onto the global hash on allocation failure, or
+	 * if private futexes are disabled.
 	 */
-	htb = kmalloc(sizeof(futex_queues), GFP_KERNEL);
+	if (sysctl_private_hash)
+		htb = kmalloc(sizeof(futex_queues), GFP_KERNEL);
 	if (!htb)
 		htb = futex_queues;
 	else {
@@ -183,6 +185,8 @@ static void alloc_htb(struct mm_struct *
 
 }
 
+int sysctl_private_hash;
+
 static struct futex_hash_bucket *get_futex_hashtable(union futex_key *key)
 {
 	struct mm_struct *mm;
Index: linux-2.6.28.6/kernel/sysctl.c
===================================================================
--- linux-2.6.28.6.orig/kernel/sysctl.c	2009-03-18 16:59:27.000000000 -0800
+++ linux-2.6.28.6/kernel/sysctl.c	2009-03-18 17:49:02.000000000 -0800
@@ -48,6 +48,7 @@
 #include <linux/acpi.h>
 #include <linux/reboot.h>
 #include <linux/ftrace.h>
+#include <linux/futex.h>
 
 #include <asm/uaccess.h>
 #include <asm/processor.h>
@@ -799,6 +800,19 @@ static struct ctl_table kern_table[] = {
 		.strategy	= &sysctl_intvec,
 	},
 #endif
+#ifdef CONFIG_PROCESS_PRIVATE_FUTEX
+	{
+		.ctl_name	= CTL_UNNUMBERED,
+		.procname	= "private_futex_hashtable",
+		.data		= &sysctl_private_hash,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= &proc_dointvec_minmax,
+		.strategy	= &sysctl_intvec,
+		.extra1		= &zero,
+		.extra2		= &one,
+	},
+#endif
 #ifdef CONFIG_COMPAT
 	{
 		.ctl_name	= KERN_COMPAT_LOG,
Index: linux-2.6.28.6/Documentation/sysctl/kernel.txt
===================================================================
--- linux-2.6.28.6.orig/Documentation/sysctl/kernel.txt	2009-02-17 09:29:27.000000000 -0800
+++ linux-2.6.28.6/Documentation/sysctl/kernel.txt	2009-03-20 12:14:15.000000000 -0800
@@ -281,6 +281,25 @@ send before ratelimiting kicks in.
 
 ==============================================================
 
+private_futex_hashtable:
+
+This sysctl can be used to enable processes to use a per-process
+private hash table for private futexes.  Private futexes
+are typically used in threaded workloads.  When this option is
+off, which is the default, threads waiting on futexes get
+hashed onto a global hash table.  On large core count machines
+this turns out to be bad for performance if the workload
+consist of multiple unrelated threaded processes.  Turning
+this option on will enable processes to use a private hash
+for private futexes, improving performance.
+
+Valid options are 0 and 1. A value of 0 turns off process private
+futex hash tables and a value of 1 enables private futex hash
+tables.  This option will only affect processes that get created
+after the option gets changed.
+
+==============================================================
+
 randomize-va-space:
 
 This option can be used to select the type of process address

  reply	other threads:[~2009-03-21  4:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-21  4:46 [rfc] [patch 1/2 ] Process private hash tables for private futexes Ravikiran G Thirumalai
2009-03-21  4:52 ` Ravikiran G Thirumalai [this message]
2009-03-21  9:07 ` Eric Dumazet
2009-03-21 11:55   ` [PATCH] futex: Dynamically size futexes hash table Eric Dumazet
2009-03-21 16:28     ` Ingo Molnar
2009-03-22  4:54   ` [rfc] [patch 1/2 ] Process private hash tables for private futexes Ravikiran G Thirumalai
2009-03-22  8:17     ` Eric Dumazet
2009-03-23 20:28       ` Ravikiran G Thirumalai
2009-03-23 21:57         ` Eric Dumazet
2009-03-24  3:19           ` Ravikiran G Thirumalai
2009-03-24  3:33             ` Ravikiran G Thirumalai
2009-03-24  5:31             ` Eric Dumazet
2009-03-24  7:04           ` Eric Dumazet
2009-04-23 17:30             ` Darren Hart
2009-03-21 11:35 ` Andrew Morton
2009-03-22  4:15   ` Ravikiran G Thirumalai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090321045251.GB7278@localdomain \
    --to=kiran@scalex86.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=shai@scalex86.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).