• linux 下__iomem 解析【转】


    转自:https://blog.csdn.net/u014470361/article/details/80682101

    -iomem解析
    在看Linux的i2s源码时,里面有个定义:void __iomem *base;
    这个__iomem是个什么东西,蒙蔽了。在include/linux/compile.h这个文件查看其宏定义为:

    #ifdef __CHECKER__
    # define __user __attribute__((noderef, address_space(1)))
    # define __kernel __attribute__((address_space(0)))
    # define __safe __attribute__((safe))
    # define __force __attribute__((force))
    # define __nocast __attribute__((nocast))
    # define __iomem __attribute__((noderef, address_space(2)))
    # define __must_hold(x) __attribute__((context(x,1,1)))
    # define __acquires(x) __attribute__((context(x,0,1)))
    # define __releases(x) __attribute__((context(x,1,0)))
    # define __acquire(x) __context__(x,1)
    # define __release(x) __context__(x,-1)
    # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
    # define __percpu __attribute__((noderef, address_space(3)))
    #ifdef CONFIG_SPARSE_RCU_POINTER
    # define __rcu __attribute__((noderef, address_space(4)))
    #else
    # define __rcu
    #endif

    iomem这个特性,即__attribute((noderef, address_space(2))),attribute是用来修饰一个变量的,这个变量必须是非解除参考(no dereference)的,即这个变量地址必须是有效的,而且变量所在的地址空间必须是2,即io存储空间。
    0.1.2.3分别对应四个空间
    address_space(v)
    ————————————-
    v: 0 内核空间
    v: 1 用户空间
    v: 2 io存储空间
    v: 3 cpu空间
    那这个address_space(4)又是啥呢,查了一些资料,如下:

    # define __rcu __attribute__((noderef, address_space(4)))
    1
    RCU代表的是 “read, copy, update”。它是一种算法,允许多个读者访问数据,并且同时允许修改者,删除者能够进行操作。

    如果内核使用 CONFIG_SPARSE_RCU_POINTER 的编译, __rcu 就会被定义为上面的定义。

    这是一种标记,可以给Sparse code 分析工具来对于某些东西进行警告。

    引用 http://stackoverflow.com/questions/17128210/what-does-rcu-stands-for-in-linux

    可以知道: __rcu sparse 检查:使用__rcu 附上 RCU保护的数据结构,如果你没有使用rcu_dereference()类中某个函数,Sparse就会警告你这个操作。


    ————————————————
    版权声明:本文为CSDN博主「夜风~」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/u014470361/java/article/details/80682101

  • 相关阅读:
    tensorflow模型保存和使用08
    LSTM最基本的应用(07-3)
    手写数字识别-卷积神经网络cnn(06-2)
    python面向对象笔记
    attention机制
    dockerfile
    docker入门
    CentOS7安装Oracle11gR2
    anaconda常用的命令
    python xlrd处理表格常用方法
  • 原文地址:https://www.cnblogs.com/sky-heaven/p/12677707.html
Copyright © 2020-2023  润新知