Deleted Added
full compact
subr_prof.c (169803) subr_prof.c (170307)
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

--- 16 unchanged lines hidden (view full) ---

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)subr_prof.c 8.3 (Berkeley) 9/23/93
30 */
31
32#include <sys/cdefs.h>
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

--- 16 unchanged lines hidden (view full) ---

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)subr_prof.c 8.3 (Berkeley) 9/23/93
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/kern/subr_prof.c 169803 2007-05-20 22:11:50Z jeff $");
33__FBSDID("$FreeBSD: head/sys/kern/subr_prof.c 170307 2007-06-05 00:00:57Z jeff $");
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/sysproto.h>
38#include <sys/kernel.h>
39#include <sys/lock.h>
40#include <sys/mutex.h>
41#include <sys/proc.h>

--- 376 unchanged lines hidden (view full) ---

418 if (uap->scale == 0) {
419 PROC_LOCK(p);
420 stopprofclock(p);
421 PROC_UNLOCK(p);
422 return (0);
423 }
424 PROC_LOCK(p);
425 upp = &td->td_proc->p_stats->p_prof;
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/sysproto.h>
38#include <sys/kernel.h>
39#include <sys/lock.h>
40#include <sys/mutex.h>
41#include <sys/proc.h>

--- 376 unchanged lines hidden (view full) ---

418 if (uap->scale == 0) {
419 PROC_LOCK(p);
420 stopprofclock(p);
421 PROC_UNLOCK(p);
422 return (0);
423 }
424 PROC_LOCK(p);
425 upp = &td->td_proc->p_stats->p_prof;
426 mtx_lock_spin(&time_lock);
426 PROC_SLOCK(p);
427 upp->pr_off = uap->offset;
428 upp->pr_scale = uap->scale;
429 upp->pr_base = uap->samples;
430 upp->pr_size = uap->size;
427 upp->pr_off = uap->offset;
428 upp->pr_scale = uap->scale;
429 upp->pr_base = uap->samples;
430 upp->pr_size = uap->size;
431 mtx_unlock_spin(&time_lock);
431 PROC_SUNLOCK(p);
432 startprofclock(p);
433 PROC_UNLOCK(p);
434
435 return (0);
436}
437
438/*
439 * Scale is a fixed-point number with the binary point 16 bits

--- 23 unchanged lines hidden (view full) ---

463 struct uprof *prof;
464 caddr_t addr;
465 u_int i;
466 int v;
467
468 if (ticks == 0)
469 return;
470 prof = &td->td_proc->p_stats->p_prof;
432 startprofclock(p);
433 PROC_UNLOCK(p);
434
435 return (0);
436}
437
438/*
439 * Scale is a fixed-point number with the binary point 16 bits

--- 23 unchanged lines hidden (view full) ---

463 struct uprof *prof;
464 caddr_t addr;
465 u_int i;
466 int v;
467
468 if (ticks == 0)
469 return;
470 prof = &td->td_proc->p_stats->p_prof;
471 mtx_lock_spin(&time_lock);
471 PROC_SLOCK(td->td_proc);
472 if (pc < prof->pr_off ||
473 (i = PC_TO_INDEX(pc, prof)) >= prof->pr_size) {
472 if (pc < prof->pr_off ||
473 (i = PC_TO_INDEX(pc, prof)) >= prof->pr_size) {
474 mtx_unlock_spin(&time_lock);
474 PROC_SUNLOCK(td->td_proc);
475 return; /* out of range; ignore */
476 }
477
478 addr = prof->pr_base + i;
475 return; /* out of range; ignore */
476 }
477
478 addr = prof->pr_base + i;
479 mtx_unlock_spin(&time_lock);
479 PROC_SUNLOCK(td->td_proc);
480 if ((v = fuswintr(addr)) == -1 || suswintr(addr, v + ticks) == -1) {
481 td->td_profil_addr = pc;
482 td->td_profil_ticks = ticks;
483 td->td_pflags |= TDP_OWEUPC;
480 if ((v = fuswintr(addr)) == -1 || suswintr(addr, v + ticks) == -1) {
481 td->td_profil_addr = pc;
482 td->td_profil_ticks = ticks;
483 td->td_pflags |= TDP_OWEUPC;
484 mtx_lock_spin(&sched_lock);
484 thread_lock(td);
485 td->td_flags |= TDF_ASTPENDING;
485 td->td_flags |= TDF_ASTPENDING;
486 mtx_unlock_spin(&sched_lock);
486 thread_unlock(td);
487 }
488}
489
490/*
491 * Much like before, but we can afford to take faults here. If the
492 * update fails, we simply turn off profiling.
493 */
494void

--- 11 unchanged lines hidden (view full) ---

506
507 PROC_LOCK(p);
508 if (!(p->p_flag & P_PROFIL)) {
509 PROC_UNLOCK(p);
510 return;
511 }
512 p->p_profthreads++;
513 prof = &p->p_stats->p_prof;
487 }
488}
489
490/*
491 * Much like before, but we can afford to take faults here. If the
492 * update fails, we simply turn off profiling.
493 */
494void

--- 11 unchanged lines hidden (view full) ---

506
507 PROC_LOCK(p);
508 if (!(p->p_flag & P_PROFIL)) {
509 PROC_UNLOCK(p);
510 return;
511 }
512 p->p_profthreads++;
513 prof = &p->p_stats->p_prof;
514 PROC_SLOCK(p);
514 if (pc < prof->pr_off ||
515 (i = PC_TO_INDEX(pc, prof)) >= prof->pr_size) {
515 if (pc < prof->pr_off ||
516 (i = PC_TO_INDEX(pc, prof)) >= prof->pr_size) {
517 PROC_SUNLOCK(p);
516 goto out;
517 }
518
519 addr = prof->pr_base + i;
518 goto out;
519 }
520
521 addr = prof->pr_base + i;
522 PROC_SUNLOCK(p);
520 PROC_UNLOCK(p);
521 if (copyin(addr, &v, sizeof(v)) == 0) {
522 v += ticks;
523 if (copyout(&v, addr, sizeof(v)) == 0) {
524 PROC_LOCK(p);
525 goto out;
526 }
527 }

--- 61 unchanged lines hidden ---
523 PROC_UNLOCK(p);
524 if (copyin(addr, &v, sizeof(v)) == 0) {
525 v += ticks;
526 if (copyout(&v, addr, sizeof(v)) == 0) {
527 PROC_LOCK(p);
528 goto out;
529 }
530 }

--- 61 unchanged lines hidden ---