Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F153856009
D21747.id62407.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D21747.id62407.diff
View Options
Index: sys/kern/subr_lock.c
===================================================================
--- sys/kern/subr_lock.c
+++ sys/kern/subr_lock.c
@@ -241,7 +241,9 @@
struct lock_prof_type lpc_types[2]; /* One for spin one for other. */
};
-struct lock_prof_cpu *lp_cpu[MAXCPU];
+DPCPU_DEFINE_STATIC(struct lock_prof_cpu, lp);
+#define LP_CPU_SELF (DPCPU_PTR(lp))
+#define LP_CPU(cpu) (DPCPU_ID_PTR((cpu), lp))
volatile int __read_mostly lock_prof_enable;
static volatile int lock_prof_resetting;
@@ -288,10 +290,8 @@
int cpu;
CPU_FOREACH(cpu) {
- lp_cpu[cpu] = malloc(sizeof(*lp_cpu[cpu]), M_DEVBUF,
- M_WAITOK | M_ZERO);
- lock_prof_init_type(&lp_cpu[cpu]->lpc_types[0]);
- lock_prof_init_type(&lp_cpu[cpu]->lpc_types[1]);
+ lock_prof_init_type(&LP_CPU(cpu)->lpc_types[0]);
+ lock_prof_init_type(&LP_CPU(cpu)->lpc_types[1]);
}
}
SYSINIT(lockprof, SI_SUB_SMP, SI_ORDER_ANY, lock_prof_init, NULL);
@@ -355,14 +355,14 @@
* into per-thread lists as well.
*/
CPU_FOREACH(cpu) {
- lpc = lp_cpu[cpu];
+ lpc = LP_CPU(cpu);
for (i = 0; i < LPROF_CACHE_SIZE; i++) {
LIST_REMOVE(&lpc->lpc_types[0].lpt_objs[i], lpo_link);
LIST_REMOVE(&lpc->lpc_types[1].lpt_objs[i], lpo_link);
}
}
CPU_FOREACH(cpu) {
- lpc = lp_cpu[cpu];
+ lpc = LP_CPU(cpu);
bzero(lpc, sizeof(*lpc));
lock_prof_init_type(&lpc->lpc_types[0]);
lock_prof_init_type(&lpc->lpc_types[1]);
@@ -406,7 +406,7 @@
dst->name = match->name;
CPU_FOREACH(cpu) {
- type = &lp_cpu[cpu]->lpc_types[spin];
+ type = &LP_CPU(cpu)->lpc_types[spin];
SLIST_FOREACH(l, &type->lpt_hash[hash], link) {
if (l->ticks == t)
continue;
@@ -469,8 +469,8 @@
}
t = ticks;
CPU_FOREACH(cpu) {
- lock_prof_type_stats(&lp_cpu[cpu]->lpc_types[0], sb, 0, t);
- lock_prof_type_stats(&lp_cpu[cpu]->lpc_types[1], sb, 1, t);
+ lock_prof_type_stats(&LP_CPU(cpu)->lpc_types[0], sb, 0, t);
+ lock_prof_type_stats(&LP_CPU(cpu)->lpc_types[1], sb, 1, t);
}
atomic_thread_fence_rel();
lock_prof_enable = enabled;
@@ -537,7 +537,7 @@
p = unknown;
hash = (uintptr_t)lo->lo_name * 31 + (uintptr_t)p * 31 + line;
hash &= LPROF_HASH_MASK;
- type = &lp_cpu[PCPU_GET(cpuid)]->lpc_types[spin];
+ type = &LP_CPU_SELF->lpc_types[spin];
head = &type->lpt_hash[hash];
SLIST_FOREACH(lp, head, link) {
if (lp->line == line && lp->file == p &&
@@ -572,7 +572,7 @@
if (l->lpo_obj == lo && l->lpo_file == file &&
l->lpo_line == line)
return (l);
- type = &lp_cpu[PCPU_GET(cpuid)]->lpc_types[spin];
+ type = &LP_CPU_SELF->lpc_types[spin];
l = LIST_FIRST(&type->lpt_lpoalloc);
if (l == NULL) {
lock_prof_rejected++;
@@ -712,7 +712,7 @@
lp->cnt_cur += l->lpo_cnt;
release:
LIST_REMOVE(l, lpo_link);
- type = &lp_cpu[PCPU_GET(cpuid)]->lpc_types[spin];
+ type = &LP_CPU_SELF->lpc_types[spin];
LIST_INSERT_HEAD(&type->lpt_lpoalloc, l, lpo_link);
out:
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 25, 7:08 AM (18 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32115758
Default Alt Text
D21747.id62407.diff (2 KB)
Attached To
Mode
D21747: lockprof: move per-cpu data to dpcpu
Attached
Detach File
Event Timeline
Log In to Comment