Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750855AbZKAEK0 (ORCPT ); Sun, 1 Nov 2009 00:10:26 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750735AbZKAEKZ (ORCPT ); Sun, 1 Nov 2009 00:10:25 -0400 Received: from ns.dcl.info.waseda.ac.jp ([133.9.216.194]:54680 "EHLO ns.dcl.info.waseda.ac.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750695AbZKAEKZ (ORCPT ); Sun, 1 Nov 2009 00:10:25 -0400 Date: Sun, 01 Nov 2009 13:10:27 +0900 (JST) Message-Id: <20091101.131027.680961629714047921.mitake@dcl.info.waseda.ac.jp> To: Ingo Molnar , linux-kernel@vger.kernel.org Subject: [PATCH][RFC] Adding hackbench.c to tools/ From: Hitoshi Mitake X-Mailer: Mew version 5.2 on Emacs 22.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8801 Lines: 388 Hi Ingo, It seems that hackbench is the de-fact standard benchmarking program for scheduler of Linux. But when I ask google where hackbench.c is, some answers are replied. Like these, (in order of google result) http://devresources.linux-foundation.org/craiger/hackbench/ (this page containts link to hackbench.c) http://people.redhat.com/mingo/cfs-scheduler/tools/hackbench.c And it seems that second one is newer. I think this situation is very confusable. So I wrote this patch to add hackbench to tools/ of kernel tree. This may help hackbench users like me. And hackbench this patch contains has little improvements. 1) Output Output is single float value, with out "Time: " string. I believe this is more friendly form for processing by script languages. 2) Option processing I don't like original option processing of hackbench, because it requires -pipe when I want to specify num of groups. I rewrote option processing with getopt_long(). 3) checkpatch.pl friendly Signed-off-by: Hitoshi Mitake diff --git a/tools/hackbench/Makefile b/tools/hackbench/Makefile new file mode 100644 index 0000000..11da1b6 --- /dev/null +++ b/tools/hackbench/Makefile @@ -0,0 +1,3 @@ + +hackbench: hackbench.c + gcc -o hackbench hackbench.c -lpthread -Wall -O2 diff --git a/tools/hackbench/hackbench.c b/tools/hackbench/hackbench.c new file mode 100644 index 0000000..3790d36 --- /dev/null +++ b/tools/hackbench/hackbench.c @@ -0,0 +1,337 @@ +/* + * hackbench.c + * + * Test program for measuring performance of + * scheduler and unix-socket (or pipe). + */ + +/* Test groups of 20 processes spraying to 20 receivers */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define _GNU_SOURCE +#include + +#define DATASIZE 100 +static unsigned int loops = 100; +/* + * 0 means thread mode and others mean process (default) + */ +static unsigned int process_mode = 1; + +static int use_pipes; /* default:0 */ + +struct sender_context { + unsigned int num_fds; + int ready_out; + int wakefd; + int out_fds[0]; +}; + +struct receiver_context { + unsigned int num_packets; + int in_fds[2]; + int ready_out; + int wakefd; +}; + + +static void barf(const char *msg) +{ + fprintf(stderr, "%s (error: %s)\n", msg, strerror(errno)); + exit(1); +} + +static void print_usage_exit(void) +{ + printf("Usage: hackbench