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:	Wed, 14 May 2014 11:44:26 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Michael wang <wangyun@...ux.vnet.ibm.com>
Cc:	Rik van Riel <riel@...hat.com>,
	LKML <linux-kernel@...r.kernel.org>,
	Ingo Molnar <mingo@...nel.org>, Mike Galbraith <efault@....de>,
	Alex Shi <alex.shi@...aro.org>, Paul Turner <pjt@...gle.com>,
	Mel Gorman <mgorman@...e.de>,
	Daniel Lezcano <daniel.lezcano@...aro.org>
Subject: Re: [ISSUE] sched/cgroup: Does cpu-cgroup still works fine nowadays?

On Wed, May 14, 2014 at 03:36:50PM +0800, Michael wang wrote:
> distro mount cpu-subsys under '/sys/fs/cgroup/cpu', create group like:
> 	mkdir /sys/fs/cgroup/cpu/A
> 	mkdir /sys/fs/cgroup/cpu/B
> 	mkdir /sys/fs/cgroup/cpu/C

Yeah, distro is on crack, nobody sane mounts anything there.

> and then:
> 	echo $$ > /sys/fs/cgroup/cpu/A/tasks ; ./my_tool -l
> 	echo $$ > /sys/fs/cgroup/cpu/B/tasks ; ./my_tool -l
> 	echo $$ > /sys/fs/cgroup/cpu/C/tasks ; ./my_tool 50
> 
> the results in top is around:
> 
> 		A	B	C
> 	CPU%	550	550	100

top doesn't do per-cgroup accounting, so how do you get these numbers,
per the above all instances of the prog are also called the same,
further making it error prone and difficult to get sane numbers.


> #include <sys/time.h>
> #include <unistd.h>
> #include <stdio.h>
> #include <pthread.h>
> 
> pthread_mutex_t my_mutex;
> 
> 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 (;;) {
> 		pthread_mutex_lock(&my_mutex);
> 		now = stamp();
> 		if ((long long)(now - begin) > spin) {
> 			pthread_mutex_unlock(&my_mutex);
> 			usleep(total - spin);
> 			pthread_mutex_lock(&my_mutex);
> 			begin += total;
> 		}
> 		pthread_mutex_unlock(&my_mutex);
> 	}
> }

Uh,.. that's just insane.. what's the point of having a multi-threaded
program do busy-wait loops if you then serialize the lot on a global
mutex such that only 1 thread can run at any one time?

How can one such prog ever consume more than 100% cpu.

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ