summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2017-05-28 08:47:20 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2017-05-28 08:47:20 +0000
commit02164be5ffe440367e0a159beefb2270646ef451 (patch)
tree088c2bb39851e18dfbc15512469d636384f97c4f
parent8f3a655d89ddc0772c029acecae025c47a7d2dbd (diff)
Use intr_disable()/intr_restore() to reduce differences with sparc64
mp_lock. ok kettenis@, visa@
-rw-r--r--sys/arch/amd64/amd64/lock_machdep.c20
-rw-r--r--sys/arch/i386/i386/lock_machdep.c20
2 files changed, 20 insertions, 20 deletions
diff --git a/sys/arch/amd64/amd64/lock_machdep.c b/sys/arch/amd64/amd64/lock_machdep.c
index cec96af1987..5943c3b4b5e 100644
--- a/sys/arch/amd64/amd64/lock_machdep.c
+++ b/sys/arch/amd64/amd64/lock_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lock_machdep.c,v 1.14 2017/04/30 16:45:45 mpi Exp $ */
+/* $OpenBSD: lock_machdep.c,v 1.15 2017/05/28 08:47:19 mpi Exp $ */
/*
* Copyright (c) 2007 Artur Grabowski <art@openbsd.org>
@@ -70,7 +70,7 @@ void
___mp_lock(struct __mp_lock *mpl LOCK_FL_VARS)
{
struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()];
- long rf = read_rflags();
+ unsigned long s;
#ifdef WITNESS
int lock_held;
@@ -80,10 +80,10 @@ ___mp_lock(struct __mp_lock *mpl LOCK_FL_VARS)
LOP_EXCLUSIVE | LOP_NEWORDER, file, line, NULL);
#endif
- disable_intr();
+ s = intr_disable();
if (cpu->mplc_depth++ == 0)
cpu->mplc_ticket = atomic_inc_int_nv(&mpl->mpl_users);
- write_rflags(rf);
+ intr_restore(s);
__mp_lock_spin(mpl, cpu->mplc_ticket);
@@ -94,7 +94,7 @@ void
___mp_unlock(struct __mp_lock *mpl LOCK_FL_VARS)
{
struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()];
- long rf = read_rflags();
+ unsigned long s;
#ifdef MP_LOCKDEBUG
if (!__mp_lock_held(mpl)) {
@@ -105,23 +105,23 @@ ___mp_unlock(struct __mp_lock *mpl LOCK_FL_VARS)
WITNESS_UNLOCK(&mpl->mpl_lock_obj, LOP_EXCLUSIVE, file, line);
- disable_intr();
+ s = intr_disable();
if (--cpu->mplc_depth == 0)
mpl->mpl_ticket++;
- write_rflags(rf);
+ intr_restore(s);
}
int
___mp_release_all(struct __mp_lock *mpl LOCK_FL_VARS)
{
struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()];
- long rf = read_rflags();
+ unsigned long s;
int rv;
#ifdef WITNESS
int i;
#endif
- disable_intr();
+ s = intr_disable();
rv = cpu->mplc_depth;
#ifdef WITNESS
for (i = 0; i < rv; i++)
@@ -129,7 +129,7 @@ ___mp_release_all(struct __mp_lock *mpl LOCK_FL_VARS)
#endif
cpu->mplc_depth = 0;
mpl->mpl_ticket++;
- write_rflags(rf);
+ intr_restore(s);
return (rv);
}
diff --git a/sys/arch/i386/i386/lock_machdep.c b/sys/arch/i386/i386/lock_machdep.c
index 74f631f2f49..92e9fe6e84c 100644
--- a/sys/arch/i386/i386/lock_machdep.c
+++ b/sys/arch/i386/i386/lock_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lock_machdep.c,v 1.23 2017/04/30 16:45:45 mpi Exp $ */
+/* $OpenBSD: lock_machdep.c,v 1.24 2017/05/28 08:47:19 mpi Exp $ */
/* $NetBSD: lock_machdep.c,v 1.1.2.3 2000/05/03 14:40:30 sommerfeld Exp $ */
/*-
@@ -89,7 +89,7 @@ void
___mp_lock(struct __mp_lock *mpl LOCK_FL_VARS)
{
struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()];
- long ef = read_eflags();
+ unsigned long s;
#ifdef WITNESS
int lock_held;
@@ -99,10 +99,10 @@ ___mp_lock(struct __mp_lock *mpl LOCK_FL_VARS)
LOP_EXCLUSIVE | LOP_NEWORDER, file, line, NULL);
#endif
- disable_intr();
+ s = intr_disable();
if (cpu->mplc_depth++ == 0)
cpu->mplc_ticket = atomic_inc_int_nv(&mpl->mpl_users);
- write_eflags(ef);
+ intr_restore(s);
__mp_lock_spin(mpl, cpu->mplc_ticket);
@@ -113,7 +113,7 @@ void
___mp_unlock(struct __mp_lock *mpl LOCK_FL_VARS)
{
struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()];
- int ef = read_eflags();
+ unsigned long s;
#ifdef MP_LOCKDEBUG
if (!__mp_lock_held(mpl)) {
@@ -124,23 +124,23 @@ ___mp_unlock(struct __mp_lock *mpl LOCK_FL_VARS)
WITNESS_UNLOCK(&mpl->mpl_lock_obj, LOP_EXCLUSIVE, file, line);
- disable_intr();
+ s = intr_disable();
if (--cpu->mplc_depth == 0)
mpl->mpl_ticket++;
- write_eflags(ef);
+ intr_restore(s);
}
int
___mp_release_all(struct __mp_lock *mpl LOCK_FL_VARS)
{
struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()];
- int ef = read_eflags();
+ unsigned long s;
int rv;
#ifdef WITNESS
int i;
#endif
- disable_intr();
+ s = intr_disable();
rv = cpu->mplc_depth;
#ifdef WITNESS
for (i = 0; i < rv; i++)
@@ -148,7 +148,7 @@ ___mp_release_all(struct __mp_lock *mpl LOCK_FL_VARS)
#endif
cpu->mplc_depth = 0;
mpl->mpl_ticket++;
- write_eflags(ef);
+ intr_restore(s);
return (rv);
}