Backout experimental adaptive-spin umtx code.
This commit is contained in:
parent
3eb2cf672b
commit
3a1a57d0eb
@ -203,9 +203,7 @@ sw1:
|
||||
movq %rbx, (%rax)
|
||||
movq %rbx, PCPU(RSP0)
|
||||
|
||||
movl TD_TID(%rsi), %eax
|
||||
movq %r8, PCPU(CURPCB)
|
||||
movl %eax, PCPU(CURTID)
|
||||
movq %rsi, PCPU(CURTHREAD) /* into next thread */
|
||||
|
||||
testl $PCB_32BIT,PCB_FLAGS(%r8)
|
||||
|
@ -194,7 +194,6 @@ ASSYM(PC_SCRATCH_RSP, offsetof(struct pcpu, pc_scratch_rsp));
|
||||
ASSYM(PC_CURPMAP, offsetof(struct pcpu, pc_curpmap));
|
||||
ASSYM(PC_TSSP, offsetof(struct pcpu, pc_tssp));
|
||||
ASSYM(PC_RSP0, offsetof(struct pcpu, pc_rsp0));
|
||||
ASSYM(PC_CURTID, offsetof(struct pcpu, pc_curtid));
|
||||
|
||||
ASSYM(LA_VER, offsetof(struct LAPIC, version));
|
||||
ASSYM(LA_TPR, offsetof(struct LAPIC, tpr));
|
||||
|
@ -1179,7 +1179,6 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
|
||||
PCPU_SET(prvspace, pc);
|
||||
PCPU_SET(curthread, &thread0);
|
||||
PCPU_SET(curpcb, thread0.td_pcb);
|
||||
PCPU_SET(curtid, thread0.td_tid);
|
||||
PCPU_SET(tssp, &common_tss[0]);
|
||||
|
||||
/*
|
||||
|
@ -199,7 +199,6 @@ ASSYM(PC_CURRENTLDT, offsetof(struct pcpu, pc_currentldt));
|
||||
ASSYM(PC_CPUID, offsetof(struct pcpu, pc_cpuid));
|
||||
ASSYM(PC_CURPMAP, offsetof(struct pcpu, pc_curpmap));
|
||||
ASSYM(PC_PRIVATE_TSS, offsetof(struct pcpu, pc_private_tss));
|
||||
ASSYM(PC_CURTID, offsetof(struct pcpu, pc_curtid));
|
||||
|
||||
#ifdef DEV_APIC
|
||||
ASSYM(LA_VER, offsetof(struct LAPIC, version));
|
||||
|
@ -2118,7 +2118,6 @@ init386(first)
|
||||
PCPU_SET(prvspace, pc);
|
||||
PCPU_SET(curthread, &thread0);
|
||||
PCPU_SET(curpcb, thread0.td_pcb);
|
||||
PCPU_SET(curtid, thread0.td_tid);
|
||||
|
||||
/*
|
||||
* Initialize mutexes.
|
||||
|
@ -247,7 +247,6 @@ sw1:
|
||||
movl %edx, PCPU(CURPCB)
|
||||
movl TD_TID(%ecx),%eax
|
||||
movl %ecx, PCPU(CURTHREAD) /* into next thread */
|
||||
movl %eax, PCPU(CURTID)
|
||||
|
||||
/*
|
||||
* Determine the LDT to use and load it if is the default one and
|
||||
|
@ -193,13 +193,6 @@ static int umtx_pi_allocated;
|
||||
SYSCTL_NODE(_debug, OID_AUTO, umtx, CTLFLAG_RW, 0, "umtx debug");
|
||||
SYSCTL_INT(_debug_umtx, OID_AUTO, umtx_pi_allocated, CTLFLAG_RD,
|
||||
&umtx_pi_allocated, 0, "Allocated umtx_pi");
|
||||
SYSCTL_DECL(_kern_threads);
|
||||
static int umtx_dflt_spins = 0;
|
||||
SYSCTL_INT(_kern_threads, OID_AUTO, umtx_dflt_spins, CTLFLAG_RW,
|
||||
&umtx_dflt_spins, 0, "default umtx spin count");
|
||||
static int umtx_max_spins = 3000;
|
||||
SYSCTL_INT(_kern_threads, OID_AUTO, umtx_max_spins, CTLFLAG_RW,
|
||||
&umtx_max_spins, 0, "max umtx spin count");
|
||||
|
||||
static void umtxq_sysinit(void *);
|
||||
static void umtxq_hash(struct umtx_key *key);
|
||||
@ -1025,33 +1018,16 @@ _do_lock_normal(struct thread *td, struct umutex *m, uint32_t flags, int timo,
|
||||
{
|
||||
struct umtx_q *uq;
|
||||
uint32_t owner, old, id;
|
||||
#ifdef SMP
|
||||
int spincount;
|
||||
#endif
|
||||
int error = 0;
|
||||
|
||||
id = td->td_tid;
|
||||
uq = td->td_umtxq;
|
||||
|
||||
#ifdef SMP
|
||||
if (smp_cpus > 1) {
|
||||
spincount = fuword32(&m->m_spincount);
|
||||
if (spincount == 0)
|
||||
spincount = umtx_dflt_spins;
|
||||
if (spincount > umtx_max_spins)
|
||||
spincount = umtx_max_spins;
|
||||
} else
|
||||
spincount = 0;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Care must be exercised when dealing with umtx structure. It
|
||||
* can fault on any access.
|
||||
*/
|
||||
for (;;) {
|
||||
#ifdef SMP
|
||||
try_unowned:
|
||||
#endif
|
||||
/*
|
||||
* Try the uncontested case. This should be done in userland.
|
||||
*/
|
||||
@ -1067,9 +1043,6 @@ _do_lock_normal(struct thread *td, struct umutex *m, uint32_t flags, int timo,
|
||||
|
||||
/* If no one owns it but it is contested try to acquire it. */
|
||||
if (owner == UMUTEX_CONTESTED) {
|
||||
#ifdef SMP
|
||||
try_contested:
|
||||
#endif
|
||||
owner = casuword32(&m->m_owner,
|
||||
UMUTEX_CONTESTED, id | UMUTEX_CONTESTED);
|
||||
|
||||
@ -1091,46 +1064,6 @@ _do_lock_normal(struct thread *td, struct umutex *m, uint32_t flags, int timo,
|
||||
if (try != 0)
|
||||
return (EBUSY);
|
||||
|
||||
#ifdef SMP
|
||||
if (spincount > 0 && (owner & ~UMUTEX_CONTESTED) != id) {
|
||||
int i, found = 0;
|
||||
struct pcpu *pcpu = NULL;
|
||||
|
||||
/* Look for a cpu the owner is running on */
|
||||
for (i = 0; i < MAXCPU; i++) {
|
||||
if (CPU_ABSENT(i))
|
||||
continue;
|
||||
pcpu = pcpu_find(i);
|
||||
if ((owner & ~UMUTEX_CONTESTED) == pcpu->pc_curtid) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (__predict_false(!found))
|
||||
goto end_spin;
|
||||
|
||||
while ((owner & ~UMUTEX_CONTESTED) == pcpu->pc_curtid &&
|
||||
(owner & ~UMUTEX_CONTESTED) != id) {
|
||||
if (--spincount <= 0)
|
||||
break;
|
||||
if ((td->td_flags &
|
||||
(TDF_NEEDRESCHED|TDF_ASTPENDING|TDF_NEEDSIGCHK)) ||
|
||||
P_SHOULDSTOP(td->td_proc))
|
||||
break;
|
||||
owner = fuword32(__DEVOLATILE(uint32_t *, &m->m_owner));
|
||||
if (owner == UMUTEX_UNOWNED)
|
||||
goto try_unowned;
|
||||
if (owner == UMUTEX_CONTESTED)
|
||||
goto try_contested;
|
||||
cpu_spinwait();
|
||||
}
|
||||
}
|
||||
end_spin:
|
||||
spincount = 0;
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If we caught a signal, we have retried and now
|
||||
* exit immediately.
|
||||
|
@ -74,7 +74,6 @@ struct pcpu {
|
||||
PCPU_MD_FIELDS;
|
||||
struct vmmeter pc_cnt; /* VM stats counters */
|
||||
struct device *pc_device;
|
||||
lwpid_t pc_curtid;
|
||||
};
|
||||
|
||||
SLIST_HEAD(cpuhead, pcpu);
|
||||
|
@ -57,8 +57,7 @@ struct umutex {
|
||||
volatile __lwpid_t m_owner; /* Owner of the mutex */
|
||||
uint32_t m_flags; /* Flags of the mutex */
|
||||
uint32_t m_ceilings[2]; /* Priority protect ceiling */
|
||||
uint32_t m_spincount; /* Max spinning cycle */
|
||||
uint32_t m_spare[3];
|
||||
uint32_t m_spare[4];
|
||||
};
|
||||
|
||||
struct ucond {
|
||||
|
Loading…
Reference in New Issue
Block a user