博文

通过简单的例子,学习systemtap

看例子先!  怎样遍历数组: 1.  # 2.  # Print the system call count by process name in descending order. 3.  # 4. 5.  global syscalls 6. 7.  probe begin { 8.     print ("Collecting data... Type Ctrl-C to exit and display results\n") 9.  } 10. 11. probe syscall.* { 12.    syscalls[execname()]++ 13. } 14. 15. probe end { 16.    printf ("%-10s %-s\n", "#SysCalls", "Process Name") 17.    foreach (proc in syscalls-) 18.       printf("%-10d %-s\n", syscalls[proc], proc) 19. }   这中间,比较难理解的是第17行,那么它的解释如下: The variable proc is an index variable that iterates over the range of values possible for the array index of syscalls. Also note the en dash (-) after syscalls that denotes that the iteration runs in reverse order. This character ensures that the number of system calls made print in descending order. To print in ascending order, change the...

外网主机ssh和vnc访问内网主机

之前,孤陋寡闻,以为外网访问内网纯属扯淡!早上开shlug的邮件列表,看到这个thread。实验了一下,夷~,竟然可以。太棒了! 外网通过ssh访问内网的方法: $ ssh -f -N -R 7070: 127.0.0.1:22  外网主机用户名@外网主机ip $ ssh 内网主机用户名@ 127.0.0.1  -p 7070 原理:将外网7070的端口映射到内网主机的22端口 外网通过VNC访问内网的方法: 同ssh访问的方法一样,我们还可以使用VNC服务: 在内网主机上安装好VNC,然后,开启一个session(默认的端口是从5900开始的) 在内网主机操作: $vnc4server :1 $vnc4passwd //设定VNC连接密码 $ssh -f -N -R 1234: 127.0.0.1:5901  外网主机用户名@外网主机ip 好,已经将5901绑定到外网主机的1234端口了。 然后,操作外网主机: 在外网主机菜单Applications->Internet->Remote Desktop Viewer 选择VNC协议,填入 127.0.0.1:1234 然后, 会要求输入密码,就是内网主机通过vnc4passwd设定的密码了。 OK啦~

__copy_user_zeroing

2.6内核和2.4相比,又加入了一个异常修复地址 #define __copy_user_zeroing(to,from,size)               \ do {                                   \    int __d0, __d1, __d2;                       \    __asm__ __volatile__(                       \        "   cmp $7,%0\n"                   \        "   jbe  1f \n"                   \        "   movl %1,%0\n"        ...

看例子,学Systemtap

看例子先! 例子 : 怎样遍历数组: 1. # 2. # Print the system call count by process name in descending order. 3. # 4. 5. global syscalls 6. 7. probe begin { 8. print ("Collecting data... Type Ctrl-C to exit and display results\n") 9. } 10. 11. probe syscall.* { 12. syscalls[execname()]++ 13. } 14. 15. probe end { 16. printf ("%-10s %-s\n", "#SysCalls", "Process Name") 17. foreach (proc in syscalls-) 18. printf("%-10d %-s\n", syscalls[proc], proc) 19. } 这中间,比较难理解的是第17行,那么它的解释如下: The variable  proc  is an index variable that iterates over the range of values possible for the array index of  syscalls . Also note the en dash (-) after  syscalls  that denotes that the iteration runs in reverse order. This character ensures that the number of system calls made print in descending order. To print in ascending order, change the script to syscalls+ . ------------------------------ ------------------------------ -----...

Linux系统调用宏展开笔记

不知道从哪个版本的内核开始,系统调用变成宏了。在2.6.38的内核里面追踪了一下,以SYSCALL_DEFINE1为例:   SYSCALL_DEFINE1(name,...)展开sys_name,后面的数字,若为1则是一个参数,若为2则为2个参数   具体的宏,展开跟踪流程如下: #define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)                                         |                                            v                            #define SYSCALL_DEFINEx(x, sname, ...)              \                                   __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)                         ...

Xen-ARM Guest DOM启动以及VCPU切换

/* 从hypervisor到DOM的转换比较复杂,简单的步骤有两个阶段: 1.将guest的contest的寄存器信息赋值,其中还包括一些DOM设置信息 2.调用scheduler通过__switch_to调度到设置的VCPU上 */ ------------hypervisor------------- construct_guest_dom() { ..... new_thread(v, dsi.v_kernentry, vstack_end, vstartinfo_start); ..... } void new_thread(struct vcpu *d, unsigned long start_pc, unsigned long start_stack, unsigned long start_info) { unsigned long *domain_stack; struct cpu_info *ci; struct cpu_user_regs *domain_context; struct cpu_user_regs *regs = &d->arch.guest_context.user_regs; domain_stack = alloc_xenheap_pages(STACK_ORDER); if(domain_stack == NULL) { return; } ci = (struct cpu_info *)domain_stack; ci->cur_vcpu = d; domain_stack += (STACK_SIZE - sizeof(struct cpu_user_regs))/sizeof(unsigned long); domain_context = (struct cpu_user_regs *)domain_stack; domain_context->r0 = 0; domain_context->r12 = start_info;//参数传过来 domain_context->r13 = start_stack; domain_context->r15 = start_pc;//DOM的启始地址 domain_context->psr = 0x13; regs-...

[xen-arm]关于Goldfish设备初始化

在移植goldfish的时候,如果没有module机制,怎么做呢?从pdev_bus_driver开始.  143 asmlinkage void do_softirq(void) 144 { 145     unsigned int i, cpu = smp_processor_id(); 146     unsigned long pending; 147     pending = softirq_pending(cpu); 148     ASSERT(pending != 0); 149  150     do { 151         i = find_first_set_bit(pending); 152         if(flag < 2 || sched_flag == 1) 153         { 154             if(flag == 0) 155                 switch_init(); 156             local_irq_enable(); 157             if(flag == 1){//设备初始化 158                 goldfish_pdev_bus_driver.probe(&goldfish_pdev_bus_device); 159                 printk("init screen\n"); 160    ...