Deleted Added
full compact
hwpmc_mod.c (168856) hwpmc_mod.c (170307)
1/*-
2 * Copyright (c) 2003-2006 Joseph Koshy
3 * 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

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

21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27
28#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2003-2006 Joseph Koshy
3 * 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

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

21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/dev/hwpmc/hwpmc_mod.c 168856 2007-04-19 08:02:51Z jkoshy $");
29__FBSDID("$FreeBSD: head/sys/dev/hwpmc/hwpmc_mod.c 170307 2007-06-05 00:00:57Z jeff $");
30
31#include <sys/param.h>
32#include <sys/eventhandler.h>
33#include <sys/jail.h>
34#include <sys/kernel.h>
35#include <sys/kthread.h>
36#include <sys/limits.h>
37#include <sys/lock.h>

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

586/*
587 * save the cpu binding of the current kthread
588 */
589
590static void
591pmc_save_cpu_binding(struct pmc_binding *pb)
592{
593 PMCDBG(CPU,BND,2, "%s", "save-cpu");
30
31#include <sys/param.h>
32#include <sys/eventhandler.h>
33#include <sys/jail.h>
34#include <sys/kernel.h>
35#include <sys/kthread.h>
36#include <sys/limits.h>
37#include <sys/lock.h>

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

586/*
587 * save the cpu binding of the current kthread
588 */
589
590static void
591pmc_save_cpu_binding(struct pmc_binding *pb)
592{
593 PMCDBG(CPU,BND,2, "%s", "save-cpu");
594 mtx_lock_spin(&sched_lock);
594 thread_lock(curthread);
595 pb->pb_bound = sched_is_bound(curthread);
596 pb->pb_cpu = curthread->td_oncpu;
595 pb->pb_bound = sched_is_bound(curthread);
596 pb->pb_cpu = curthread->td_oncpu;
597 mtx_unlock_spin(&sched_lock);
597 thread_unlock(curthread);
598 PMCDBG(CPU,BND,2, "save-cpu cpu=%d", pb->pb_cpu);
599}
600
601/*
602 * restore the cpu binding of the current thread
603 */
604
605static void
606pmc_restore_cpu_binding(struct pmc_binding *pb)
607{
608 PMCDBG(CPU,BND,2, "restore-cpu curcpu=%d restore=%d",
609 curthread->td_oncpu, pb->pb_cpu);
598 PMCDBG(CPU,BND,2, "save-cpu cpu=%d", pb->pb_cpu);
599}
600
601/*
602 * restore the cpu binding of the current thread
603 */
604
605static void
606pmc_restore_cpu_binding(struct pmc_binding *pb)
607{
608 PMCDBG(CPU,BND,2, "restore-cpu curcpu=%d restore=%d",
609 curthread->td_oncpu, pb->pb_cpu);
610 mtx_lock_spin(&sched_lock);
610 thread_lock(curthread);
611 if (pb->pb_bound)
612 sched_bind(curthread, pb->pb_cpu);
613 else
614 sched_unbind(curthread);
611 if (pb->pb_bound)
612 sched_bind(curthread, pb->pb_cpu);
613 else
614 sched_unbind(curthread);
615 mtx_unlock_spin(&sched_lock);
615 thread_unlock(curthread);
616 PMCDBG(CPU,BND,2, "%s", "restore-cpu done");
617}
618
619/*
620 * move execution over the specified cpu and bind it there.
621 */
622
623static void
624pmc_select_cpu(int cpu)
625{
626 KASSERT(cpu >= 0 && cpu < mp_ncpus,
627 ("[pmc,%d] bad cpu number %d", __LINE__, cpu));
628
629 /* never move to a disabled CPU */
630 KASSERT(pmc_cpu_is_disabled(cpu) == 0, ("[pmc,%d] selecting "
631 "disabled CPU %d", __LINE__, cpu));
632
633 PMCDBG(CPU,SEL,2, "select-cpu cpu=%d", cpu);
616 PMCDBG(CPU,BND,2, "%s", "restore-cpu done");
617}
618
619/*
620 * move execution over the specified cpu and bind it there.
621 */
622
623static void
624pmc_select_cpu(int cpu)
625{
626 KASSERT(cpu >= 0 && cpu < mp_ncpus,
627 ("[pmc,%d] bad cpu number %d", __LINE__, cpu));
628
629 /* never move to a disabled CPU */
630 KASSERT(pmc_cpu_is_disabled(cpu) == 0, ("[pmc,%d] selecting "
631 "disabled CPU %d", __LINE__, cpu));
632
633 PMCDBG(CPU,SEL,2, "select-cpu cpu=%d", cpu);
634 mtx_lock_spin(&sched_lock);
634 thread_lock(curthread);
635 sched_bind(curthread, cpu);
635 sched_bind(curthread, cpu);
636 mtx_unlock_spin(&sched_lock);
636 thread_unlock(curthread);
637
638 KASSERT(curthread->td_oncpu == cpu,
639 ("[pmc,%d] CPU not bound [cpu=%d, curr=%d]", __LINE__,
640 cpu, curthread->td_oncpu));
641
642 PMCDBG(CPU,SEL,2, "select-cpu cpu=%d ok", cpu);
643}
644

--- 3762 unchanged lines hidden ---
637
638 KASSERT(curthread->td_oncpu == cpu,
639 ("[pmc,%d] CPU not bound [cpu=%d, curr=%d]", __LINE__,
640 cpu, curthread->td_oncpu));
641
642 PMCDBG(CPU,SEL,2, "select-cpu cpu=%d ok", cpu);
643}
644

--- 3762 unchanged lines hidden ---