insmod: ERROR: could not insert module *.ko: Unknown symbol in module

问题:

         在实际编译运行  什么是RCU :API      中的例子 rcu_example时报错

[root@centosgpt rcu]# insmod list_rcu.ko
insmod: ERROR: could not insert module list_rcu.ko: Unknown symbol in module
[root@centosgpt rcu]# dmesg|tail
[13084.720516] list_rcu: Unknown symbol synchronize_rcu (err -2)
[13084.720561] list_rcu: Unknown symbol call_rcu (err -2)

原因:

       在写代码的时候漏掉了原来例子中的  MODULE_LICENSE(“GPL”);

       __class_create函数仅为 GPL模块导出(标记为使用 EXPORT_SYMBOL_GPL导出)的模块, 需要使用MODULE_LICENSE(“GPL”),才能使用相关功能。

/kernel/rcu/tree.c
...
void synchronize_rcu(void)
{
	RCU_LOCKDEP_WARN(lock_is_held(&rcu_bh_lock_map) ||
			 lock_is_held(&rcu_lock_map) ||
			 lock_is_held(&rcu_sched_lock_map),
			 "Illegal synchronize_rcu() in RCU read-side critical section");
	if (rcu_blocking_is_gp())
		return;
	if (rcu_gp_is_expedited())
		synchronize_rcu_expedited();
	else
		wait_rcu_gp(call_rcu);
}
EXPORT_SYMBOL_GPL(synchronize_rcu);
...
void call_rcu(struct rcu_head *head, rcu_callback_t func)
{
	__call_rcu(head, func, -1, 0);
}
EXPORT_SYMBOL_GPL(call_rcu);

参考:

How to Resolve – insmod: ERROR: could not insert module hello.ko: Unknown symbol in module – unknown symbol class_unregister

unknown-symbol-class-create-err-0

 

Be First to Comment

发表回复