lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 6 Jul 2007 23:08:05 -0700
From:	"Li, Tong N" <tong.n.li@...el.com>
To:	"Mathieu Desnoyers" <mathieu.desnoyers@...ymtl.ca>
Cc:	"Andi Kleen" <andi@...stfloor.org>,
	"Andrew Morton" <akpm@...ux-foundation.org>,
	"Alexey Dobriyan" <adobriyan@...il.com>,
	<linux-kernel@...r.kernel.org>
Subject: RE: [patch 10/10] *Tests* Scheduler profiling - Use immediate values

Mathieu,

> 	cycles_per_iter = 0.0;
> 	for (i=0; i<NR_TESTS; i++) {
> 		time1 = get_cycles();
> 		for (j = 0; j < NR_ITER; j++) {
> 			testval = &array[random() % ARRAY_SIZE];
> 		}
> 		time2 = get_cycles();
> 		cycles_per_iter += (time2 - time1)/(double)NR_ITER;
> 	}
> 	cycles_per_iter /= (double)NR_TESTS;
> 	printf("Just getting the pointer, doing noting with it, cycles
per
> iteration (mean) : %g\n", cycles_per_iter);
> 

Some comments on the code:

1. random() is counted in cycle_per_iter, which can skew the results.
You could pre-compute the random addresses and store them in an array.
Then, during the actual timing, walk the array:

index = 0;
for (i = 0; i < ARRAY_SIZE; i++)
      index = *(int *)(array + index * CACHE_LINE_SIZE);

2. You may want to flush the cache before the timing starts.

3. You want to access memory at the cache-line granularity to avoid
addresses falling into the same line (and thus unwanted hits).

If you do these, I expect you'll get a higher memory latency.

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ