All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Stephan Bärwolf" <stephan.baerwolf@tu-ilmenau.de>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] nitro: make multiplier scaleable, change "nitro_hzmultiplicator" into "nitro_hz_permille"
Date: Tue, 28 Feb 2012 11:53:00 +0100	[thread overview]
Message-ID: <4F4CB20C.2000201@tu-ilmenau.de> (raw)
In-Reply-To: <4F4B7CC6.1030307@tu-ilmenau.de>

This patch extends the conventional "nitro_hzmultiplicator" into a permille-base.
So now it is possible also to scale down HZ. (For example half HZ would be possible
with nitro_hz_permille=500, a quarter nitro_hz_permille=250 ...etc...)
As always, jiffies_64 increases with HZ frequency.

The new proc-file is called "nitro_hz_permille"
The new config-option is called "CONFIG_SCHED_NITRO_HZBOOST_PERMILLE"

Signed-off-by: Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
---
 kernel/Kconfig.sched        |   17 +++++++++--------
 kernel/sysctl.c             |   12 ++++++------
 kernel/time/tick-common.c   |   14 +++++++-------
 kernel/time/tick-internal.h |   19 ++++++++++++++-----
 4 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/kernel/Kconfig.sched b/kernel/Kconfig.sched
index 27e5518..a066434 100644
--- a/kernel/Kconfig.sched
+++ b/kernel/Kconfig.sched
@@ -176,23 +176,24 @@ config SCHED_NITRO_HZBOOST_USERSPAC
          accessable from userspace via procfs.
          The responsible file will be called /proc/sys/kernel/nitro_hzmultiplicator

-config SCHED_NITRO_HZBOOST_MULTIPLICATOR
-       int "Multiply the HZ frequency value"
-       range 1 100
-       default 1
+config SCHED_NITRO_HZBOOST_PERMILLE
+       int "Skale the HZ frequency value (per mille)"
+       range 1 100000
+       default 1000
        depends on (SCHED_NITRO_HZBOOST && X86_64 && SCHED_HRTICK)
        help
          Normally the scheduler code (scheduler_tick()) ticks with "HZ" frequency.
          With this frequency also "jiffies_64" is increased and is used by
          timerelated kernelcode.
-         This Option increases the schedulers tickerfrequency by multiplying
-         this multiplicator with HZ. However the jiffies_64 is STILL updated
-         with HZ-frequency and all the jiffy-based timecode is working further on.
+         This Option skales the schedulers tickerfrequency by multiplying
+         this per-mille value with HZ (and divides everything by 1000).
+         However the jiffies_64 is STILL updated with HZ-frequency and all the
+         jiffy-based timecode is working further on.

          Asyncron ns-time-based code will take advantage from this option and
          scheduling will become finer and more interactive.

-         WARNING: !! THIS OPTION WILL INCREASE YOUR "INTERRUPTS PER SECOND" FOR
+         WARNING: !! THIS OPTION MAY INCREASE YOUR "INTERRUPTS PER SECOND" FOR
                      EACH ONLINE CPU. THIS WILL ALSO INCREASE YOUR SYSTEMOVERHEAD !!
 endmenu

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 6c95dfe..f8cec40 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -253,8 +253,8 @@ static struct ctl_table root_table[] = {

 #ifdef CONFIG_SCHED_NITRO_HZBOOST_USERSPAC
 #include "time/tick-internal.h"
-static int min_tick_period_HZmultiplicator = 1;
-static int max_tick_period_HZmultiplicator = 100;
+static int min_tick_period_HZscalepermille = 1;
+static int max_tick_period_HZscalepermille = 100000;
 #endif
 #ifdef CONFIG_SCHED_DEBUG
 static int min_sched_granularity_ns = 100000;          /* 100 usecs */
@@ -280,13 +280,13 @@ static struct ctl_table kern_table[] = {
        },
 #ifdef CONFIG_SCHED_NITRO_HZBOOST_USERSPAC
        {
-               .procname       = "nitro_hzmultiplicator",
-               .data           = &sysctl_tick_period_HZmultiplicator,
+               .procname       = "nitro_hz_permille",
+               .data           = &sysctl_tick_period_HZscalepermille,
                .maxlen         = sizeof(unsigned int),
                .mode           = 0644,
                .proc_handler   = tick_change_periodmultiplicator_handler,
-               .extra1         = &min_tick_period_HZmultiplicator,
-               .extra2         = &max_tick_period_HZmultiplicator,
+               .extra1         = &min_tick_period_HZscalepermille,
+               .extra2         = &max_tick_period_HZscalepermille,
        },
 #endif
 #ifdef CONFIG_SCHED_DEBUG
diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
index 1c62de8..a0176e245 100644
--- a/kernel/time/tick-common.c
+++ b/kernel/time/tick-common.c
@@ -170,7 +170,7 @@ static void tick_setup_device(struct tick_device *td,
                        tick_next_period = ktime_get();
 #ifdef CONFIG_SCHED_NITRO_HZBOOST
                        tick_HZbaseperiod = ktime_set(0, NSEC_PER_SEC / HZ);
-                       tick_change_periodmultiplicator(CONFIG_SCHED_NITRO_HZBOOST_MULTIPLICATOR);
+                       tick_change_periodmultiplicator(CONFIG_SCHED_NITRO_HZBOOST_PERMILLE);
 #else
                        tick_period = ktime_set(0, NSEC_PER_SEC / HZ);
 #endif
@@ -427,8 +427,8 @@ void __init tick_init(void)
 }

 #ifdef CONFIG_SCHED_NITRO_HZBOOST_USERSPAC
-unsigned int sysctl_tick_period_HZmultiplicator        = ((unsigned long)CONFIG_SCHED_NITRO_HZBOOST_MULTIPLICATOR);
-static unsigned int __last_HZmultiplicator     = ((unsigned long)CONFIG_SCHED_NITRO_HZBOOST_MULTIPLICATOR);
+unsigned int sysctl_tick_period_HZscalepermille        = ((unsigned long)CONFIG_SCHED_NITRO_HZBOOST_PERMILLE);
+static unsigned int __last_HZscalepermille     = ((unsigned long)CONFIG_SCHED_NITRO_HZBOOST_PERMILLE);

 int tick_change_periodmultiplicator_handler(struct ctl_table *table, int write,
                                            void __user *buffer, size_t *lenp,
@@ -439,11 +439,11 @@ int tick_change_periodmultiplicator_handler(struct ctl_table *table, int write,
        if (ret || !write)
                return ret;

-       if (sysctl_tick_period_HZmultiplicator > 0)
-         if (__last_HZmultiplicator != sysctl_tick_period_HZmultiplicator) {
+       if (sysctl_tick_period_HZscalepermille > 0)
+         if (__last_HZscalepermille != sysctl_tick_period_HZscalepermille) {
            write_seqlock(&xtime_lock);
-           tick_change_periodmultiplicator(sysctl_tick_period_HZmultiplicator);
-           __last_HZmultiplicator = sysctl_tick_period_HZmultiplicator;
+           tick_change_periodmultiplicator(sysctl_tick_period_HZscalepermille);
+           __last_HZscalepermille = sysctl_tick_period_HZscalepermille;
            write_sequnlock(&xtime_lock);
          }

diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h
index eb60d32..26a1bda 100644
--- a/kernel/time/tick-internal.h
+++ b/kernel/time/tick-internal.h
@@ -17,19 +17,28 @@ extern int tick_do_timer_cpu __read_mostly;
 #ifdef CONFIG_SCHED_NITRO_HZBOOST
 extern ktime_t tick_HZbaseperiod;
 #ifdef CONFIG_SCHED_NITRO_HZBOOST_USERSPAC
-extern unsigned int sysctl_tick_period_HZmultiplicator;
+extern unsigned int sysctl_tick_period_HZscalepermille;
 extern int tick_change_periodmultiplicator_handler(struct ctl_table *table, int write,
                                            void __user *buffer, size_t *lenp,
                                            loff_t *ppos);
 #endif
 /*
  * proper locking has to be taken care outside
+ *
+ * scalepermille better be not zero!
+ *
  */
-static inline void tick_change_periodmultiplicator(const unsigned long long multiplicator)
+static inline void tick_change_periodmultiplicator(const unsigned long long scalepermille)
 {
-  printk( KERN_NOTICE "changing nitro hzboost multiplicator, new frequency: %llu x %lluHz\n", multiplicator, (unsigned long long)HZ);
-  tick_period = ktime_set(0, NSEC_PER_SEC / (HZ*multiplicator));
-  printk( KERN_NOTICE "scheduler nitro-patchset v1.0 Ilmenau 2012, by Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>\n");
+  unsigned long long __nanoseconds = (((unsigned long long)NSEC_PER_SEC) * 1000ULL) / scalepermille;
+  unsigned int i,j;
+
+  i = scalepermille / 1000;
+  j = scalepermille % 1000;
+
+  printk( KERN_NOTICE "changing nitro hzboost multiplicator, new frequency: %u.%03u x %lluHz\n", i, j, (unsigned long long)HZ);
+  tick_period = ktime_set(0, __nanoseconds / ((unsigned long long)HZ));
+  printk( KERN_NOTICE "scheduler nitro-patchset v1.0.1 Ilmenau 2012, by Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>\n");
 }
 #endif

-- 
1.7.3.4


      reply	other threads:[~2012-02-28 10:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-27 12:53 [PATCH 00/10] scheduler-ticker > 1000Hz, nitromethane for linux ;-) Stephan Bärwolf
2012-02-28 10:53 ` Stephan Bärwolf [this message]

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=4F4CB20C.2000201@tu-ilmenau.de \
    --to=stephan.baerwolf@tu-ilmenau.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.