Changeset d22e567 in mainline


Ignore:
Timestamp:
2012-12-04T21:11:02Z (11 years ago)
Author:
Adam Hraska <adam.hraska+hos@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6a585dd
Parents:
f74ec77
Message:

rcubench: Replaced futex contention benchmark with futex syscall benchmark.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/rcubench/rcubench.c

    rf74ec77 rd22e567  
    6767
    6868
    69 /* Combats compiler optimizations. */
    70 static volatile size_t dummy = 0;
    71 
    72 static size_t sum_array(size_t *array, size_t len)
    73 {
    74         size_t sum = 0;
    75        
    76         for (size_t k = 0; k < len; ++k)
    77                 sum += array[k];
    78        
    79         return sum;
    80 }
    8169
    8270
    8371static void  kernel_futex_bench(bench_t *bench)
    8472{
    85         futex_t * const fut = &bench->bench_fut;
    8673        const size_t iters = bench->iters;
    87         size_t sum = 0;
    8874       
    8975        for (size_t i = 0; i < iters; ++i) {
    90                 /* Do some work with the futex locked to encourage contention. */
    91                 futex_down(fut);
    92                 sum += sum_array(bench->array, bench->array_size);
    93                 futex_up(fut);
    94                
    95                 /*
    96                  * Do half as much work to give other threads a chance to acquire
    97                  * the futex.
    98                  */
    99                 sum += sum_array(bench->array, bench->array_size / 2);
    100         }
    101        
    102         /*
    103          * Writing to a global volatile variable separated with a cc-barrier
    104          * should discourage the compiler from optimizing away sum_array()s.
    105          */
    106         compiler_barrier();
    107         dummy = sum;
     76                int val = 0;
     77                __SYSCALL1(SYS_FUTEX_WAKEUP, (sysarg_t) &val);
     78                __SYSCALL1(SYS_FUTEX_SLEEP, (sysarg_t) &val);
     79        }
    10880}
    10981
     
    179151}
    180152
    181 static const char *results_txt = "/tmp/rcu-bench-results.txt";
     153static const char *results_txt = "/tmp/urcu-bench-results.txt";
    182154
    183155static bool open_results(void)
     
    211183        printf("rcubench [test-name] [k-iterations] [n-threads] {work-size}\n");
    212184        printf("Available tests: \n");
    213         printf("  ke-futex .. threads down/up a shared futex and do some work when\n");
    214         printf("              in critical section; do a little less work outside CS.\n");
     185        printf("  sys-futex.. threads make wakeup/sleepdown futex syscalls in a loop\n");
     186        printf("              but for separate variables/futex kernel objects.\n");
    215187        printf("  lock     .. threads lock/unlock separate futexes.\n");
    216188        printf("  sema     .. threads down/up separate futexes.\n");
     
    232204        futex_initialize(&bench->bench_fut, 1);
    233205       
    234         if (0 == str_cmp(argv[1], "ke-futex")) {
     206        if (0 == str_cmp(argv[1], "sys-futex")) {
    235207                bench->func = kernel_futex_bench;
    236208        } else if (0 == str_cmp(argv[1], "lock")) {
Note: See TracChangeset for help on using the changeset viewer.