kern_mutex.c (278693) | kern_mutex.c (278694) |
---|---|
1/*- 2 * Copyright (c) 1998 Berkeley Software Design, Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 20 unchanged lines hidden (view full) --- 29 * and BSDI $Id: synch_machdep.c,v 2.3.2.39 2000/04/27 03:10:25 cp Exp $ 30 */ 31 32/* 33 * Machine independent bits of mutex implementation. 34 */ 35 36#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1998 Berkeley Software Design, Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 20 unchanged lines hidden (view full) --- 29 * and BSDI $Id: synch_machdep.c,v 2.3.2.39 2000/04/27 03:10:25 cp Exp $ 30 */ 31 32/* 33 * Machine independent bits of mutex implementation. 34 */ 35 36#include <sys/cdefs.h> |
37__FBSDID("$FreeBSD: stable/10/sys/kern/kern_mutex.c 278693 2015-02-13 18:45:44Z sbruno $"); | 37__FBSDID("$FreeBSD: stable/10/sys/kern/kern_mutex.c 278694 2015-02-13 19:06:22Z sbruno $"); |
38 39#include "opt_adaptive_mutexes.h" 40#include "opt_ddb.h" 41#include "opt_global.h" 42#include "opt_hwpmc_hooks.h" 43#include "opt_kdtrace.h" 44#include "opt_sched.h" 45 --- 385 unchanged lines hidden (view full) --- 431 v = m->mtx_lock; 432 if (v != MTX_UNOWNED) { 433 owner = (struct thread *)(v & ~MTX_FLAGMASK); 434 if (TD_IS_RUNNING(owner)) { 435 if (LOCK_LOG_TEST(&m->lock_object, 0)) 436 CTR3(KTR_LOCK, 437 "%s: spinning on %p held by %p", 438 __func__, m, owner); | 38 39#include "opt_adaptive_mutexes.h" 40#include "opt_ddb.h" 41#include "opt_global.h" 42#include "opt_hwpmc_hooks.h" 43#include "opt_kdtrace.h" 44#include "opt_sched.h" 45 --- 385 unchanged lines hidden (view full) --- 431 v = m->mtx_lock; 432 if (v != MTX_UNOWNED) { 433 owner = (struct thread *)(v & ~MTX_FLAGMASK); 434 if (TD_IS_RUNNING(owner)) { 435 if (LOCK_LOG_TEST(&m->lock_object, 0)) 436 CTR3(KTR_LOCK, 437 "%s: spinning on %p held by %p", 438 __func__, m, owner); |
439 KTR_STATE1(KTR_SCHED, "thread", 440 sched_tdname((struct thread *)tid), 441 "spinning", "lockname:\"%s\"", 442 m->lock_object.lo_name); |
|
439 while (mtx_owner(m) == owner && 440 TD_IS_RUNNING(owner)) { 441 cpu_spinwait(); 442#ifdef KDTRACE_HOOKS 443 spin_cnt++; 444#endif 445 } | 443 while (mtx_owner(m) == owner && 444 TD_IS_RUNNING(owner)) { 445 cpu_spinwait(); 446#ifdef KDTRACE_HOOKS 447 spin_cnt++; 448#endif 449 } |
450 KTR_STATE0(KTR_SCHED, "thread", 451 sched_tdname((struct thread *)tid), 452 "running"); |
|
446 continue; 447 } 448 } 449#endif 450 451 ts = turnstile_trywait(&m->lock_object); 452 v = m->mtx_lock; 453 --- 120 unchanged lines hidden (view full) --- 574 575 if (SCHEDULER_STOPPED()) 576 return; 577 578 m = mtxlock2mtx(c); 579 580 if (LOCK_LOG_TEST(&m->lock_object, opts)) 581 CTR1(KTR_LOCK, "_mtx_lock_spin: %p spinning", m); | 453 continue; 454 } 455 } 456#endif 457 458 ts = turnstile_trywait(&m->lock_object); 459 v = m->mtx_lock; 460 --- 120 unchanged lines hidden (view full) --- 581 582 if (SCHEDULER_STOPPED()) 583 return; 584 585 m = mtxlock2mtx(c); 586 587 if (LOCK_LOG_TEST(&m->lock_object, opts)) 588 CTR1(KTR_LOCK, "_mtx_lock_spin: %p spinning", m); |
589 KTR_STATE1(KTR_SCHED, "thread", sched_tdname((struct thread *)tid), 590 "spinning", "lockname:\"%s\"", m->lock_object.lo_name); |
|
582 583#ifdef HWPMC_HOOKS 584 PMC_SOFT_CALL( , , lock, failed); 585#endif 586 lock_profile_obtain_lock_failed(&m->lock_object, &contested, &waittime); 587 while (!_mtx_obtain_lock(m, tid)) { 588 589 /* Give interrupts a chance while we spin. */ --- 9 unchanged lines hidden (view full) --- 599 _mtx_lock_spin_failed(m); 600 cpu_spinwait(); 601 } 602 spinlock_enter(); 603 } 604 605 if (LOCK_LOG_TEST(&m->lock_object, opts)) 606 CTR1(KTR_LOCK, "_mtx_lock_spin: %p spin done", m); | 591 592#ifdef HWPMC_HOOKS 593 PMC_SOFT_CALL( , , lock, failed); 594#endif 595 lock_profile_obtain_lock_failed(&m->lock_object, &contested, &waittime); 596 while (!_mtx_obtain_lock(m, tid)) { 597 598 /* Give interrupts a chance while we spin. */ --- 9 unchanged lines hidden (view full) --- 608 _mtx_lock_spin_failed(m); 609 cpu_spinwait(); 610 } 611 spinlock_enter(); 612 } 613 614 if (LOCK_LOG_TEST(&m->lock_object, opts)) 615 CTR1(KTR_LOCK, "_mtx_lock_spin: %p spin done", m); |
616 KTR_STATE0(KTR_SCHED, "thread", sched_tdname((struct thread *)tid), 617 "running"); |
|
607 608 LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_SPIN_LOCK_ACQUIRE, m, 609 contested, waittime, (file), (line)); 610 LOCKSTAT_RECORD1(LS_MTX_SPIN_LOCK_SPIN, m, i); 611} 612#endif /* SMP */ 613 614void --- 395 unchanged lines hidden --- | 618 619 LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(LS_MTX_SPIN_LOCK_ACQUIRE, m, 620 contested, waittime, (file), (line)); 621 LOCKSTAT_RECORD1(LS_MTX_SPIN_LOCK_SPIN, m, i); 622} 623#endif /* SMP */ 624 625void --- 395 unchanged lines hidden --- |