【问题标题】:Running kernel function in other cpu core in ARM在 ARM 的其他 cpu 内核中运行内核函数
【发布时间】:2017-01-27 13:21:15
【问题描述】:

我正在尝试打印一些函数名称和运行该函数的 CPU ID。使用linux-4.1 kernel,当我打印 CPU ID 时,它始终为零。我正在使用双核板。我只是想表明一些内核函数也可以在其他CPU 中运行。有什么办法可以切换 CPU 并将cpu id 打印为 1。 我正在使用armv7 板。 示例

 0)   0.073 us    |        mutex_unlock();
 3)   0.124 us    |                iov_iter_fault_in_readable();
 1)   0.105 us    |        fget_light();
 3)               |                ext3_write_begin() {
 0)   0.071 us    |        put_pid();
 3)               |                  ext3_writepage_trans_blocks() {
 3)   0.043 us    |                    journal_blocks_per_page();
 1)               |        sock_poll() {
 0)   3.126 us    |      }
 1)               |          unix_poll() {
 3)   0.390 us    |                  }
 0)   6.007 us    |    }
 3)               |                  grab_cache_page_write_begin() {
 1)               |            __pollwait() {
 3)               |                    find_lock_page() {
 0)   0.077 us    |    fput();
 3)   0.074 us    |                      find_get_page();
 1)               |              add_wait_queue() {
 1)   0.081 us    |                _raw_spin_lock_irqsave();

正如我们在第一列中看到的那样,数字发生了变化,我如何才能实现修改内核源代码。

【问题讨论】:

标签: linux linux-kernel arm linux-device-driver armv7


【解决方案1】:

有什么办法可以切换CPU

sched_setaffinity用户空间函数使用sched_setaffinity 系统调用。

通过查看 sched_setaffinity 系统调用的实现,在内核空间中使用了同名的内核函数。
http://lxr.free-electrons.com/source/kernel/sched/core.c#L4685

这里 sched_setaffinity 在内核中使用。
http://lxr.free-electrons.com/source/kernel/trace/trace_hwlat.c#L269

【讨论】:

    猜你喜欢
    • 2010-10-25
    • 2017-08-22
    • 2015-07-12
    • 2021-12-29
    • 1970-01-01
    • 1970-01-01
    • 2013-12-02
    • 2014-08-23
    • 2013-08-09
    相关资源
    最近更新 更多