perfmon: base code
PATCH 2/24 perfmon: base code
This patch adds the core functions of the perfmon subsystem. It creates the toplevel perfmon subdirectory where all perfmon generic code lives. Core functions implements initialization, session allocation and termination.
Signed-off-by Stephane Eranian <[email protected]>
--
perfmon/perfmon_attach.c new file +86 -0
@@ -0,0 +1,86 @@ +/* +* perfmon_attach.c: perfmon2 load/unload functions +* +* This file implements the perfmon2 interface which +* provides access to the hardware performance counters +* of the host processor. +* +* +* The initial version of perfmon.c was written by +* Ganesh Venkitachalam, IBM Corp. +* +* Then it was modified for perfmon-1.x by Stephane Eranian and +* David Mosberger, Hewlett Packard Co. +* +* Version Perfmon-2.x is a complete rewrite of perfmon-1.x +* by Stephane Eranian, Hewlett Packard Co. +* +* Copyright (c) 1999-2006 Hewlett-Packard Development Company, L.P. +* Contributed by Stephane Eranian <[email protected]> +* David Mosberger-Tang <[email protected]> +* +* More information about perfmon available at: +* http://www.hpl.hp.com/research/linux/perfmon +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of version 2 of the GNU General Public +* License as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +* 02111-1307 USA +*/ +#include <linux/kernel.h> +#include <linux/fs.h> +#include <linux/perfmon_kern.h> +#include "perfmon_priv.h" + +/** +* __pfm_exit_thread - detach and free context on thread exit +*/ +void __pfm_exit_thread (void ) +{ +struct pfm_context *ctx; +unsigned long flags; +int free_ok =0 , ret =-1 ; + + ctx = current->pfm_context; + +spin_lock_irqsave (&ctx->lock, flags); + +PFM_DBG ("state=%d is_self=%d" , ctx->state, ctx->flags.is_self); + +/* +* __pfm_unload_context() cannot fail +* in the context states we are interested in +*/ +switch (ctx->state) { +case PFM_CTX_LOADED : + ret =__pfm_unload_context (ctx); +break ; +case PFM_CTX_ZOMBIE : + ret =__pfm_unload_context (ctx); + free_ok =1 ; +break ; +default : +BUG_ON (ctx->state !=PFM_CTX_LOADED ); +break ; + } +spin_unlock_irqrestore (&ctx->lock, flags); + +if (!ret) +pfm_session_release (); + +/* +* All memory free operations (especially for vmalloc'ed memory) +* MUST be done with interrupts ENABLED. +*/ +if (free_ok) +pfm_free_context (ctx); +}
perfmon/perfmon_ctx.c new file +164 -0
164 lines not on this page · raw message
perfmon/perfmon_file.c new file +94 -0
94 lines not on this page · raw message
perfmon/perfmon_init.c new file +84 -0
84 lines not on this page · raw message
perfmon/perfmon_priv.h new file +110 -0
110 lines not on this page · raw message
perfmon/perfmon_res.c new file +105 -0
105 lines not on this page · raw message
include/linux/sched.h +3 -0
@@ -1352,6 +1352,9 @@unsigned long default_timer_slack_ns;struct list_head *scm_work_list; +#ifdef CONFIG_PERFMON +struct pfm_context *pfm_context; +#endif };/*