All of lore.kernel.org
 help / color / mirror / Atom feed
* Hang with fair cgroup scheduler (reproducer is attached.)
@ 2007-12-14  7:18 KAMEZAWA Hiroyuki
       [not found] ` <20071214161834.034e6efe.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
  0 siblings, 1 reply; 25+ messages in thread
From: KAMEZAWA Hiroyuki @ 2007-12-14  7:18 UTC (permalink / raw)
  To: containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org
  Cc: Andrew Morton, mingo-X9Un+BFzKDI,
	vatsa-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8

[-- Attachment #1: Type: text/plain, Size: 742 bytes --]

Hi,

While I was testing 2.6.24-rc5-mm1's fair group scheduler (with cgroup),
the system hangs. please confirm. it's reproducible on my box.

My test program is attached.

What happens:
  the system hangs. (panic ?)

Environ:
  ia64/NUMA 8CPU systems. 4 cpus per node.

How to reproduce:
  Compile attached one.
  # gcc -o reg reg.c
  Create group as following
  # mount -t cgroup none /opt/cgroup -o cpu
  # mkdir /opt/cgroup/group_1
  # mkdir /opt/cgroup/group_2
  
  And run attached program
  # ./reg 8 8

What 'reg' does;  
  usage : reg A B C...
  This program forks child process and assign 
     A of processes to group_1
     B of processes to group_2
     C of processes to group_3
  kick and waitpid all and repeat.

Thanks,
-Kame

[-- Attachment #2: reg.c --]
[-- Type: text/x-csrc, Size: 2301 bytes --]

#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
#include <sys/types.h>
#include <unistd.h>
#include <sched.h>
#include <asm/intrinsics.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <errno.h>
#include <sys/times.h>

static char *shared;
#define MAX_PROCS 32
#define SHMSIZE	(16384)

struct start_stop {
	int go;
};

/* Assign PID to a group....
 * work as # echo PID > /opt/cgroup/group_%d/tasks
 */
void assign_to(int pid, int group)
{
	FILE *fp;
	char buf[32];

	memset(buf, 0, sizeof(buf));
	sprintf(buf,"/opt/cgroup/group_%d/tasks",group);
	fp = fopen(buf,"w");
	if (fp == NULL) {
		perror("fopen");
		fprintf(stderr, "failed : fopen");
		exit(0);
	}
	fprintf(fp, "%d", pid);
	fclose(fp);
	printf("%d to %s\n", pid, buf);
}

/*
 * spin wait and go into small loop.
 * # of loops are counted as score.
 * This process's utime is recorded in times[id]
 */
int worker(int id)
{
	struct start_stop *shared_flag;

	shared_flag = (struct start_stop*)shared;
	do  {
		sched_yield();
		ia64_mf();
	} while (!shared_flag->go);
}

/*
 * If you want to assign..
 * 2 proces to group 1, 3 procs to group 2 -># ./a.out 2 3
 * 3 proces to group 1, 3 procs to group 2, 3 procs to group 3
 * -># ./a.out 3 3 3
 * Total 32 procs are supported.
 */

int main(int argc, char *argv[])
{
	int nprocs;
	int shmid, i;
	struct start_stop *shared_flag;
	int pids[MAX_PROCS];
	int groups[MAX_PROCS];

	memset(pids, 0 , sizeof(pids));
	memset(groups, 0 , sizeof(groups));

again:
	for (nprocs = 0, i = 1; i < argc; i++) {
		int num = atoi(argv[i]);
		int j;
		for (j = 0; j < num; j++) {
			groups[nprocs + j] = i;
		}
		nprocs += num;
	}
	
	shmid = shmget(IPC_PRIVATE, SHMSIZE, IPC_CREAT | 0666);
	if (shmid == -1) {
		perror("shmget");
		exit(1);
	}

	shared = shmat(shmid, NULL, 0);
	shared_flag = (struct start_stop *)shared;

	memset(shared, 0, SHMSIZE);
	shmctl(shmid, IPC_RMID, 0);
	
	for (i = 0; i < nprocs; i++) {
		int ret;
		ret = fork();
		if (ret == 0) {
			worker(i);
			exit(0);
		} else if (ret == -1) {
			perror("fork");
			exit(0);
		}
		pids[i] = ret;
	}
	sleep(1);
	for (i = 0; i < nprocs; i++)
		assign_to(pids[i], groups[i]);
	sleep(1);
	ia64_mf();
	shared_flag->go = 1;
	
	for (i = 0; i < nprocs; i++) {
		int status;
		waitpid(pids[i], &status, 0);
	} 
	goto again;

	return 0;
}

[-- Attachment #3: Type: text/plain, Size: 206 bytes --]

_______________________________________________
Containers mailing list
Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2007-12-17 14:45 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-14  7:18 Hang with fair cgroup scheduler (reproducer is attached.) KAMEZAWA Hiroyuki
     [not found] ` <20071214161834.034e6efe.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2007-12-14  8:17   ` KAMEZAWA Hiroyuki
     [not found]     ` <20071214171759.59f7ba57.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2007-12-14  9:49       ` Ingo Molnar
     [not found]         ` <20071214094909.GG11266-X9Un+BFzKDI@public.gmane.org>
2007-12-14 10:58           ` KAMEZAWA Hiroyuki
     [not found]             ` <20071214195837.0d3511db.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2007-12-14 11:48               ` Dhaval Giani
2007-12-14 12:47               ` Dmitry Adamushko
     [not found]                 ` <20071214141528.GA6161-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2007-12-14 14:24                   ` kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A
     [not found]                     ` <20442799.1197642268756.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2007-12-14 15:36                       ` Dhaval Giani
     [not found]                         ` <20071214153607.GB23670-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2007-12-14 15:38                           ` Dhaval Giani
     [not found]                             ` <20071214153823.GC23670-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2007-12-14 16:25                               ` Dmitry Adamushko
     [not found]                                 ` <b647ffbd0712140825h4f541be0xa7a7866e70b3af7a-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-12-14 19:51                                   ` Dmitry Adamushko
     [not found]                                     ` <b647ffbd0712141151k697d9bbemda9a7e90515e4400-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-12-14 21:33                                       ` Steven Rostedt
     [not found]                                         ` <Pine.LNX.4.58.0712141614340.22005-f9ZlEuEWxVcI6MkJdU+c8EEOCMrvLtNR@public.gmane.org>
2007-12-15 10:22                                           ` Dmitry Adamushko
     [not found]                                             ` <b647ffbd0712150222p30cac9f9i772c2a2c4e05a4a-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-12-15 10:50                                               ` Dhaval Giani
     [not found]                                                 ` <20071215105036.GB26325-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2007-12-15 11:15                                                   ` Dmitry Adamushko
2007-12-15 23:44                                               ` Dmitry Adamushko
     [not found]                                                 ` <b647ffbd0712151544n2dfad101r2d306d393e8550ff-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-12-16  0:00                                                   ` Dmitry Adamushko
     [not found]                                                     ` <b647ffbd0712151600s14e3f355we5ee6348b4d484cc-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-12-16  4:28                                                       ` Dhaval Giani
     [not found]                                                         ` <20071216042821.GA8494-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2007-12-17  1:12                                                           ` KAMEZAWA Hiroyuki
     [not found]                                                             ` <20071217101245.76562518.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2007-12-17 14:45                                                               ` Ingo Molnar
2007-12-16  8:55                                                       ` Ingo Molnar
     [not found]                                                         ` <20071216085559.GB20790-X9Un+BFzKDI@public.gmane.org>
2007-12-16 10:06                                                           ` Dmitry Adamushko
     [not found]             ` <b647ffbd0712140447kfba5945ybde40f18653dd164-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-12-14 12:50               ` kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A
2007-12-14 14:15               ` Dhaval Giani
2007-12-14  9:48   ` Ingo Molnar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.