gcc show "Need native word sized stores/loads for atomicity" 用于调用 `hlist_nulls_add_head_rcu`

gcc show "Need native word sized stores/loads for atomicity" for calling `hlist_nulls_add_head_rcu`

我想调用 hlist_nulls_add_head_rcu 来管理我的列表,但是 gcc 给出了很多如下错误信息:

|| ./include/linux/rculist_nulls.h: In function ‘hlist_nulls_add_head_rcu’:
/home/river/Desktop/kernel/linux-4.9.82/./include/linux/compiler.h|518 col 38| error: call to ‘__compiletime_assert_97’ declared with attribute error: Need native word sized stores/loads for atomicity.
||   _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
||                                       ^
/home/river/Desktop/kernel/linux-4.9.82/./include/linux/compiler.h|501 col 4| note: in definition of macro ‘__compiletime_assert’
||     prefix ## suffix();    \
||     ^~~~~~
/home/river/Desktop/kernel/linux-4.9.82/./include/linux/compiler.h|518 col 2| note: in expansion of macro ‘_compiletime_assert’
||   _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
||   ^~~~~~~~~~~~~~~~~~~
/home/river/Desktop/kernel/linux-4.9.82/./include/linux/compiler.h|521 col 2| note: in expansion of macro ‘compiletime_assert’
||   compiletime_assert(__native_word(t),    \
||   ^~~~~~~~~~~~~~~~~~
/home/river/Desktop/kernel/linux-4.9.82/./arch/x86/include/asm/barrier.h|92 col 2| note: in expansion of macro ‘compiletime_assert_atomic_type’
||   compiletime_assert_atomic_type(*p);    \
||   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/river/Desktop/kernel/linux-4.9.82/./include/asm-generic/barrier.h|157 col 33| note: in expansion of macro ‘__smp_store_release’
||  #define smp_store_release(p, v) __smp_store_release(p, v)
||                                  ^~~~~~~~~~~~~~~~~~~
/home/river/Desktop/kernel/linux-4.9.82/./include/linux/rcupdate.h|672 col 3| note: in expansion of macro ‘smp_store_release’
||    smp_store_release(&p, RCU_INITIALIZER((typeof(p))_r_a_p__v)); \
||    ^~~~~~~~~~~~~~~~~
/home/river/Desktop/kernel/linux-4.9.82/./include/linux/rculist_nulls.h|97 col 2| note: in expansion of macro ‘rcu_assign_pointer’
||   rcu_assign_pointer(hlist_nulls_first_rcu(h), n);
||   ^~~~~~~~~~~~~~~~~~

我觉得最有用的留言是第一条:

/include/linux/compiler.h|518 col 38| error: call to ‘__compiletime_assert_97’ declared with attribute error: Need native word sized stores/loads for atomicity.

那么在我的模块中调用hlist_nulls_add_head_rcu的语句是:

hlist_nulls_add_head_rcu( &kcnew->hnnode,
        &kp_sock_lists[kp_hash(kcnew->sock)] );

参数类型正确,可能是调用方式错误。有谁知道如何使用 hlist_nulls_add_head_rcu?

ccflags-y 中删除 -O0

RCU编译需要编译优化