vhost网络设备才会添加eventfd

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/leoufung/article/details/53941538
vhost网络设备就会从virtio_set_status中调用memory_region_add_eventfd,然后通过kvm_io_ioeventfd_add添加eventfd到KVM,一旦有PIO操作,就通过eventfd通知QEMU,和iothread没有关系
一般virtio网络设备(非vhost)从virtio_set_status 进入到virtio_net_vhost_status 后,发现不是vhost这边就直接return了,也就不会有memory_region_add_eventfd添加eventfd的过程了


VHOST调用栈如下
#0  memory_region_add_eventfd (mr=0x55fe2ae56320, addr=16, size=2, match_data=true, data=0, e=0x55fe2cf729f0) at /home/liufeng/workspace/src/open/qemu/memory.c:1792
#1  0x000055fe2976a299 in virtio_pci_set_host_notifier_internal (proxy=0x55fe2ae55aa0, n=0, assign=true, set_handler=false) at hw/virtio/virtio-pci.c:307
#2  0x000055fe2976c15f in virtio_pci_set_host_notifier (d=0x55fe2ae55aa0, n=0, assign=true) at hw/virtio/virtio-pci.c:1130
#3  0x000055fe2952fe97 in vhost_dev_enable_notifiers (hdev=0x55fe2adcfbc0, vdev=0x55fe2ae5ddc8) at /home/liufeng/workspace/src/open/qemu/hw/virtio/vhost.c:1124
#4  0x000055fe2950b8c7 in vhost_net_start_one (net=0x55fe2adcfbc0, dev=0x55fe2ae5ddc8) at /home/liufeng/workspace/src/open/qemu/hw/net/vhost_net.c:208
#5  0x000055fe2950bdef in vhost_net_start (dev=0x55fe2ae5ddc8, ncs=0x55fe2c1ab040, total_queues=1) at /home/liufeng/workspace/src/open/qemu/hw/net/vhost_net.c:308
#6  0x000055fe2950647c in virtio_net_vhost_status (n=0x55fe2ae5ddc8, status=7 '\a') at /home/liufeng/workspace/src/open/qemu/hw/net/virtio-net.c:151
#7  0x000055fe29506711 in virtio_net_set_status (vdev=0x55fe2ae5ddc8, status=7 '\a') at /home/liufeng/workspace/src/open/qemu/hw/net/virtio-net.c:224
#8  0x000055fe29527b89 in virtio_set_status (vdev=0x55fe2ae5ddc8, val=7 '\a') at /home/liufeng/workspace/src/open/qemu/hw/virtio/virtio.c:748
#9  0x000055fe2976a6eb in virtio_ioport_write (opaque=0x55fe2ae55aa0, addr=18, val=7) at hw/virtio/virtio-pci.c:428
#10 0x000055fe2976ab46 in virtio_pci_config_write (opaque=0x55fe2ae55aa0, addr=18, val=7, size=1) at hw/virtio/virtio-pci.c:553
#11 0x000055fe294c67dd in memory_region_write_accessor (mr=0x55fe2ae56320, addr=18, value=0x7f6d3fd9a848, size=1, shift=0, mask=255, attrs=...) at /home/liufeng/workspace/src/open/qemu/memory.c:525
#12 0x000055fe294c69e8 in access_with_adjusted_size (addr=18, value=0x7f6d3fd9a848, size=1, access_size_min=1, access_size_max=4, access=0x55fe294c66fc <memory_region_write_accessor>, mr=0x55fe2ae56320, attrs=...)
    at /home/liufeng/workspace/src/open/qemu/memory.c:591
#13 0x000055fe294c962f in memory_region_dispatch_write (mr=0x55fe2ae56320, addr=18, data=7, size=1, attrs=...) at /home/liufeng/workspace/src/open/qemu/memory.c:1273
#14 0x000055fe2947b724 in address_space_write_continue (as=0x55fe29e205c0 <address_space_io>, addr=49170, attrs=..., buf=0x7f6d4ba38000 "\aE\003", len=1, addr1=18, l=1, mr=0x55fe2ae56320)
    at /home/liufeng/workspace/src/open/qemu/exec.c:2619
#15 0x000055fe2947b89a in address_space_write (as=0x55fe29e205c0 <address_space_io>, addr=49170, attrs=..., buf=0x7f6d4ba38000 "\aE\003", len=1) at /home/liufeng/workspace/src/open/qemu/exec.c:2665
#16 0x000055fe2947bc51 in address_space_rw (as=0x55fe29e205c0 <address_space_io>, addr=49170, attrs=..., buf=0x7f6d4ba38000 "\aE\003", len=1, is_write=true) at /home/liufeng/workspace/src/open/qemu/exec.c:2768
#17 0x000055fe294c2d64 in kvm_handle_io (port=49170, attrs=..., data=0x7f6d4ba38000, direction=1, size=1, count=1) at /home/liufeng/workspace/src/open/qemu/kvm-all.c:1699
#18 0x000055fe294c3264 in kvm_cpu_exec (cpu=0x55fe2ae8ef50) at /home/liufeng/workspace/src/open/qemu/kvm-all.c:1863
#19 0x000055fe294aa8b8 in qemu_kvm_cpu_thread_fn (arg=0x55fe2ae8ef50) at /home/liufeng/workspace/src/open/qemu/cpus.c:1064
#20 0x00007f6d47187dc5 in start_thread () from /lib64/libpthread.so.0
#21 0x00007f6d46eb4ced in clone () from /lib64/libc.so.6
展开阅读全文

Linux新增API:eventfd

07-25

<p>n <span style="font-size:18px;">Linux系统提供了各种系统调用API用于进程之间的通信:</span>n</p>n<p>n </p><ul><li>n <span style="font-size:16px;">    无名管道PIPE</span>n </li>n <li>n <span style="font-size:16px;">    命名管道FIFO</span>n </li>n <li>n <span style="font-size:16px;">    消息队列</span>n </li>n <li>n <span style="font-size:16px;">    共享内存</span>n </li>n <li>n <span style="font-size:16px;">    信号量</span>n </li>n <li>n <span style="font-size:16px;">    文件锁</span>n </li>n <li>n <span style="font-size:16px;">    信号signal....</span>n </li>n </ul><p>n <span style="font-size:18px;">其中还包括system V和POSIX 两种接口标准,除此之外,Linux系统自身还扩展了自己的一套API接口用于进程间通信,比如signalfd、timerfd、eventfd等。</span>n</p>n<p>n <br /></p>n<p>n <span style="font-size:18px;">本视频教程为《Linux系统编程》第05期,本期课程将会带领大家学习Linux下将近15种进程间通信IPC工具的使用,了解它们的通信机制、编程实例、使用场景、内核中的实现以及各自的优缺点。</span>n</p>n<p>n <br /></p>n<p>n <span style="font-size:14px;background-color:#CCCCCC;">本课程会提供PDF版本的PPT课件和代码,学员购买课程后可到课程主页自行下载</span>n</p>n<p>n <span style="font-size:18px;"><br /></span>n</p>n<p>n <span style="font-size:18px;"><br /></span>n</p>n<p>n <span style="font-size:18px;">n </span></p><p>n <span style="background-color:#FF9900;">嵌入式自学路线指导图</span>:n </p>n <p>n ------------------------------------------------------------------------------------------------------n </p>n <p>n                    《<strong>嵌入式工程师自我修养</strong>》嵌入式自学系列教程n </p>n <p>n                                           作者:王利涛n </p>n <p>n ------------------------------------------------------------------------------------------------------n </p>n <p>n 一线嵌入式工程师精心打造,嵌入式学习路线六步走: n </p>n <p>n <br /></p>n <p>n <span style="background-color:#60D978;">第 1 步:Linux三剑客</span>n </p>n <ul><li>n <p>n <span style="font-size:16px;">零基础玩转Linux+Ubuntu</span>n </p>n </li>n <li>n <p>n <span style="font-size:16px;">Git零基础实战:Linux开发技能标配</span>n </p>n </li>n <li>n <p>n <span style="font-size:16px;">vim从入门到精通基础篇:零基础学习vim基本命令</span>n </p>n </li>n <li>n <p>n <span style="font-size:16px;">vim从入门到精通定制篇:使用插件打造嵌入式开发IDE</span>n </p>n </li>n <li>n <p>n <span style="font-size:16px;">makefile工程实践基础篇:从零开始一步一步写项目的Makefile</span>n </p>n </li>n <li>n <p>n <span style="font-size:16px;">makefile工程实践第2季:使用Autotools自动生成Makefile</span>n </p>n </li>n <li>n <p>n <span style="font-size:16px;">软件调试基础理论</span>n </p>n </li>n <li>n <p>n <span style="font-size:16px;">printf打印技巧</span>n </p>n </li>n <li>n <p>n <span style="font-size:16px;">Linux内核日志与打印</span>n </p>n </li>n <li>n <p>n <span style="font-size:16px;">使用QEMU搭建u-boot+Linux+NFS嵌入式开发环境</span>n </p>n </li>n </ul><p>n <span style="background-color:#60D978;">第 2 步:C语言嵌入式Linux高级编程</span>n </p>n <ul><li>n <p>n <span style="font-size:16px;">第1期:C语言进阶学习路线指南</span>n </p>n </li>n <li>n <p>n <span style="font-size:16px;">第2期:计算机架构与ARM汇编程序设计</span>n </p>n </li>n <li>n <p>n <span style="font-size:16px;">第3期:程序的编译、链接和运行原理</span>n </p>n </li>n <li>n <p>n <span style="font-size:16px;">第4期:堆栈内存管理</span>n </p>n </li>n <li>n <p>n <span style="font-size:16px;">第6期:数据存储与指针</span>n </p>n </li>n <li>n <p>n <span style="font-size:16px;">第7期:嵌入式数据结构与Linux内核的OOP思想</span>n </p>n </li>n <li>n <p>n <span style="font-size:16px;">第8期:C语言的模块化编程</span>n </p>n </li>n <li>n <p>n <span style="font-size:16px;">第9期:CPU和操作系统入门</span>n </p>n </li>n </ul><p>n       搞内核驱动开发、光会C语言是不行的!n </p>n <p>n       你还需要学习的有很多,包括:计算机体系架构、ARM汇编、程序的编译链接运行原理、CPU和操作系统原理、堆栈内存管理、指针、linux内核中的面向对象思想、嵌入式系统架构、C语言的模块化编程.....n </p>n <p>n <br /></p>n <p>n <span style="background-color:#60D978;">第 3 步:Linux系统编程</span>n </p>n <ul><li>n <p>n <span style="font-size:16px;">第00期:Linux系统编程入门</span>n </p>n </li>n <li>n <p>n <span style="font-size:16px;">第01期:揭开文件系统的神秘面纱</span>n </p>n </li>n <li>n <p>n <span style="font-size:16px;">第02期:文件I/O编程实战</span>n </p>n </li>n <li>n <p>n <span style="font-size:16px;">第03期:I/O缓存与内存映射</span>n </p>n </li>n <li>n <p>n <span style="font-size:16px;">第04期:打通进程与终端的任督二脉</span>n </p>n </li>n <li>n <p>n <span style="background-color:#E53333;font-size:16px;">第05期:进程间通信-------------------we are here!‍</span>n </p>n </li>n </ul><p>n     n </p>n <p>n <span style="background-color:#60D978;">第 4 步:Linux内核编程‍</span>n </p>n <p>n     练乾坤大挪移,会不会九阳神功,是一道坎。搞驱动内核开发,懂不懂内核也是一道坎。n </p>n <p>n <span style="background-color:#60D978;">第 5 步:嵌入式驱动开发</span>n </p>n <p>n     芯片原理、datasheet、硬件电路、调试手段、总线协议、内核机制、框架流程....n </p>n <p>n <span style="background-color:#60D978;">第 6 步:项目实战</span>n </p>n <p>n     嵌入式、嵌入式人工智能、物联网、智能家居...n </p>n<br />n

没有更多推荐了,返回首页