问如何在list_for_each_entry_rcu中删除元素EN我们说不能在foreach 中进行,但是使用普通的for 循环还...
* the newly deleted entry. Instead, either synchronize_rcu() * or call_rcu() must be used to defer freeing until an RCU * grace period has elapsed. */staticinlinevoidlist_del_rcu(struct list_head*entry){__list_del_entry(entry);entry->prev=LIST_POISON2;}staticinlinevoid__list_del_ent...
rcu_read_lock; //遍历当前的bdi_list所有的bdi设备 list_for_each_entry_rcu(bdi, &bdi_list, bdi_list) { structbdi_writeback*wb; if(!bdi_has_dirty_io(bdi)) continue; //遍历当前bdi设备中wb_list存储的所有wb list_for_each_entry_rcu(wb, &bdi->wb_list, bdi_node) wb_start_writeback(...
staticinlinevoidlist_del_rcu(structlist_head*entry) 1. 函数, 就是 从 链表中 删除元素 的 函数 ; list_del_rcu 函数中 , 主要是调用了 __list_del_entry 函数 , 在__list_del_entry 函数中 , 又调用了 __list_del 函数 ; ...
list_for_each_entry作用 综上所述,我们可以了解到list_for_each_entry的作用:所有包含list_head的数据结构,均可使用此方法遍历链表;list_head结构体不包含数据部分,使用该函数进行遍历链表节点,然后在循环体中,对链表的数据部分进行读写操作,这就是list_for_each_entry的共通性 通过对链表中list成员的遍历,即可...
#define list_for_each_entry(pos, head, member) …… 与list_for_each()不同,这里的pos是数据项结构指针类型,而不是(struct list_head *)。nf_register_sockopt()函数可以利用这个宏而设计得更简单: …… struct nf_sockopt_ops *ops; list_for_each_entry(ops,&nf_sockopts,list){ …… } …… ...
static inline void list_del(structlist_head *entry) { __list_del(entry->prev,entry->next); entry->next = LIST_POISON1; entry->prev = LIST_POISON2; } 3.3: 安全的删除指定项: static inline void list_del_rcu(structlist_head *entry) ...
* using the generic single-entry routines. * 有一些内部函数("__xxx")是非常有用的当你操纵整个链表而不是 * 单个条目的时候。因为有的时候我们已经知道下一个条目并且我们可以 * 通过直接使用他们而不是使用普遍的单条目程序来生成更好的代码。
本文从最基本的内核链表出发,引出初始化INIT_LIST_HEAD函数,然后介绍list_add,通过改变链表位置的问题引出list_for_each函数,然后为了获取容器结构地址,引出offsetof和container_of宏,并对内核链表设计原因作出了解释,一步步引导到list_for_each_entry,然后介绍list_del函数,通过在遍历时list_del链表的不安全行为,引出li...
对于给定一个结构,offsetof(type,member)是一个常量,list_entry()正是利用这个不变的偏移量来求得链表数据项的变量地址。 b) 遍历宏 在[net/core/netfilter.c]的nf_register_sockopt()函数中有这么一段话: …… struct list_head *i; …… list_for_each(i, &nf_sockopts) { ...