11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Copyright (C) 2001-2003 Hewlett-Packard Co 31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Stephane Eranian <eranian@hpl.hp.com> 41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifndef _ASM_IA64_PERFMON_H 61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define _ASM_IA64_PERFMON_H 71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 843e40f25d2c090392fc36cb900b42972e88cc2e2David Howells#include <uapi/asm/perfmon.h> 91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern long perfmonctl(int fd, int cmd, void *arg, int narg); 121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 13a1ecf7f6e65637ba4470405ad39794710dbf85d4Tony Lucktypedef struct { 14a1ecf7f6e65637ba4470405ad39794710dbf85d4Tony Luck void (*handler)(int irq, void *arg, struct pt_regs *regs); 15a1ecf7f6e65637ba4470405ad39794710dbf85d4Tony Luck} pfm_intr_handler_desc_t; 16a1ecf7f6e65637ba4470405ad39794710dbf85d4Tony Luck 171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern void pfm_save_regs (struct task_struct *); 181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern void pfm_load_regs (struct task_struct *); 191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern void pfm_exit_thread(struct task_struct *); 211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int pfm_use_debug_registers(struct task_struct *); 221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int pfm_release_debug_registers(struct task_struct *); 231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern void pfm_syst_wide_update_task(struct task_struct *, unsigned long info, int is_ctxswin); 241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern void pfm_inherit(struct task_struct *task, struct pt_regs *regs); 251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern void pfm_init_percpu(void); 261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern void pfm_handle_work(void); 27a1ecf7f6e65637ba4470405ad39794710dbf85d4Tony Luckextern int pfm_install_alt_pmu_interrupt(pfm_intr_handler_desc_t *h); 28a1ecf7f6e65637ba4470405ad39794710dbf85d4Tony Luckextern int pfm_remove_alt_pmu_interrupt(pfm_intr_handler_desc_t *h); 29a1ecf7f6e65637ba4470405ad39794710dbf85d4Tony Luck 30a1ecf7f6e65637ba4470405ad39794710dbf85d4Tony Luck 311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Reset PMD register flags 341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define PFM_PMD_SHORT_RESET 0 361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define PFM_PMD_LONG_RESET 1 371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldstypedef union { 391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int val; 401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct { 411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int notify_user:1; /* notify user program of overflow */ 421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int reset_ovfl_pmds:1; /* reset overflowed PMDs */ 431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int block_task:1; /* block monitored task on kernel exit */ 441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int mask_monitoring:1; /* mask monitors via PMCx.plm */ 451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int reserved:28; /* for future use */ 461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } bits; 471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} pfm_ovfl_ctrl_t; 481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldstypedef struct { 501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned char ovfl_pmd; /* index of overflowed PMD */ 511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned char ovfl_notify; /* =1 if monitor requested overflow notification */ 521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned short active_set; /* event set active at the time of the overflow */ 531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds pfm_ovfl_ctrl_t ovfl_ctrl; /* return: perfmon controls to set by handler */ 541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long pmd_last_reset; /* last reset value of of the PMD */ 561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long smpl_pmds[4]; /* bitmask of other PMD of interest on overflow */ 571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long smpl_pmds_values[PMU_MAX_PMDS]; /* values for the other PMDs of interest */ 581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long pmd_value; /* current 64-bit value of the PMD */ 591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long pmd_eventid; /* eventid associated with PMD */ 601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} pfm_ovfl_arg_t; 611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldstypedef struct { 641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds char *fmt_name; 651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds pfm_uuid_t fmt_uuid; 661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds size_t fmt_arg_size; 671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long fmt_flags; 681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int (*fmt_validate)(struct task_struct *task, unsigned int flags, int cpu, void *arg); 701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int (*fmt_getsize)(struct task_struct *task, unsigned int flags, int cpu, void *arg, unsigned long *size); 711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int (*fmt_init)(struct task_struct *task, void *buf, unsigned int flags, int cpu, void *arg); 721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int (*fmt_handler)(struct task_struct *task, void *buf, pfm_ovfl_arg_t *arg, struct pt_regs *regs, unsigned long stamp); 731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int (*fmt_restart)(struct task_struct *task, pfm_ovfl_ctrl_t *ctrl, void *buf, struct pt_regs *regs); 741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int (*fmt_restart_active)(struct task_struct *task, pfm_ovfl_ctrl_t *ctrl, void *buf, struct pt_regs *regs); 751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int (*fmt_exit)(struct task_struct *task, void *buf, struct pt_regs *regs); 761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct list_head fmt_list; 781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} pfm_buffer_fmt_t; 791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int pfm_register_buffer_fmt(pfm_buffer_fmt_t *fmt); 811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int pfm_unregister_buffer_fmt(pfm_uuid_t uuid); 821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * perfmon interface exported to modules 851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int pfm_mod_read_pmds(struct task_struct *, void *req, unsigned int nreq, struct pt_regs *regs); 871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int pfm_mod_write_pmcs(struct task_struct *, void *req, unsigned int nreq, struct pt_regs *regs); 881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int pfm_mod_write_ibrs(struct task_struct *task, void *req, unsigned int nreq, struct pt_regs *regs); 891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsextern int pfm_mod_write_dbrs(struct task_struct *task, void *req, unsigned int nreq, struct pt_regs *regs); 901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * describe the content of the local_cpu_date->pfm_syst_info field 931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define PFM_CPUINFO_SYST_WIDE 0x1 /* if set a system wide session exists */ 951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define PFM_CPUINFO_DCR_PP 0x2 /* if set the system wide session has started */ 961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define PFM_CPUINFO_EXCL_IDLE 0x4 /* the system wide session excludes the idle task */ 971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 984944930ab748942e41ea4dc313fcb0946aee3f17Stephane Eranian/* 994944930ab748942e41ea4dc313fcb0946aee3f17Stephane Eranian * sysctl control structure. visible to sampling formats 1004944930ab748942e41ea4dc313fcb0946aee3f17Stephane Eranian */ 1014944930ab748942e41ea4dc313fcb0946aee3f17Stephane Eraniantypedef struct { 1024944930ab748942e41ea4dc313fcb0946aee3f17Stephane Eranian int debug; /* turn on/off debugging via syslog */ 1034944930ab748942e41ea4dc313fcb0946aee3f17Stephane Eranian int debug_ovfl; /* turn on/off debug printk in overflow handler */ 1044944930ab748942e41ea4dc313fcb0946aee3f17Stephane Eranian int fastctxsw; /* turn on/off fast (unsecure) ctxsw */ 1054944930ab748942e41ea4dc313fcb0946aee3f17Stephane Eranian int expert_mode; /* turn on/off value checking */ 1064944930ab748942e41ea4dc313fcb0946aee3f17Stephane Eranian} pfm_sysctl_t; 1074944930ab748942e41ea4dc313fcb0946aee3f17Stephane Eranianextern pfm_sysctl_t pfm_sysctl; 1084944930ab748942e41ea4dc313fcb0946aee3f17Stephane Eranian 1094944930ab748942e41ea4dc313fcb0946aee3f17Stephane Eranian 1101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif /* _ASM_IA64_PERFMON_H */ 111