From: Peter Zijlstra <peterz@infradead.org>
To: Doug Smythies <dsmythies@telus.net>
Cc: "'Charles Wang'" <muming.wq@gmail.com>,
linux-kernel@vger.kernel.org, "'Ingo Molnar'" <mingo@redhat.com>,
"'Charles Wang'" <muming.wq@taobao.com>, "'Tao Ma'" <tm@tao.ma>,
'含黛' <handai.szj@taobao.com>
Subject: RE: [PATCH] sched: Folding nohz load accounting more accurate
Date: Mon, 18 Jun 2012 12:13:15 +0200 [thread overview]
Message-ID: <1340014395.15222.25.camel@twins> (raw)
In-Reply-To: <000101cd49db$b0d92a20$128b7e60$@net>
On Wed, 2012-06-13 at 20:13 -0700, Doug Smythies wrote:
> ./waiter 2 900 345912 9444
So we're all simply just trying to burn a particular amount of cpu-time?
I have a little consume.c thing lying about doing something like that.
Its independent of clockspeed, but doesn't really like preemption much,
but it more or less works ;-)
---
#include <sys/time.h>
#include <unistd.h>
#include <stdio.h>
unsigned long long stamp(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (unsigned long long)tv.tv_sec * 1000000 + tv.tv_usec;
}
void consume(int spin, int total)
{
unsigned long long begin, now;
begin = stamp();
for (;;) {
now = stamp();
if ((long long)(now - begin) > spin) {
usleep(total - spin);
begin += total;
}
}
}
int main(int argc, char **argv)
{
int period = 100000; /* 100ms */
int frac;
if (argc < 2) {
fprintf(stderr, "%s <frac> [<period>]\n"
" frac -- [1-100] %% of time to burn\n"
" period -- [usec] period of burn/sleep cycle\n",
argv[0]);
return -1;
}
frac = atoi(argv[1]);
if (argc > 2)
period = atoi(argv[2]);
if (frac > 100)
frac = 100;
if (frac < 1)
frac = 1;
consume((period * frac) / 100, period);
return 0;
}
next prev parent reply other threads:[~2012-06-18 10:13 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-09 10:54 Charles Wang
2012-06-11 15:42 ` Peter Zijlstra
[not found] ` <4FD6BFC4.1060302@gmail.com>
2012-06-12 8:54 ` Peter Zijlstra
2012-06-12 9:34 ` Charles Wang
2012-06-12 9:56 ` Peter Zijlstra
2012-06-13 5:55 ` Doug Smythies
2012-06-13 7:56 ` Charles Wang
2012-06-14 4:41 ` Doug Smythies
2012-06-14 15:42 ` Charles Wang
2012-06-16 6:42 ` Doug Smythies
2012-06-13 8:16 ` Peter Zijlstra
2012-06-13 15:33 ` Doug Smythies
2012-06-13 21:57 ` Peter Zijlstra
2012-06-14 3:13 ` Doug Smythies
2012-06-18 10:13 ` Peter Zijlstra [this message]
2012-07-20 19:24 ` sched: care and feeding of load-avg code (Re: [PATCH] sched: Folding nohz load accounting more accurate) Jonathan Nieder
2012-06-15 14:27 ` [PATCH] sched: Folding nohz load accounting more accurate Charles Wang
2012-06-15 17:39 ` Peter Zijlstra
2012-06-16 14:53 ` Doug Smythies
2012-06-18 6:41 ` Doug Smythies
2012-06-18 14:41 ` Charles Wang
2012-06-18 10:06 ` Charles Wang
2012-06-18 16:03 ` Peter Zijlstra
2012-06-19 6:08 ` Yong Zhang
2012-06-19 9:18 ` Peter Zijlstra
2012-06-19 15:50 ` Doug Smythies
2012-06-20 9:45 ` Peter Zijlstra
2012-06-21 4:12 ` Doug Smythies
2012-06-21 6:35 ` Charles Wang
2012-06-21 8:48 ` Peter Zijlstra
2012-06-22 14:03 ` Peter Zijlstra
2012-06-24 21:45 ` Doug Smythies
2012-07-03 16:01 ` Doug Smythies
2012-06-25 2:15 ` Charles Wang
2012-07-06 6:19 ` [tip:sched/core] sched/nohz: Rewrite and fix load-avg computation -- again tip-bot for Peter Zijlstra
2012-06-19 6:19 ` [PATCH] sched: Folding nohz load accounting more accurate Doug Smythies
2012-06-19 6:24 ` Charles Wang
2012-06-19 9:57 ` Peter Zijlstra
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=1340014395.15222.25.camel@twins \
--to=peterz@infradead.org \
--cc=dsmythies@telus.net \
--cc=handai.szj@taobao.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=muming.wq@gmail.com \
--cc=muming.wq@taobao.com \
--cc=tm@tao.ma \
/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
Powered by JetHome