免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2890 | 回复: 7
打印 上一主题 下一主题

如何使以SMP方式运行的内核,切换到单核模式? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-08-25 09:48 |只看该作者 |倒序浏览
双核powerpc E500 。

我在内核的一个系统调用中,添加了一句: smp_send_stop();  想要关闭其中一个CPU,结果发现,该系统调用无法返回到用户态。


请问有没有什么好的办法,可以在以SMP方式运行的内核中,关闭一个CPU?

谢谢

论坛徽章:
0
2 [报告]
发表于 2009-08-26 01:08 |只看该作者
在编译内核的时候配置成单核就行了

论坛徽章:
0
3 [报告]
发表于 2009-08-26 01:09 |只看该作者
好像还有一个选项专门用户调试smp的。
注释里都写了的

论坛徽章:
0
4 [报告]
发表于 2009-08-27 13:21 |只看该作者
如果是在启动的时候可以在grub里边kernel的那一行添加参数 maxcpus=1 将传递cpu一个内核给操作系统

建议有问题先去各厂商的官方网站去搜索
http://kbase.redhat.com/faq/docs/DOC-15523

Release Found: Red Hat Enterprise Linux 5 and later


Problem
You want to dynamically enable or disable a CPU on a running system.


Solution
Red Hat Enterprise Linux 5 supports the cpu-hotplug mechanism, which allows for CPUs to be dynamically disabled and re-enabled on a system without requiring a system reboot. Note: CPU hot-plugging will only work if physical hotplug is supported by the hardware.


In order to disable a CPU core in a running machine, use the file /sys/devices/system/cpu/cpuX/online.


The following command will disable a CPU:


# echo 0 > /sys/devices/system/cpu/cpuX/online
Where X is the ID of the CPU as determined from /proc/cpuinfo.


To re-enable the CPU, run:


# echo 1 > /sys/devices/system/cpu/cpuX/online
Example:

The following output from /proc/cpuinfo shows two processors on a system:


root@xen # grep "processor" /proc/cpuinfo
processor       : 0
processor       : 1

In order to disable CPU 1, echo "0" to /sys/devices/system/cpu/cpu1/online:


root@xen# echo 0 > /sys/devices/system/cpu/cpu1/online
cpu0/ cpu1/  
Check /proc/cpuinfo to see if the cpu is disabled .


root@xen # grep "processor" /proc/cpuinfo
processor       : 0
Notice that there is now only one processor shown (CPU 0) instead of two.

评分

参与人数 1可用积分 +30 收起 理由
platinum + 30 高招!

查看全部评分

论坛徽章:
0
5 [报告]
发表于 2009-08-27 15:29 |只看该作者
已经跑起来了就不行了吧?
重启修改启动参数,比较方便

论坛徽章:
0
6 [报告]
发表于 2009-08-27 15:33 |只看该作者
原帖由 Roemer 于 2009-8-27 15:29 发表
已经跑起来了就不行了吧?
重启修改启动参数,比较方便

跑起来的也可以,请看英文描述

论坛徽章:
0
7 [报告]
发表于 2009-08-27 18:24 |只看该作者
谢谢,查了一下hotplug ,真是个好东西啊。



我目前的情况是这样:

内核运行中,CPU0正常,而CPU1是死循环;

接着,CPU0把PC指向内核起始地址0,再次开始执行内核第一条指令,结果发现内核无法启动。


或者,我尝试,当CPU0跳到0地址执行后,把CPU1再指向0地址,结果仍然无法启动(这是因为在powerpc的启动,是由主CPU来启

动从cpu的)



看来,可能需要参考hotplug里面cpu_down的操作,来关闭CPU1...

不然,还真没办法,从一个这样的状态:CPU0正常,CPU1死循环---重新跳到配置了SMP的内核来执行

[ 本帖最后由 wilos 于 2009-8-27 22:58 编辑 ]

论坛徽章:
0
8 [报告]
发表于 2009-08-28 17:47 |只看该作者
加内核锁试试
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP