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]
Message-ID: <1340014395.15222.25.camel@twins>
Date:	Mon, 18 Jun 2012 12:13:15 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Doug Smythies <dsmythies@...us.net>
Cc:	'Charles Wang' <muming.wq@...il.com>, linux-kernel@...r.kernel.org,
	'Ingo Molnar' <mingo@...hat.com>,
	'Charles Wang' <muming.wq@...bao.com>, 'Tao Ma' <tm@....ma>,
	'含黛' <handai.szj@...bao.com>
Subject: RE: [PATCH] sched: Folding nohz load accounting more accurate

On Wed, 2012-06-13 at 20:13 -0700, Doug Smythies wrote:
> ./waiter 2 900 345912 9444

So we're all simply just trying to burn a particular amount of cpu-time?

I have a little consume.c thing lying about doing something like that.
Its independent of clockspeed, but doesn't really like preemption much,
but it more or less works ;-)

---
#include <sys/time.h>
#include <unistd.h>
#include <stdio.h>

unsigned long long stamp(void)
{
	struct timeval tv;

	gettimeofday(&tv, NULL);

	return (unsigned long long)tv.tv_sec * 1000000 + tv.tv_usec;
}

void consume(int spin, int total)
{
	unsigned long long begin, now;

	begin = stamp();

	for (;;) {
		now = stamp();
		if ((long long)(now - begin) > spin) {
			usleep(total - spin);
			begin += total;
		}
	}
}

int main(int argc, char **argv)
{
	int period = 100000; /* 100ms */
	int frac;

	if (argc < 2) {
		fprintf(stderr, "%s <frac> [<period>]\n"
				"  frac   -- [1-100] %% of time to burn\n"
				"  period -- [usec] period of burn/sleep cycle\n",
				argv[0]);
		return -1;
	}

	frac = atoi(argv[1]);
	if (argc > 2)
		period = atoi(argv[2]);

	if (frac > 100)
		frac = 100;

	if (frac < 1)
		frac = 1;

	consume((period * frac) / 100, period);

	return 0;
}

--
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