From: Davide Libenzi <davidel@xmail.virusscreen.com>
To: Andrea Arcangeli <andrea@suse.de>, Mike Kravetz <mkravetz@sequent.com>
Cc: lse-tech@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [Lse-tech] Re: multi-queue scheduler update
Date: Thu, 18 Jan 2001 17:39:45 -0800 [thread overview]
Message-ID: <01011817394501.01413@ewok.dev.mycio.com> (raw)
In-Reply-To: <20010118155311.B8637@w-mikek.des.sequent.com> <20010118165225.E8637@w-mikek.des.sequent.com> <20010119023041.F32087@athlon.random>
In-Reply-To: <20010119023041.F32087@athlon.random>
On Thursday 18 January 2001 17:39, Andrea Arcangeli wrote:
> On Thu, Jan 18, 2001 at 04:52:25PM -0800, Mike Kravetz wrote:
> > was less than the number of processors. I'll give the tests a try
> > with a smaller number of threads. I'm also open to suggestions for
>
> OK!
>
> > what benchmarks/test methods I could use for scheduler testing. If
> > you remember what people have used in the past, please let me know.
>
> It was this one IIRC (it spawns threads calling sched_yield() in loop).
>
> /*
> Tester for the kernel's speed in scheduling.
> (C) 1999 / Willy Tarreau <willy@meta-x.org>
>
> Modified by Davide Libenzi <davidel@maticad.it>
>
>
> You can do whatever you want with this program, but I'm not
> responsible for any misuse. Be aware that it can heavily load
> a host. As it is multithreaded, it might take advantages of SMP.
>
> It basically creates a growing amount of threads and measures
> their cumulative work (i.e. loop iterations/second). The output
> is easily useable by gnuplot.
>
> To compile, you need libpthread :
>
> gcc -O2 -fomit-frame-pointer -o threads threads.c -lpthread
>
> Output on stdout is :
> <nb_threads> <average_work> <zero_work_threads> <std_deviation>
>
> */
>
> #include <stdio.h>
> #include <pthread.h>
> #include <signal.h>
> #include <unistd.h>
> #include <time.h>
>
>
>
> #define MAXTHREADS 450
> #define MEASURE_TIME 60
>
>
>
> pthread_t thr[MAXTHREADS];
> int nbthreads = MAXTHREADS;
> int measure_time = MEASURE_TIME;
> volatile actthreads = 0;
>
> long long int totalwork[MAXTHREADS];
> volatile int stop = 0,
> start = 0,
> count = 0;
>
> void oneatwork(int thr)
> {
> int i;
> while (!start) /* don't disturb pthread_create() */
> usleep(10000);
>
> actthreads++;
> while (!stop)
> {
> if (count)
> totalwork[thr]++;
>
> syscall(158); /* sys_sched_yield() */
> }
> actthreads--;
> pthread_exit(0);
> }
>
> main(int argc, char **argv)
> {
>
> int i,
> err,
> avgwork,
> thrzero;
> long long int value,
> avgvalue;
> double sqrdev;
> time_t ts,
> te;
>
> if (argc < 3)
> {
> printf("usage: %s threads time\n", argv[0]);
> exit(1);
> }
>
> nbthreads = atoi(argv[1]);
> measure_time = atoi(argv[2]);
>
>
> start = 0;
> count = 0;
> stop = 0;
> actthreads = 0;
> thrzero = 0;
> value = 0;
> sqrdev = 0.0;
>
> fprintf(stderr, "\nCreating %d threads ...", nbthreads);
> for (i = 0; i < nbthreads; i++)
> {
> if ((err = pthread_create(&thr[i], NULL, (void *) &oneatwork, (void
> *) i)) != 0) {
> fprintf(stderr, "thread %d pthread_create=%d -> ", i, err);
> perror("");
> exit(1);
> }
> pthread_detach(thr[i]);
> }
>
> for (i = 0; i < nbthreads; i++)
> totalwork[i] = 0;
>
> fprintf(stderr, " OK !\nWaiting for all threads to start ...");
>
> start = 1;
> while (actthreads != nbthreads)
> usleep(10000); /* waiting for a bit of stability */
>
> fprintf(stderr, "Go !\n");
>
> count = 1;
> time(&ts);
>
> sleep(measure_time);
>
> count = 0;
> stop = 1;
> time(&te);
>
>
> for (i = 0; i < nbthreads; i++)
> {
> value += totalwork[i];
> if (totalwork[i] == 0)
> ++thrzero;
> }
> avgvalue = value / nbthreads;
> value /= (int) difftime(te, ts);
> avgwork = (int) (value / nbthreads);
>
> for (i = 0; i < nbthreads; i++)
> {
> double difvv = (double) (totalwork[i] - avgvalue);
>
> sqrdev += difvv * difvv;
> }
>
> while (actthreads > 0)
> usleep(10000);
>
> printf("%d\t\t%lld\t\t%d\t\t%d\t\t%f\n", nbthreads, value, avgwork,
> thrzero, sqrdev / ((double) nbthreads * avgvalue * avgvalue));
>
> exit(0);
>
> }
>
Andrea found it before me :)
- Davide
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2001-01-19 1:39 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-01-18 23:53 multi-queue scheduler update Mike Kravetz
2001-01-19 0:26 ` Andrea Arcangeli
2001-01-19 0:51 ` [Lse-tech] " Andi Kleen
2001-01-19 1:14 ` John Clemens
2001-01-19 0:52 ` [Lse-tech] " Mike Kravetz
2001-01-19 1:30 ` Andrea Arcangeli
2001-01-19 1:34 ` Mike Kravetz
2001-01-19 20:49 ` Mike Kravetz
2001-01-19 21:51 ` Mike Kravetz
2001-01-19 22:03 ` Davide Libenzi
2001-01-19 22:18 ` Mike Kravetz
2001-01-19 23:24 ` Davide Libenzi
2001-01-19 1:39 ` Davide Libenzi [this message]
2001-01-19 16:06 ` David Lang
2001-01-19 1:00 ` Mark Hahn
2001-01-19 1:08 ` Andi Kleen
2001-01-19 1:23 ` Mike Kravetz
2001-01-19 1:38 ` Davide Libenzi
2001-01-19 1:35 ` Andrea Arcangeli
2001-01-19 1:48 ` Andi Kleen
2001-01-19 23:35 ` Mike Kravetz
2001-01-19 0:43 ` Gerhard Mack
2001-01-23 16:49 ` [Lse-tech] " Jun Nakajima
[not found] ` <LYR76657-1923-2001.01.23-08.54.49--mikek#sequent.com@lyris.sequent.com>
2001-01-23 17:08 ` Mike Kravetz
-- strict thread matches above, loose matches on Subject: below --
2001-01-19 15:47 [Lse-tech] " Hubertus Franke
2001-01-19 17:11 ` Mike Kravetz
[not found] ` <LYR76657-5332-2001.01.19-12.12.38--mikek#sequent.com@lyris.sequent.com>
2001-01-19 20:32 ` Mike Kravetz
2001-01-19 16:30 Hubertus Franke
2001-01-19 16:33 ` nick
2001-01-19 17:06 ` Tim Wright
2001-01-19 16:47 Hubertus Franke
2001-01-19 18:03 Hubertus Franke
2001-01-19 19:52 ` bert hubert
2001-01-22 13:35 Hubertus Franke
2001-01-22 16:58 ` Davide Libenzi
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=01011817394501.01413@ewok.dev.mycio.com \
--to=davidel@xmail.virusscreen.com \
--cc=andrea@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=lse-tech@lists.sourceforge.net \
--cc=mkravetz@sequent.com \
/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