subr_prof.c (110530) | subr_prof.c (111032) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)subr_prof.c 8.3 (Berkeley) 9/23/93 | 1/*- 2 * Copyright (c) 1982, 1986, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)subr_prof.c 8.3 (Berkeley) 9/23/93 |
34 * $FreeBSD: head/sys/kern/subr_prof.c 110530 2003-02-08 02:58:16Z julian $ | 34 * $FreeBSD: head/sys/kern/subr_prof.c 111032 2003-02-17 09:55:10Z julian $ |
35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/sysproto.h> 40#include <sys/kernel.h> 41#include <sys/lock.h> 42#include <sys/mutex.h> --- 430 unchanged lines hidden (view full) --- 473 * and copyout will work. Trap will then call addupc_task(). 474 * 475 * Note that we may (rarely) not get around to the AST soon enough, and 476 * lose profile ticks when the next tick overwrites this one, but in this 477 * case the system is overloaded and the profile is probably already 478 * inaccurate. 479 */ 480void | 35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/sysproto.h> 40#include <sys/kernel.h> 41#include <sys/lock.h> 42#include <sys/mutex.h> --- 430 unchanged lines hidden (view full) --- 473 * and copyout will work. Trap will then call addupc_task(). 474 * 475 * Note that we may (rarely) not get around to the AST soon enough, and 476 * lose profile ticks when the next tick overwrites this one, but in this 477 * case the system is overloaded and the profile is probably already 478 * inaccurate. 479 */ 480void |
481addupc_intr(struct kse *ke, uintptr_t pc, u_int ticks) | 481addupc_intr(struct thread *td, uintptr_t pc, u_int ticks) |
482{ 483 struct uprof *prof; 484 caddr_t addr; 485 u_int i; 486 int v; 487 488 if (ticks == 0) 489 return; | 482{ 483 struct uprof *prof; 484 caddr_t addr; 485 u_int i; 486 int v; 487 488 if (ticks == 0) 489 return; |
490 prof = &ke->ke_proc->p_stats->p_prof; | 490 prof = &td->td_proc->p_stats->p_prof; |
491 if (pc < prof->pr_off || 492 (i = PC_TO_INDEX(pc, prof)) >= prof->pr_size) 493 return; /* out of range; ignore */ 494 495 addr = prof->pr_base + i; 496 if ((v = fuswintr(addr)) == -1 || suswintr(addr, v + ticks) == -1) { 497 mtx_lock_spin(&sched_lock); 498 prof->pr_addr = pc; 499 prof->pr_ticks = ticks; | 491 if (pc < prof->pr_off || 492 (i = PC_TO_INDEX(pc, prof)) >= prof->pr_size) 493 return; /* out of range; ignore */ 494 495 addr = prof->pr_base + i; 496 if ((v = fuswintr(addr)) == -1 || suswintr(addr, v + ticks) == -1) { 497 mtx_lock_spin(&sched_lock); 498 prof->pr_addr = pc; 499 prof->pr_ticks = ticks; |
500 ke->ke_flags |= KEF_OWEUPC | KEF_ASTPENDING ; | 500 td->td_flags |= TDF_OWEUPC | TDF_ASTPENDING ; |
501 mtx_unlock_spin(&sched_lock); 502 } 503} 504 505/* 506 * Much like before, but we can afford to take faults here. If the 507 * update fails, we simply turn off profiling. 508 * XXXKSE, don't use kse unless we got sched lock. 509 */ 510void | 501 mtx_unlock_spin(&sched_lock); 502 } 503} 504 505/* 506 * Much like before, but we can afford to take faults here. If the 507 * update fails, we simply turn off profiling. 508 * XXXKSE, don't use kse unless we got sched lock. 509 */ 510void |
511addupc_task(struct kse *ke, uintptr_t pc, u_int ticks) | 511addupc_task(struct thread *td, uintptr_t pc, u_int ticks) |
512{ | 512{ |
513 struct proc *p = ke->ke_proc; | 513 struct proc *p = td->td_proc; |
514 struct uprof *prof; 515 caddr_t addr; 516 u_int i; 517 u_short v; 518 int stop = 0; 519 520 if (ticks == 0) 521 return; --- 83 unchanged lines hidden --- | 514 struct uprof *prof; 515 caddr_t addr; 516 u_int i; 517 u_short v; 518 int stop = 0; 519 520 if (ticks == 0) 521 return; --- 83 unchanged lines hidden --- |