Re: [PATCH 0/4] Fix ebizzy performance regression due to X86 TLBrange flush v2

From: Mel Gorman
Date: Mon Dec 16 2013 - 06:16:52 EST


On Sun, Dec 15, 2013 at 10:34:25AM -0800, Linus Torvalds wrote:
> On Sun, Dec 15, 2013 at 7:55 AM, Mel Gorman <mgorman@xxxxxxx> wrote:
> >
> > Short answer -- There appears to be a second bug where 3.13-rc3 is less
> > fair to threads getting time on the CPU.
>
> Hmm. Can you point me at the (fixed) microbenchmark you mention?
>

ebizzy is what I was using to see the per-thread performance. It's at
http://sourceforge.net/projects/ebizzy/. It's patched with the patch below
to give per-thread stats.

You probably want to run it manually but FWIW, the results I posted were
using mmtests (https://github.com/gormanm/mmtests) to build, patch,
run ebizzy and generate the report. The configuration file I used was
configs/config-global-dhp__tlbflush-performance. I have not tried a manual
performance analysis yet as an automated bisection is in progress to see
can the thread spread problem be found the easy way.

diff --git a/ebizzy.c b/ebizzy.c
index 76c7492..3e7644f 100644
--- a/ebizzy.c
+++ b/ebizzy.c
@@ -83,7 +83,7 @@ static char **hole_mem;
static unsigned int page_size;
static time_t start_time;
static volatile int threads_go;
-static unsigned int records_read;
+static unsigned int *thread_records_read;

static void
usage(void)
@@ -436,6 +436,7 @@ search_mem(void)
static void *
thread_run(void *arg)
{
+ unsigned int *records = (unsigned int *)arg;

if (verbose > 1)
printf("Thread started\n");
@@ -444,7 +445,7 @@ thread_run(void *arg)

while (threads_go == 0);

- records_read += search_mem();
+ *records = search_mem();

if (verbose > 1)
printf("Thread finished, %f seconds\n",
@@ -471,12 +472,19 @@ start_threads(void)
struct rusage start_ru, end_ru;
struct timeval usr_time, sys_time;
int err;
+ unsigned int total_records = 0;

if (verbose)
printf("Threads starting\n");

+ thread_records_read = calloc(threads, sizeof(unsigned int));
+ if (!thread_records_read) {
+ fprintf(stderr, "Error allocating thread_records_read\n");
+ exit(1);
+ }
+
for (i = 0; i < threads; i++) {
- err = pthread_create(&thread_array[i], NULL, thread_run, NULL);
+ err = pthread_create(&thread_array[i], NULL, thread_run, &thread_records_read[i]);
if (err) {
fprintf(stderr, "Error creating thread %d\n", i);
exit(1);
@@ -505,13 +513,21 @@ start_threads(void)
fprintf(stderr, "Error joining thread %d\n", i);
exit(1);
}
+ total_records += thread_records_read[i];
}

if (verbose)
printf("Threads finished\n");

- printf("%u records/s\n",
- (unsigned int) (((double) records_read)/elapsed));
+ printf("%u records/s",
+ (unsigned int) (((double) total_records)/elapsed));
+
+ for (i = 0; i < threads; i++) {
+ printf(" %u", (unsigned int) (((double) thread_records_read[i])/elapsed));
+ }
+ printf("\n");
+
+ free(thread_records_read);

usr_time = difftimeval(&end_ru.ru_utime, &start_ru.ru_utime);
sys_time = difftimeval(&end_ru.ru_stime, &start_ru.ru_stime);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/