Skip to contentSkip to conversation

perf machine: Search for modules in %s/lib/modules/%s

PATCH In review Richard Yao 4 participants 5 messages Apr 10, 2014 – Apr 26, 2014 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf machine: Search for modules in %s/lib/modules/%s

Modules installed outside of the kernel's build system should go into "%s/lib/modules/%s/extra", but at present, perf will only look at them when they are in "%s/lib/modules/%s/kernel". Lets encourage good citizenship by relaxing this requirement to "%s/lib/modules/%s". This way open source modules that are out-of-tree have no incentive to start populating a directory reserved for in-kernle modules and I can stop hex editing my system's perf binary when profiling OSS out-of-tree modules.

---
 tools/perf/util/machine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/machine.c +1 -1
index a53cd0b..116842e 100644
@@ -786,7 +786,7 @@ static int machine__set_modules_path(struct machine *machine)
 	if (!version)
 		return -1;
 
-	snprintf(modules_path, sizeof(modules_path), "%s/lib/modules/%s/kernel",
+	snprintf(modules_path, sizeof(modules_path), "%s/lib/modules/%s",
 		 machine->root_dir, version);
 	free(version);
 
Signature · 1 line
1.8.3.2
Acked-by on v1 1/1
#1 lore raw
Quoted 19 lines · Richard Yao

Modules installed outside of the kernel's build system should go into "%s/lib/modules/%s/extra", but at present, perf will only look at them when they are in "%s/lib/modules/%s/kernel". Lets encourage good citizenship by relaxing this requirement to "%s/lib/modules/%s". This way open source modules that are out-of-tree have no incentive to start populating a directory reserved for in-kernle modules and I can stop hex editing my system's perf binary when profiling OSS out-of-tree modules.

---
  tools/perf/util/machine.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/machine.c +0 -0
index a53cd0b..116842e 100644

tools/perf/util/machine.c static int machine__set_modules_path(struct machine *machine) · line 792

Quoted 8 lines
tools/perf/util/machine.c +1 -1
@@ -786,7 +786,7 @@ static int machine__set_modules_path(struct machine *machine)
  	if (!version)
  		return -1;
 
-	snprintf(modules_path, sizeof(modules_path), "%s/lib/modules/%s/kernel",
+	snprintf(modules_path, sizeof(modules_path), "%s/lib/modules/%s",
  		 machine->root_dir, version);
  	free(version);
 
#2 lore raw
In reply to Richard Yao

Hi Richard,

Quoted 7 lines · Richard Yao

Modules installed outside of the kernel's build system should go into "%s/lib/modules/%s/extra", but at present, perf will only look at them when they are in "%s/lib/modules/%s/kernel". Lets encourage good citizenship by relaxing this requirement to "%s/lib/modules/%s". This way open source modules that are out-of-tree have no incentive to start populating a directory reserved for in-kernle modules and I can stop hex editing my system's perf binary when profiling OSS out-of-tree modules.

But it'll make the perf traverses all the source and build directories too, right? I don't think it's a right thing to do.

Maybe we can also change stat() in map_groups__set_modules_path_dir() to lstat() so that it cannot go to unwanted directories in that case. Or else, just checking "kernel" and "extra" directories will work.

Thanks,
Namhyung

#3 lore raw
Quoted 11 lines · Namhyung Kim

Hi Richard,

Quoted 7 lines · Richard Yao

Modules installed outside of the kernel's build system should go into "%s/lib/modules/%s/extra", but at present, perf will only look at them when they are in "%s/lib/modules/%s/kernel". Lets encourage good citizenship by relaxing this requirement to "%s/lib/modules/%s". This way open source modules that are out-of-tree have no incentive to start populating a directory reserved for in-kernle modules and I can stop hex editing my system's perf binary when profiling OSS out-of-tree modules.

Quoted 6 lines

But it'll make the perf traverses all the source and build directories too, right? I don't think it's a right thing to do.

Maybe we can also change stat() in map_groups__set_modules_path_dir() to lstat() so that it cannot go to unwanted directories in that case. Or else, just checking "kernel" and "extra" directories will work.

yay, forgot about source directory.. :-\ looks like lstat should help, but hardcoding kernel and extra sounds better to me.

Richard, please send updated patch

thanks,
jirka

#4 lore raw

Dear Jirka,

I have sent an updated patch, but instead of using your white list idea, I went with a black list. That way things like the historical addon directory are included and anyone who decides to use a custom directory for their own in-development modules is free to do so.

Yours truly,
Richard Yao

Quoted 27 lines · Jiri Olsa
Quoted 11 lines · Namhyung Kim

Hi Richard,

Quoted 7 lines · Richard Yao

Modules installed outside of the kernel's build system should go into "%s/lib/modules/%s/extra", but at present, perf will only look at them when they are in "%s/lib/modules/%s/kernel". Lets encourage good citizenship by relaxing this requirement to "%s/lib/modules/%s". This way open source modules that are out-of-tree have no incentive to start populating a directory reserved for in-kernle modules and I can stop hex editing my system's perf binary when profiling OSS out-of-tree modules.

Quoted 6 lines

But it'll make the perf traverses all the source and build directories too, right? I don't think it's a right thing to do.

Maybe we can also change stat() in map_groups__set_modules_path_dir() to lstat() so that it cannot go to unwanted directories in that case. Or else, just checking "kernel" and "extra" directories will work.

yay, forgot about source directory.. :-\ looks like lstat should help, but hardcoding kernel and extra sounds better to me.

Richard, please send updated patch

thanks,
jirka