2.6.36.4 の spinlock.h の spin_lock & spin_unlock API を修正したい。コアでロックが取得されるたびに、spin_lock が呼び出されたときにそのカウンターがインクリメントおよびデクリメントされるように、コアごとにカウンターを追加したいと考えています。いつでも各コアの lock_depth を取得できます。
CPUごとの変数を追加して、これを試しました。使用するDECLARE_PER_CPU(int, crnt_lck_depth)
が、これを行うには、#include percpu.h
どのインターンシップを使用する必要がありましたか#includes spinlock.h
そのため、配列を作成してそれぞれのインデックスに書き込むことで回避策を実行しましたが、これを行うには、実行中のスレッドの cpu を使用する必要がありcpu_id()
、依存関係の同じ問題が発生しました。
これまでに spinlock.h で行ったことは次のとおりです。
static int ctr_lock_depth[24];
EXPORT_SYMBOL(ctr_lock_depth);//ctr_depth is used by my module
/* from smp.h */
extern int raw_smp_processor_id(void);
static inline void spin_lock(spinlock_t *lock)
{
int cpu;
raw_spin_lock(&lock->rlock);
cpu = raw_smp_processor_id();
ctr_lock_depth[cpu]++;
}
static inline void spin_unlock(spinlock_t *lock)
{
int cpu ;
raw_spin_unlock(&lock->rlock);
cpu = raw_smp_processor_id();
ctr_lock_depth[cpu]--;
}
そして、これらは私が得る警告/エラーです
include/linux/spinlock.h:292:1: warning: data definition has no type or storage class
include/linux/spinlock.h:292:1: warning: type defaults to ‘int’ in declaration of ‘EXPORT_SYMBOL’
include/linux/spinlock.h:292:1: warning: parameter names (without types) in function declaration
include/linux/timex.h:76:17: error: field ‘time’ has incomplete type
In file included from include/linux/ktime.h:25:0,
from include/linux/timer.h:5,
from include/linux/workqueue.h:8,
from include/linux/pm.h:25,
from /usr/src/linux-2.6.36.4.kvm-rr/arch/x86/include/asm/apic.h:6,
from /usr/src/linux-2.6.36.4.kvm-rr/arch/x86/include/asm/smp.h:13,
from include/linux/spinlock.h:62,
from include/linux/seqlock.h:29,
from include/linux/time.h:8,
from include/linux/stat.h:60,
from include/linux/module.h:10,
from include/linux/crypto.h:21,
from arch/x86/kernel/asm-offsets_64.c:8,
from arch/x86/kernel/asm-offsets.c:4:
include/linux/jiffies.h:257:10: warning: "NSEC_PER_SEC" is not defined
include/linux/ktime.h:84:6: error: ‘NSEC_PER_SEC’ undeclared (first use in this function)
include/linux/time.h:240:23: error: conflicting types for ‘ns_to_timeval’
include/linux/ktime.h:294:22: note: previous implicit declaration of ‘ns_to_timeval’ was here
何か間違っていますか?同じことを行うための他の簡単な方法はありますか。
ありがとう、シャラン