-/* $OpenBSD: lock_machdep.c,v 1.6 2017/05/29 14:19:49 mpi Exp $ */
+/* $OpenBSD: lock_machdep.c,v 1.7 2017/12/04 09:51:03 mpi Exp $ */
/*
* Copyright (c) 2007 Artur Grabowski <art@openbsd.org>
}
int
-__mp_lock_held(struct __mp_lock *mpl)
+__mp_lock_held(struct __mp_lock *mpl, struct cpu_info *ci)
{
- return (mpl->mpl_cpu == curcpu());
+ return (mpl->mpl_cpu == ci);
}
-/* $OpenBSD: mplock.h,v 1.1 2014/01/26 17:40:11 miod Exp $ */
+/* $OpenBSD: mplock.h,v 1.2 2017/12/04 09:51:03 mpi Exp $ */
/*
* Copyright (c) 2004 Niklas Hallqvist. All rights reserved.
int __mp_release_all(struct __mp_lock *);
int __mp_release_all_but_one(struct __mp_lock *);
void __mp_acquire_count(struct __mp_lock *, int);
-int __mp_lock_held(struct __mp_lock *);
+int __mp_lock_held(struct __mp_lock *, struct cpu_info *);
#endif
-/* $OpenBSD: mplock.h,v 1.1 2016/12/17 23:38:33 patrick Exp $ */
+/* $OpenBSD: mplock.h,v 1.2 2017/12/04 09:51:03 mpi Exp $ */
/*
* Copyright (c) 2004 Niklas Hallqvist. All rights reserved.
int __mp_release_all(struct __mp_lock *);
int __mp_release_all_but_one(struct __mp_lock *);
void __mp_acquire_count(struct __mp_lock *, int);
-int __mp_lock_held(struct __mp_lock *);
+int __mp_lock_held(struct __mp_lock *, struct cpu_info *);
#endif
-/* $OpenBSD: lock_machdep.c,v 1.12 2017/07/16 22:48:38 guenther Exp $ */
+/* $OpenBSD: lock_machdep.c,v 1.13 2017/12/04 09:51:03 mpi Exp $ */
/*
* Copyright (c) 2007 Artur Grabowski <art@openbsd.org>
int s;
#ifdef WITNESS
- if (!__mp_lock_held(mpl))
+ if (!__mp_lock_held(mpl, curcpu()))
WITNESS_CHECKORDER(&mpl->mpl_lock_obj,
LOP_EXCLUSIVE | LOP_NEWORDER, file, line, NULL);
#endif
}
int
-__mp_lock_held(struct __mp_lock *mpl)
+__mp_lock_held(struct __mp_lock *mpl, struct cpu_info *ci)
{
- return mpl->mpl_cpu == curcpu();
+ return mpl->mpl_cpu == ci;
}
-/* $OpenBSD: mplock.h,v 1.2 2017/07/16 22:48:38 guenther Exp $ */
+/* $OpenBSD: mplock.h,v 1.3 2017/12/04 09:51:03 mpi Exp $ */
/*
* Copyright (c) 2004 Niklas Hallqvist. All rights reserved.
int ___mp_release_all(struct __mp_lock * LOCK_FL_VARS);
int ___mp_release_all_but_one(struct __mp_lock * LOCK_FL_VARS);
void ___mp_acquire_count(struct __mp_lock *, int LOCK_FL_VARS);
-int __mp_lock_held(struct __mp_lock *);
+int __mp_lock_held(struct __mp_lock *, struct cpu_info *);
#ifdef WITNESS
-/* $OpenBSD: mplock.h,v 1.2 2011/03/23 16:54:35 pirofti Exp $ */
+/* $OpenBSD: mplock.h,v 1.3 2017/12/04 09:51:03 mpi Exp $ */
/*
* Copyright (c) 2004 Niklas Hallqvist. All rights reserved.
}
static __inline__ int
-__mp_lock_held(struct __mp_lock *mpl)
+__mp_lock_held(struct __mp_lock *mpl, struct cpu_info *ci)
{
- return mpl->mpl_cpu == curcpu();
+ return mpl->mpl_cpu == ci;
}
#endif
-/* $OpenBSD: mplock.h,v 1.2 2015/06/26 11:22:12 dlg Exp $ */
+/* $OpenBSD: mplock.h,v 1.3 2017/12/04 09:51:03 mpi Exp $ */
/*
* Copyright (c) 2004 Niklas Hallqvist. All rights reserved.
int __mp_release_all(struct __mp_lock *);
int __mp_release_all_but_one(struct __mp_lock *);
void __mp_acquire_count(struct __mp_lock *, int);
-int __mp_lock_held(struct __mp_lock *);
+int __mp_lock_held(struct __mp_lock *, struct cpu_info *);
#endif
-/* $OpenBSD: lock_machdep.c,v 1.6 2017/05/29 14:19:50 mpi Exp $ */
+/* $OpenBSD: lock_machdep.c,v 1.7 2017/12/04 09:51:03 mpi Exp $ */
/*
* Copyright (c) 2007 Artur Grabowski <art@openbsd.org>
}
int
-__mp_lock_held(struct __mp_lock *mpl)
+__mp_lock_held(struct __mp_lock *mpl, struct cpu_info *ci)
{
- return mpl->mpl_cpu == curcpu();
+ return mpl->mpl_cpu == ci;
}
-/* $OpenBSD: kern_lock.c,v 1.51 2017/10/17 14:25:35 visa Exp $ */
+/* $OpenBSD: kern_lock.c,v 1.52 2017/12/04 09:51:03 mpi Exp $ */
/*
* Copyright (c) 1995
{
if (panicstr)
return 1;
- return (__mp_lock_held(&kernel_lock));
+ return (__mp_lock_held(&kernel_lock, curcpu()));
}
#ifdef __USE_MI_MPLOCK
unsigned long s;
#ifdef WITNESS
- if (!__mp_lock_held(mpl))
+ if (!__mp_lock_held(mpl, curcpu()))
WITNESS_CHECKORDER(&mpl->mpl_lock_obj,
LOP_EXCLUSIVE | LOP_NEWORDER, file, line, NULL);
#endif
unsigned long s;
#ifdef MP_LOCKDEBUG
- if (!__mp_lock_held(mpl)) {
+ if (!__mp_lock_held(mpl, curcpu())) {
db_printf("__mp_unlock(%p): not held lock\n", mpl);
db_enter();
}
#endif
#ifdef MP_LOCKDEBUG
- if (!__mp_lock_held(mpl)) {
+ if (!__mp_lock_held(mpl, curcpu())) {
db_printf("__mp_release_all_but_one(%p): not held lock\n", mpl);
db_enter();
}
}
int
-__mp_lock_held(struct __mp_lock *mpl)
+__mp_lock_held(struct __mp_lock *mpl, struct cpu_info *ci)
{
- struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[cpu_number()];
+ struct __mp_lock_cpu *cpu = &mpl->mpl_cpus[CPU_INFO_UNIT(ci)];
return (cpu->mplc_ticket == mpl->mpl_ticket && cpu->mplc_depth > 0);
}
-/* $OpenBSD: kern_proc.c,v 1.77 2017/09/29 09:36:04 mpi Exp $ */
+/* $OpenBSD: kern_proc.c,v 1.78 2017/12/04 09:51:03 mpi Exp $ */
/* $NetBSD: kern_proc.c,v 1.14 1996/02/09 18:59:41 christos Exp $ */
/*
{
char *mode;
int skipzomb = 0;
+ int has_kernel_lock = 0;
struct proc *p;
struct process *pr, *ppr;
-
+
if (modif[0] == 0)
modif[0] = 'n'; /* default == normal mode */
db_printf("\t/o == show normal info for non-idle SONPROC\n");
return;
}
-
+
pr = LIST_FIRST(&allprocess);
switch (*mode) {
ppr = pr->ps_pptr;
TAILQ_FOREACH(p, &pr->ps_threads, p_thr_link) {
+#ifdef MULTIPROCESSOR
+ if (__mp_lock_held(&kernel_lock, p->p_cpu))
+ has_kernel_lock = 1;
+ else
+ has_kernel_lock = 0;
+#endif
if (p->p_stat) {
if (*mode == 'o') {
if (p->p_stat != SONPROC)
case 'o':
db_printf("%5d %5d %#10x %#10x %3d"
- " %-31s\n",
+ "%c %-31s\n",
pr->ps_pid, pr->ps_ucred->cr_ruid,
pr->ps_flags, p->p_flag,
CPU_INFO_UNIT(p->p_cpu),
+ has_kernel_lock ? 'K' : ' ',
pr->ps_comm);
break;
-/* $OpenBSD: mplock.h,v 1.10 2017/10/17 14:25:35 visa Exp $ */
+/* $OpenBSD: mplock.h,v 1.11 2017/12/04 09:51:03 mpi Exp $ */
/*
* Copyright (c) 2004 Niklas Hallqvist. All rights reserved.
int ___mp_release_all(struct __mp_lock * LOCK_FL_VARS);
int ___mp_release_all_but_one(struct __mp_lock * LOCK_FL_VARS);
void ___mp_acquire_count(struct __mp_lock *, int LOCK_FL_VARS);
-int __mp_lock_held(struct __mp_lock *);
+int __mp_lock_held(struct __mp_lock *, struct cpu_info *);
#ifdef WITNESS
-/* $OpenBSD: sched.h,v 1.42 2017/02/14 10:31:15 mpi Exp $ */
+/* $OpenBSD: sched.h,v 1.43 2017/12/04 09:51:03 mpi Exp $ */
/* $NetBSD: sched.h,v 1.2 1999/02/28 18:14:58 ross Exp $ */
/*-
#define SCHED_ASSERT_LOCKED() \
do { \
splassert(IPL_SCHED); \
- KASSERT(__mp_lock_held(&sched_lock)); \
+ KASSERT(__mp_lock_held(&sched_lock, curcpu())); \
+} while (0)
+#define SCHED_ASSERT_UNLOCKED() \
+do { \
+ KASSERT(__mp_lock_held(&sched_lock, curcpu()) == 0); \
} while (0)
-#define SCHED_ASSERT_UNLOCKED() KASSERT(__mp_lock_held(&sched_lock) == 0)
#define SCHED_LOCK_INIT() __mp_lock_init(&sched_lock)