* [RFC]: do_xor_speed Broken on UML do to jiffies
@ 2011-10-11 0:13 Boaz Harrosh
0 siblings, 0 replies; only message in thread
From: Boaz Harrosh @ 2011-10-11 0:13 UTC (permalink / raw)
To: Dan Williams, Herbert Xu, David S. Miller,
Linux Crypto Mailing List, l
Remember that hang I reported a while back on UML. Well
I'm at it again, and it still hangs and I found why.
I have dprinted jiffies and it never advances during the
loop at do_xor_speed. Therefor it is stuck in an endless
loop. I have also dprinted current_kernel_time() and it
returns the same constant value as well.
Note that it does usually work on UML, only during
the modprobe of xor.ko while that test is running, it is broken.
It looks like some lucking is preventing the clock from ticking.
However ktime_get_ts does work for me so I changed the code
as below, so I can work. See how I put several safety
guards, to never get hangs again.
And I think my time based approach is more accurate then
previous system.
UML guys please investigate the jiffies issue? what is
xor.ko not doing right?
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
---
crypto/xor.c | 46 +++++++++++++++++++++++++++-------------------
1 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/crypto/xor.c b/crypto/xor.c
index b75182d..65433f5 100644
--- a/crypto/xor.c
+++ b/crypto/xor.c
@@ -62,37 +62,45 @@ static struct xor_block_template *template_list;
static void
do_xor_speed(struct xor_block_template *tmpl, void *b1, void *b2)
{
- int speed;
- unsigned long now;
- int i, count, max;
+ unsigned speed, count;
+ u64 ns_begin;
+ u64 ns_end;
+ struct timespec ts;
+
tmpl->next = template_list;
template_list = tmpl;
/*
- * Count the number of XORs done during a whole jiffy, and use
+ * Count the number of XORs done during 10 miliseconds, and use
* this to calculate the speed of checksumming. We use a 2-page
* allocation to have guaranteed color L1-cache layout.
*/
- max = 0;
- for (i = 0; i < 5; i++) {
- now = jiffies;
- count = 0;
- while (jiffies == now) {
- mb(); /* prevent loop optimzation */
- tmpl->do_2(BENCH_SIZE, b1, b2);
- mb();
- count++;
- mb();
- }
- if (count > max)
- max = count;
+ ktime_get_ts(&ts);
+ ns_begin = timespec_to_ns(&ts);
+ count = 0;
+ while (count < 4000000L) {
+ mb(); /* prevent loop optimzation */
+ tmpl->do_2(BENCH_SIZE, b1, b2);
+ mb();
+ count++;
+ mb();
+
+ ktime_get_ts(&ts);
+ ns_end = timespec_to_ns(&ts);
+ /* Test for 10 miliseconds */
+ if ((ns_end - ns_begin) > NSEC_PER_SEC / 100)
+ break;
}
- speed = max * (HZ * BENCH_SIZE / 1024);
+ ns_end -= ns_begin;
+ if (ns_end > 0)
+ speed = BENCH_SIZE / 1024 * count * NSEC_PER_SEC / ns_end;
+ else
+ speed = 17;
tmpl->speed = speed;
- printk(KERN_INFO " %-10s: %5d.%03d MB/sec\n", tmpl->name,
+ printk(KERN_INFO " %-10s: %5u.%03u MB/sec\n", tmpl->name,
speed / 1000, speed % 1000);
}
--
1.7.2.3
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2011-10-11 0:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-11 0:13 [RFC]: do_xor_speed Broken on UML do to jiffies Boaz Harrosh
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).