LINUX.ORG.RU

oprofile & external kernel modules


0

0

Привет!

Подскажите как увидеть посимвольную информацию для примерно такого модуля.

#include <linux/init.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/kthread.h>

static struct task_struct *task;

static void foo0(void)
{
	int i, count = 0;
	
	for (i = 0; i < 50000; i++)
		count++;
}

static void foo1(void)
{
	int i, count = 0;
	
	for (i = 0; i < 150000; i++)
		count++;
}


static int test_oprofile_task(void *data)
{
	int i, j = 0, count;

	for (;;) {
		
		if (kthread_should_stop())
			break;
		
		/* 1 second sleep */
		set_current_state(TASK_INTERRUPTIBLE);
		schedule_timeout(1 * HZ);
		pr_info("%s: %d\n", __func__, j++);
		
		count = 0;
		for (i = 0; i < 100000; i++)
			count++;

		foo0();
		foo1();
	}
	
	return 0;
}

static int __init test_oprofile_init(void)
{

	task = kthread_run(test_oprofile_task, NULL, "test_oprofile");  

	return 0;
}

static void __exit test_oprofile_exit(void)
{
	kthread_stop(task);
}

module_init(test_oprofile_init);
module_exit(test_oprofile_exit);

Если собрать подобное в качестве userspace программки, то всё просто. Программка:

#include <unistd.h>
#include <stdlib.h>

static void foo0(void)
{
	int count = 0;
	
	for (int i = 0; i < 50000; i++)
		count++;
}

static void foo1(void)
{
	int count = 0;
	
	for (int i = 0; i < 150000; i++)
		count++;
}

int main()
{
	for (;;) {
		sleep(1);

		int count = 0;
		for (int i = 0; i < 100000; i++)
			count++;

		foo0();
		foo1();
	}
	exit(EXIT_SUCCESS);
}

Что я получаю для неё:

[root@localhost test_oprofile]# opcontrol --no-vmlinux
[root@localhost test_oprofile]# opcontrol --start
Using default event: GLOBAL_POWER_EVENTS:100000:1:1:1
Using 2.6+ OProfile kernel interface.
Using log file /var/lib/oprofile/samples/oprofiled.log
Daemon started.
Profiler running.
[root@localhost test_oprofile]# ./test_oprofile 
^C
[root@localhost test_oprofile]# opcontrol --shutdown
Stopping profiling.
Killing daemon.
[root@localhost test_oprofile]# opreport -l test_oprofile
warning: [vdso] (tgid:9741 range:0x4ce000-0x4cf000) could not be found.
CPU: P4 / Xeon with 2 hyper-threads, speed 3000 MHz (estimated)
Counted GLOBAL_POWER_EVENTS events (time during which processor is not stopped) with a unit mask of 0x01 (mandatory) count 100000
samples  %        image name               symbol name
226      49.8896  test_oprofile            foo1
153      33.7748  test_oprofile            main
72       15.8940  test_oprofile            foo0
2         0.4415  [vdso] (tgid:9741 range:0x4ce000-0x4cf000) [vdso] (tgid:9741 range:0x4ce000-0x4cf000)

Вот такое же хочу получить для модуля, но не могу.


удалось получить подобное, но только в общей статистике, указав путь к модулю через ключ ---image для opcontrol

226       0.0575  test_oprofile            test_oprofile            foo1
153       0.0389  test_oprofile            test_oprofile            main
72        0.0183  test_oprofile            test_oprofile            foo0
2        5.1e-04  [vdso] (tgid:9741 range:0x4ce000-0x4cf000) test_oprofile            [vdso] (tgid:9741 range:0x4ce000-0x4cf000)

но отдельно для модуля не получается всё равно

Idle
() автор топика

Получилось для таргета со стандартными опциями -p [путь к каталогу с модулями] -l и указанием имени файла модуля с расширением. Всё как в документации, зря провозился на хосте.

Idle
() автор топика
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.