From: Nadia.Derbey@bull.net
To: linux-kernel@vger.kernel.org
Cc: Nadia Derbey <Nadia.Derbey@bull.net>
Subject: [RFC][PATCH 2/6] auto_tuning activation
Date: Tue, 16 Jan 2007 07:15:18 +0100 [thread overview]
Message-ID: <20070116063028.901814000@bull.net> (raw)
In-Reply-To: 20070116061516.899460000@bull.net
[-- Attachment #1: auto_tuning_activation.patch --]
[-- Type: text/plain, Size: 4225 bytes --]
[PATCH 02/06]
Introduces the auto-tuning activation routine
The auto-tuning routine is called by the fork kernel component
Signed-off-by: Nadia Derbey <Nadia.Derbey@bull.net>
---
include/linux/akt.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
kernel/exit.c | 11 +++++++++++
kernel/fork.c | 2 ++
3 files changed, 63 insertions(+)
Index: linux-2.6.20-rc4/include/linux/akt.h
===================================================================
--- linux-2.6.20-rc4.orig/include/linux/akt.h 2007-01-15 14:26:24.000000000 +0100
+++ linux-2.6.20-rc4/include/linux/akt.h 2007-01-15 15:00:31.000000000 +0100
@@ -118,12 +118,22 @@ struct auto_tune {
/*
* Flags for a registered tunable
*/
+#define AUTO_TUNE_ENABLE 0x01
#define TUNABLE_REGISTERED 0x02
/*
* When calling this routine the tunable lock should be held
*/
+static inline int is_auto_tune_enabled(struct auto_tune *tunable)
+{
+ return (tunable->flags & AUTO_TUNE_ENABLE) == AUTO_TUNE_ENABLE;
+}
+
+
+/*
+ * When calling this routine the tunable lock should be held
+ */
static inline int is_tunable_registered(struct auto_tune *tunable)
{
return (tunable->flags & TUNABLE_REGISTERED) == TUNABLE_REGISTERED;
@@ -163,6 +173,44 @@ static inline int is_tunable_registered(
} while (0)
+static inline void set_autotuning_routine(struct auto_tune *tunable,
+ auto_tune_fn fn)
+{
+ if (fn != NULL)
+ tunable->auto_tune = fn;
+}
+
+
+/*
+ * direction may be one of:
+ * AKT_UP: adjust up (i.e. increase tunable value when needed)
+ * AKT_DOWN: adjust down (i.e. decrease tunable value when needed)
+ */
+static inline int activate_auto_tuning(int direction,
+ struct auto_tune *tunable)
+{
+ int ret = 0;
+
+ BUG_ON(direction != AKT_UP && direction != AKT_DOWN);
+
+ if (tunable == NULL)
+ return 0;
+
+ spin_lock(&tunable->tunable_lck);
+
+ if (!is_auto_tune_enabled(tunable) ||
+ !is_tunable_registered(tunable)) {
+ spin_unlock(&tunable->tunable_lck);
+ return 0;
+ }
+
+ ret = tunable->auto_tune(direction, tunable);
+
+ spin_unlock(&tunable->tunable_lck);
+ return ret;
+}
+
+
extern int register_tunable(struct auto_tune *);
extern int unregister_tunable(struct auto_tune *);
@@ -173,7 +221,9 @@ extern int unregister_tunable(struct aut
#define DEFINE_TUNABLE(s, thresh, min, max, tun, chk, type)
#define set_tunable_min_max(s, min, max, type) do { } while (0)
+#define set_autotuning_routine(s, fn) do { } while (0)
+#define activate_auto_tuning(direction, tunable) ( { 0; } )
#define register_tunable(a) 0
#define unregister_tunable(a) 0
Index: linux-2.6.20-rc4/kernel/fork.c
===================================================================
--- linux-2.6.20-rc4.orig/kernel/fork.c 2007-01-15 14:36:48.000000000 +0100
+++ linux-2.6.20-rc4/kernel/fork.c 2007-01-15 14:57:28.000000000 +0100
@@ -995,6 +995,8 @@ static struct task_struct *copy_process(
if ((clone_flags & CLONE_SIGHAND) && !(clone_flags & CLONE_VM))
return ERR_PTR(-EINVAL);
+ activate_auto_tuning(AKT_UP, &max_threads_akt);
+
retval = security_task_create(clone_flags);
if (retval)
goto fork_out;
Index: linux-2.6.20-rc4/kernel/exit.c
===================================================================
--- linux-2.6.20-rc4.orig/kernel/exit.c 2007-01-15 13:08:15.000000000 +0100
+++ linux-2.6.20-rc4/kernel/exit.c 2007-01-15 14:58:23.000000000 +0100
@@ -42,12 +42,15 @@
#include <linux/audit.h> /* for audit_free() */
#include <linux/resource.h>
#include <linux/blkdev.h>
+#include <linux/akt.h>
#include <asm/uaccess.h>
#include <asm/unistd.h>
#include <asm/pgtable.h>
#include <asm/mmu_context.h>
+extern struct auto_tune max_threads_akt;
+
extern void sem_exit (void);
static void exit_mm(struct task_struct * tsk);
@@ -172,6 +175,14 @@ repeat:
sched_exit(p);
write_unlock_irq(&tasklist_lock);
+
+ /*
+ * nr_threads has been decremented in __unhash_process: adjust
+ * max_threads down if needed
+ * We do it here to avoid calling activate_auto_tuning under lock
+ */
+ activate_auto_tuning(AKT_DOWN, &max_threads_akt);
+
proc_flush_task(p);
release_thread(p);
call_rcu(&p->rcu, delayed_put_task_struct);
--
next prev parent reply other threads:[~2007-01-16 6:28 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-16 6:15 [RFC][PATCH 0/6] Automatice kernel tunables (AKT) Nadia.Derbey
2007-01-16 6:15 ` [RFC][PATCH 1/6] Tunable structure and registration routines Nadia.Derbey
2007-01-25 0:32 ` Randy Dunlap
2007-01-25 16:26 ` Nadia Derbey
2007-01-25 16:34 ` Randy Dunlap
2007-01-25 17:01 ` Nadia Derbey
2007-01-16 6:15 ` Nadia.Derbey [this message]
2007-01-16 6:15 ` [RFC][PATCH 3/6] tunables associated kobjects Nadia.Derbey
2007-01-16 6:15 ` [RFC][PATCH 4/6] min and max kobjects Nadia.Derbey
2007-01-24 22:41 ` Randy Dunlap
2007-01-25 16:34 ` Nadia Derbey
2007-01-16 6:15 ` [RFC][PATCH 5/6] per namespace tunables Nadia.Derbey
2007-01-24 22:41 ` Randy Dunlap
2007-01-16 6:15 ` [RFC][PATCH 6/6] automatic tuning applied to some kernel components Nadia.Derbey
2007-01-22 19:56 ` Andrew Morton
2007-01-23 14:40 ` Nadia Derbey
2007-02-07 21:18 ` Eric W. Biederman
2007-02-09 12:27 ` Nadia Derbey
2007-02-09 18:35 ` Eric W. Biederman
2007-02-13 9:06 ` Nadia Derbey
2007-02-13 10:10 ` Eric W. Biederman
2007-02-15 7:07 ` Nadia Derbey
2007-02-15 7:49 ` Eric W. Biederman
2007-02-15 8:25 ` Nadia Derbey
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=20070116063028.901814000@bull.net \
--to=nadia.derbey@bull.net \
--cc=linux-kernel@vger.kernel.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