如何在每个CPU上运行code [英] How to run code on every CPU

查看:591
本文介绍了如何在每个CPU上运行code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置的性能监视器用户模式使能上一台Nexus 4的所有CPU上运行的灰鲭鲨内核注册。

I am trying to set the Performance Monitor User Mode Enable register on all cpus on a Nexus 4 running a mako kernel.

现在我设置寄存器可加载模块:

Right now I am setting the registers in a loadable module:

    void enable_registers(void* info)
    {
        unsigned int set = 1;
        /* enable user-mode access to the performance counter*/
        asm volatile ("mcr p15,  0, %0, c9,  c14, 0\n\t" : : "r" (set));
    }

    int init_module(void)
    {
       online = num_online_cpus();
       possible = num_possible_cpus();
       present = num_present_cpus();
       printk (KERN_INFO "Online Cpus=%d\nPossible Cpus=%d\nPresent Cpus=%d\n", online, possible, present);
       on_each_cpu(enable_registers , NULL, 1);
       return 0;
    }

的问题是,on_each_cpu仅运行功能上联机CPU和如由printk的说明书:

The problem is that on_each_cpu only runs the function on Online cpus and as shown by the printk statment:

Online Cpus=1
Possible Cpus=4
Present Cpus=4

只有四大家之一是在线,当我打电话on_each_cpu。所以我的问题是,如何保证CPU处于联机状态,不然怎么可以强制某些CPU执行code? 谢谢

Only one of the four is online when I call on_each_cpu. So my question is, how do I force a cpu to be online, or how can force a certain cpu to execute code? Thanks

推荐答案

您不必在每个CPU的运行code现在。你需要做的是安排,这样,当离线的CPU重新联机,你的code是能够执行并启用访问PMU。

You don't need to run the code on every cpu right now. What you need to do is arrange so that when the offline cpus come back online, your code is able to execute and enable the access to the PMU.

要实现这一目标的方法之一是用一个CPU热插拔通知。

One way to achieve that would be with a cpu hotplug notifier.

这篇关于如何在每个CPU上运行code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆