コード例 #1
0
ファイル: smpboot.c プロジェクト: fhgwright/bb-linux
/*
 * Bring a secondary processor online.
 */
void online_secondary(void)
{
	/*
	 * low-memory mappings have been cleared, flush them from
	 * the local TLBs too.
	 */
	local_flush_tlb();

	BUG_ON(in_interrupt());

	/* This must be done before setting cpu_online_mask */
	wmb();

	notify_cpu_starting(smp_processor_id());

	set_cpu_online(smp_processor_id(), 1);
	__this_cpu_write(cpu_state, CPU_ONLINE);

	/* Set up tile-specific state for this cpu. */
	setup_cpu(0);

	/* Set up tile-timer clock-event device on this cpu */
	setup_tile_timer();

	cpu_startup_entry(CPUHP_AP_ONLINE_IDLE);
}
コード例 #2
0
ファイル: smpboot.c プロジェクト: 1703011/asuswrt-merlin
/*
 * Bring a secondary processor online.
 */
void __cpuinit online_secondary(void)
{
	/*
	 * low-memory mappings have been cleared, flush them from
	 * the local TLBs too.
	 */
	local_flush_tlb();

	BUG_ON(in_interrupt());

	/* This must be done before setting cpu_online_mask */
	wmb();

	/*
	 * We need to hold call_lock, so there is no inconsistency
	 * between the time smp_call_function() determines number of
	 * IPI recipients, and the time when the determination is made
	 * for which cpus receive the IPI. Holding this
	 * lock helps us to not include this cpu in a currently in progress
	 * smp_call_function().
	 */
	ipi_call_lock();
	set_cpu_online(smp_processor_id(), 1);
	ipi_call_unlock();
	__get_cpu_var(cpu_state) = CPU_ONLINE;

	/* Set up tile-specific state for this cpu. */
	setup_cpu(0);

	/* Set up tile-timer clock-event device on this cpu */
	setup_tile_timer();

	preempt_enable();

	cpu_idle();
}
コード例 #3
0
ファイル: syst_smpl.c プロジェクト: multics69/danbi
int
mainloop(char **arg)
{
	static uint64_t ovfl_count = 0; /* static to avoid setjmp issue */
	struct pollfd pollfds[1];
	int ret;
	int fd = -1;
	int i;

	if (pfm_initialize() != PFM_SUCCESS)
		errx(1, "libpfm initialization failed\n");

	pgsz = sysconf(_SC_PAGESIZE);
	map_size = (options.mmap_pages+1)*pgsz;

	if (options.cgroup) {
		fd = open_cgroup(options.cgroup);
		if (fd == -1)
			err(1, "cannot open cgroup file %s\n", options.cgroup);
	}

	setup_cpu(options.cpu, fd);

	signal(SIGALRM, handler);
	signal(SIGINT, handler);

	pollfds[0].fd = fds[0].fd;
	pollfds[0].events = POLLIN;

	printf("monitoring on CPU%d, session ending in %ds\n", options.cpu, options.delay);

	if (setjmp(jbuf) == 1)
		goto terminate_session;

	start_cpu();

	alarm(options.delay);
	/*
	 * core loop
	 */
	for(;;) {
		ret = poll(pollfds, 1, -1);
		if (ret < 0 && errno == EINTR)
			break;
		ovfl_count++;
		process_smpl_buf(&fds[0]);
	}
terminate_session:
	for(i=0; i < num_fds; i++)
		close(fds[i].fd);

	/* check for partial event buffer */
	process_smpl_buf(&fds[0]);
	munmap(fds[0].buf, map_size);

	free(fds);

	printf("%"PRIu64" samples collected in %"PRIu64" poll events, %"PRIu64" lost samples\n",
		collected_samples,
		ovfl_count, lost_samples);
	return 0;
}
コード例 #4
0
ファイル: syst_count.c プロジェクト: pyrovski/papi-rapl
void
measure(void)
{
	int c, cmin, cmax, ncpus;
	int cfd = -1;

	cmin = 0;
	cmax = (int)sysconf(_SC_NPROCESSORS_ONLN);
	ncpus = cmax;

	if (options.cpu != -1) {
		cmin = options.cpu;
		cmax = cmin + 1;
	}

	all_fds = malloc(ncpus * sizeof(perf_event_desc_t *));
	if (!all_fds)
		err(1, "cannot allocate memory for all_fds");

	if (options.cgroup_name) {
		cfd = open_cgroup(options.cgroup_name);
		if (cfd == -1)
			exit(1);
	}

	for(c=cmin ; c < cmax; c++)
		setup_cpu(c, cfd);

	printf("<press CTRL-C to quit before %ds time limit>\n", options.delay);
	/*
	 * FIX this for hotplug CPU
	 */

	if (options.interval) {
		struct timespec tv;
		int delay;

		for (delay = 1 ; delay <= options.delay; delay++) {

		for(c=cmin ; c < cmax; c++)
			start_cpu(c);

			if (0) {
				tv.tv_sec = 0;
				tv.tv_nsec = 100000000;
				nanosleep(&tv, NULL);
			} else
				sleep(1);

		for(c=cmin ; c < cmax; c++)
			stop_cpu(c);

			for(c = cmin; c < cmax; c++) {
				printf("# %'ds -----\n", delay);
				read_cpu(c);
			}

		}

	} else {
		for(c=cmin ; c < cmax; c++)
			start_cpu(c);

		sleep(options.delay);

		if (0)
			for(c=cmin ; c < cmax; c++)
				stop_cpu(c);

		for(c = cmin; c < cmax; c++) {
			printf("# -----\n");
			read_cpu(c);
		}
	}

	for(c = cmin; c < cmax; c++)
		close_cpu(c);

	free(all_fds);
}
コード例 #5
0
ファイル: status.c プロジェクト: iddumied/SDWM
void setup_status()
{
  #ifdef INFO
  char buffer[256];
  sprintf(buffer, "Setup Status: draw Memory %s", sbar_status_symbols[DrawMemory].active ? "yes" : "no");
  log_str(buffer, LOG_DEBUG);
  sprintf(buffer, "Setup Status: draw Battery %s", sbar_status_symbols[DrawBattery].active ? "yes" : "no");
  log_str(buffer, LOG_DEBUG);
  sprintf(buffer, "Setup Status: draw Uptime %s", sbar_status_symbols[DrawUptime].active ? "yes" : "no");
  log_str(buffer, LOG_DEBUG);
  sprintf(buffer, "Setup Status: draw Termal %s", sbar_status_symbols[DrawTermal].active ? "yes" : "no");
  log_str(buffer, LOG_DEBUG);
  #ifdef NF310_A01
  sprintf(buffer, "Setup Status: draw Backlight %s", sbar_status_symbols[DrawBacklight].active ? "yes" : "no");
  log_str(buffer, LOG_DEBUG);
  #endif
  sprintf(buffer, "Setup Status: draw Net %s", sbar_status_symbols[DrawNet].active ? "yes" : "no");
  log_str(buffer, LOG_DEBUG);
  #endif

  // setup disks
  setup_disk();  

  #ifdef INFO
  log_str("Setup Status Disk", LOG_INFO);
  #endif

  // setup uptime
  if(sbar_status_symbols[DrawUptime].active) {
    setup_uptime();
    
    #ifdef INFO
    log_str("Setup Status Uptime", LOG_INFO);
    #endif
  }
  
  // setup net
  if(sbar_status_symbols[DrawNet].active) {
    setup_net();

    #ifdef INFO
    log_str("Setup Status Net", LOG_INFO);
    #endif
  }
  
  // setup audio
  if(sbar_status_symbols[DrawAudio].active) {
    setup_audio();

    #ifdef INFO
    log_str("Setup Status Audio", LOG_INFO);
    #endif
  }
  
  #ifdef NF310_A01
  // setup backlight
  if(sbar_status_symbols[DrawBacklight].active) {
    backlight.on = True;

    #ifdef INFO
    log_str("Setup Status Backlight", LOG_INFO);
    #endif
  }
  #endif

  // setup cpu
  setup_cpu();

  #ifdef INFO
  log_str("Setup Status CPU", LOG_INFO);
  #endif
}