From: Nicholas Mc Guire <der.herr@hofr.at>
To: linux-rt-users@vger.kernel.org
Cc: LKML <linux-kernel@vger.kernel.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Steven Rostedt <rostedt@goodmis.org>,
Peter Zijlstra <peterz@infradead.org>,
Carsten Emde <C.Emde@osadl.org>,
Thomas Gleixner <tglx@linutronix.de>,
Andreas Platschek <platschek@ict.tuwien.ac.at>
Subject: [PATCH RT 1/5] allow preemption in add_timer_randomness
Date: Mon, 10 Feb 2014 16:37:28 +0100 [thread overview]
Message-ID: <20140210153728.GB20017@opentech.at> (raw)
allow preemption in add_timer_randomness
This patch replaced the preempt_disable by migrate_disable in
add_timer_randomness.
Does this really need even migration protection at all ?
if one would even drop migration protection - what would happen ?
/* if over the trickle threshold, use only 1 in 4096 samples */
if (input_pool.entropy_count > trickle_thresh &&
((__this_cpu_inc_return(trickle_count) - 1) & 0xfff)) {
return;
}
trickle_thresh and input_pool.entropy_count are global, so the only thing
that would happen if this got migrated would be that the 1/4096 could be
a bit less precise locally (the probability of being migrted here is not
very high this is a window of a few instructions at best)
If we got migrated away - so what ? that only would mean that it would be
checking the trickle_count on the "wrong" cpu - in sum the cpus would though
still not contribute more bits, the one countdown wouuld speed up only as
much as some other countdown slowed down.
In any case, even for precise 1/4096 when over threshhold we would not need
more than a migration protection.
patch is against 3.12.10-rt15
Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
---
drivers/char/random.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/char/random.c b/drivers/char/random.c
index ddcbcad..ede5346 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -238,6 +238,7 @@
#include <linux/utsname.h>
#include <linux/module.h>
#include <linux/kernel.h>
+#include <linux/sched.h>
#include <linux/major.h>
#include <linux/string.h>
#include <linux/fcntl.h>
@@ -670,15 +671,15 @@ static void add_timer_randomness(struct timer_rand_state *state, unsigned num)
} sample;
long delta, delta2, delta3;
- preempt_disable();
+ migrate_disable();
/* if over the trickle threshold, use only 1 in 4096 samples */
if (input_pool.entropy_count > trickle_thresh &&
((__this_cpu_inc_return(trickle_count) - 1) & 0xfff)) {
- preempt_enable();
+ migrate_enable();
return;
}
- preempt_enable();
+ migrate_enable();
sample.jiffies = jiffies;
sample.cycles = random_get_entropy();
sample.num = num;
--
1.7.2.5
next reply other threads:[~2014-02-10 15:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-10 15:37 Nicholas Mc Guire [this message]
2014-02-14 12:34 ` [PATCH RT 1/5] allow preemption in add_timer_randomness Sebastian Andrzej Siewior
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=20140210153728.GB20017@opentech.at \
--to=der.herr@hofr.at \
--cc=C.Emde@osadl.org \
--cc=bigeasy@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=platschek@ict.tuwien.ac.at \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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).