开发者

how ther linux kernel process the write to /sys/power/state

I want to find o开发者_高级运维ut the source file of the Linux kernel (x86, 2.6.18 or similar) that handle the write to /sys/power/state. I googled and try to search sysfs_create_file (and dir) in the source code. But I didn't find anything useful so far. Anyone knows that? Thanks!


To find out where a call into the kernel ends up, Ftrace can be a handy tool.

For your particular case, I used the following command to get a function graph for a read from /sys/power/state (I figured the reading function wouldn't be too far away from writing function that you are looking for):

trace-cmd record -p function_graph -F cat /sys/power/state

(You need to be root to execute this)

This dumps the trace to a binary file called trace.dat. To read this file, do the following (again as root):

trace-cmd report

Then I used grep to filter the output on things like "power" or "state" and eventually was able to find the following (only showing relevant parts):

sysfs_read_file() {
  ...
  state_show() {
    valid_state() {
      acpi_suspend_state_valid();
    }
  }
  ...
}

So reading /sys/power/state ends up in state_show. Below that function, you can find state_store which is where I guess writes will end up.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜