lkml.org 
[lkml]   [2012]   [Feb]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 0/2] More i387 state save/restore work
On Sun, Feb 19, 2012 at 4:53 PM, Michael Neuling <mikey@neuling.org> wrote:
>
> Does "2476844 loops in 2 seconds" imply 2476844 context switches in 2
> sec?  With Anton's context_switch [1] benchmark, we don't even hit 100K
> context switches per sec.
>
> Do you have this test program anywhere?

Here. No guarantees that this is at all sane, it's special-cased code
literally for testing only this one issue. The only indication I have
that this works at all is that the numbers did change roughly as
expected, and the kernel profile changes made sense.

You may have to do something else than just do some FP calculation to
force it to use VSX on PPC, obviously.

Linus
---
[torvalds@i5 ~]$ cat fp-switch.c
#define _GNU_SOURCE
#include <sched.h>
#include <stdlib.h>

#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <sys/time.h>

#define SECONDS (2)
unsigned long loops = 0, child;

static void use_math(void)
{
double x = 0;
asm volatile("":"+m" (x));
x += 1;
asm volatile("":"+m" (x));
}

static void end(int signr)
{
printf("%d loops in %d seconds\n", loops, SECONDS);
kill(child, SIGKILL);
exit(0);
}

int main(int argc, char **argv)
{
cpu_set_t cpuset;

CPU_ZERO(&cpuset);
CPU_SET(0, &cpuset);

sched_setaffinity(0, sizeof(cpu_set_t), &cpuset);

child = fork();
if (!child) {
for (;;)
sched_yield();
}

signal(SIGALRM, end);
alarm(SECONDS);

for (;;) {
use_math();
sched_yield();
loops++;
}
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2012-02-20 02:07    [W:0.466 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site