From 63f0426fdf707cc22d636e630d4c53cc808d777e Mon Sep 17 00:00:00 2001 From: fengbojiang Date: Thu, 16 Sep 2021 15:30:22 +0800 Subject: [PATCH] fix some issues. --- freebsd/sys/counter.h | 2 ++ lib/ff_freebsd_init.c | 1 + lib/include/amd64/include/counter.h | 6 +++++- lib/include/amd64/include/pcpu.h | 3 +++ lib/include/sys/mutex.h | 6 ++++++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/freebsd/sys/counter.h b/freebsd/sys/counter.h index 3e1b7828d..e9feb7ca5 100644 --- a/freebsd/sys/counter.h +++ b/freebsd/sys/counter.h @@ -80,9 +80,11 @@ int64_t counter_ratecheck(struct counter_rate *, int64_t); SYSUNINIT(c##_counter_sysuninit, SI_SUB_COUNTER, \ SI_ORDER_ANY, counter_u64_sysuninit, &c) +#ifndef FSTACK #define COUNTER_U64_DEFINE_EARLY(c) \ counter_u64_t __read_mostly c = EARLY_COUNTER; \ COUNTER_U64_SYSINIT(c) +#endif void counter_u64_sysinit(void *); void counter_u64_sysuninit(void *); diff --git a/lib/ff_freebsd_init.c b/lib/ff_freebsd_init.c index 992f23b1b..711fc3e3a 100644 --- a/lib/ff_freebsd_init.c +++ b/lib/ff_freebsd_init.c @@ -96,6 +96,7 @@ ff_freebsd_init(void) pcpup = malloc(sizeof(struct pcpu), M_DEVBUF, M_ZERO); pcpu_init(pcpup, 0, sizeof(struct pcpu)); + PCPU_SET(prvspace, pcpup); CPU_SET(0, &all_cpus); ff_init_thread0(); diff --git a/lib/include/amd64/include/counter.h b/lib/include/amd64/include/counter.h index ba606e1c3..1951969a7 100644 --- a/lib/include/amd64/include/counter.h +++ b/lib/include/amd64/include/counter.h @@ -29,7 +29,11 @@ #include -#define EARLY_COUNTER (void *)__offsetof(struct pcpu, pc_early_dummy_counter) +#define EARLY_COUNTER &pcpup->pc_early_dummy_counter + +#define COUNTER_U64_DEFINE_EARLY(c) \ + counter_u64_t __read_mostly c = (void *)__offsetof(struct pcpu, pc_early_dummy_counter); \ + COUNTER_U64_SYSINIT(c) #define counter_enter() do {} while (0) #define counter_exit() do {} while (0) diff --git a/lib/include/amd64/include/pcpu.h b/lib/include/amd64/include/pcpu.h index 5d72f4218..c65f45b9b 100644 --- a/lib/include/amd64/include/pcpu.h +++ b/lib/include/amd64/include/pcpu.h @@ -31,6 +31,7 @@ #include_next #undef __curthread +#undef get_pcpu #undef PCPU_GET #undef PCPU_ADD #undef PCPU_INC @@ -40,6 +41,8 @@ extern __thread struct thread *pcurthread; extern struct pcpu *pcpup; +#define get_pcpu() (pcpup->pc_ ## prvspace) + #define PCPU_GET(member) (pcpup->pc_ ## member) #define PCPU_ADD(member, val) (pcpup->pc_ ## member += (val)) #define PCPU_INC(member) PCPU_ADD(member, 1) diff --git a/lib/include/sys/mutex.h b/lib/include/sys/mutex.h index c51033d28..0a8e22e1e 100644 --- a/lib/include/sys/mutex.h +++ b/lib/include/sys/mutex.h @@ -51,6 +51,9 @@ #undef mtx_destroy #undef mtx_owned +#undef DROP_GIANT +#undef PICKUP_GIANT + #define DO_NOTHING do {} while(0) #define __mtx_lock(mp, tid, opts, file, line) DO_NOTHING @@ -81,4 +84,7 @@ void ff_mtx_init(struct lock_object *lo, const char *name, const char *type, int #define mtx_owned(m) (1) +#define DROP_GIANT() DO_NOTHING +#define PICKUP_GIANT() DO_NOTHING + #endif /* _FSTACK_SYS_MUTEX_H_ */