Deleted Added
full compact
hwpmc_logging.c (267992) hwpmc_logging.c (277177)
1/*-
2 * Copyright (c) 2005-2007 Joseph Koshy
3 * Copyright (c) 2007 The FreeBSD Foundation
4 * All rights reserved.
5 *
6 * Portions of this software were developed by A. Joseph Koshy under
7 * sponsorship from the FreeBSD Foundation and Google, Inc.
8 *

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

29 *
30 */
31
32/*
33 * Logging code for hwpmc(4)
34 */
35
36#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2005-2007 Joseph Koshy
3 * Copyright (c) 2007 The FreeBSD Foundation
4 * All rights reserved.
5 *
6 * Portions of this software were developed by A. Joseph Koshy under
7 * sponsorship from the FreeBSD Foundation and Google, Inc.
8 *

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

29 *
30 */
31
32/*
33 * Logging code for hwpmc(4)
34 */
35
36#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: head/sys/dev/hwpmc/hwpmc_logging.c 267992 2014-06-28 03:56:17Z hselasky $");
37__FBSDID("$FreeBSD: head/sys/dev/hwpmc/hwpmc_logging.c 277177 2015-01-14 12:46:58Z rrs $");
38
39#include <sys/param.h>
38
39#include <sys/param.h>
40#if (__FreeBSD_version >= 1100000)
40#include <sys/capsicum.h>
41#include <sys/capsicum.h>
42#endif
41#include <sys/file.h>
42#include <sys/kernel.h>
43#include <sys/kthread.h>
44#include <sys/lock.h>
45#include <sys/module.h>
46#include <sys/mutex.h>
47#include <sys/pmc.h>
48#include <sys/pmckern.h>

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

563 * owner process. This file needs to have been opened for writing.
564 */
565
566int
567pmclog_configure_log(struct pmc_mdep *md, struct pmc_owner *po, int logfd)
568{
569 int error;
570 struct proc *p;
43#include <sys/file.h>
44#include <sys/kernel.h>
45#include <sys/kthread.h>
46#include <sys/lock.h>
47#include <sys/module.h>
48#include <sys/mutex.h>
49#include <sys/pmc.h>
50#include <sys/pmckern.h>

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

565 * owner process. This file needs to have been opened for writing.
566 */
567
568int
569pmclog_configure_log(struct pmc_mdep *md, struct pmc_owner *po, int logfd)
570{
571 int error;
572 struct proc *p;
573#if (__FreeBSD_version >= 1100000)
571 cap_rights_t rights;
574 cap_rights_t rights;
572
575#endif
573 /*
574 * As long as it is possible to get a LOR between pmc_sx lock and
575 * proctree/allproc sx locks used for adding a new process, assure
576 * the former is not held here.
577 */
578 sx_assert(&pmc_sx, SA_UNLOCKED);
579 PMCDBG(LOG,CFG,1, "config po=%p logfd=%d", po, logfd);
580

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

587 KASSERT(po->po_kthread == NULL,
588 ("[pmclog,%d] po=%p kthread (%p) already present", __LINE__, po,
589 po->po_kthread));
590 KASSERT(po->po_file == NULL,
591 ("[pmclog,%d] po=%p file (%p) already present", __LINE__, po,
592 po->po_file));
593
594 /* get a reference to the file state */
576 /*
577 * As long as it is possible to get a LOR between pmc_sx lock and
578 * proctree/allproc sx locks used for adding a new process, assure
579 * the former is not held here.
580 */
581 sx_assert(&pmc_sx, SA_UNLOCKED);
582 PMCDBG(LOG,CFG,1, "config po=%p logfd=%d", po, logfd);
583

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

590 KASSERT(po->po_kthread == NULL,
591 ("[pmclog,%d] po=%p kthread (%p) already present", __LINE__, po,
592 po->po_kthread));
593 KASSERT(po->po_file == NULL,
594 ("[pmclog,%d] po=%p file (%p) already present", __LINE__, po,
595 po->po_file));
596
597 /* get a reference to the file state */
598#if (__FreeBSD_version >= 1100000)
595 error = fget_write(curthread, logfd,
596 cap_rights_init(&rights, CAP_WRITE), &po->po_file);
597 if (error)
598 goto error;
599 error = fget_write(curthread, logfd,
600 cap_rights_init(&rights, CAP_WRITE), &po->po_file);
601 if (error)
602 goto error;
599
603#endif
600 /* mark process as owning a log file */
601 po->po_flags |= PMC_PO_OWNS_LOGFILE;
602 error = kproc_create(pmclog_loop, po, &po->po_kthread,
603 RFHIGHPID, 0, "hwpmc: proc(%d)", p->p_pid);
604 if (error)
605 goto error;
606
607 /* mark process as using HWPMCs */

--- 463 unchanged lines hidden ---
604 /* mark process as owning a log file */
605 po->po_flags |= PMC_PO_OWNS_LOGFILE;
606 error = kproc_create(pmclog_loop, po, &po->po_kthread,
607 RFHIGHPID, 0, "hwpmc: proc(%d)", p->p_pid);
608 if (error)
609 goto error;
610
611 /* mark process as using HWPMCs */

--- 463 unchanged lines hidden ---