1. 14 1月, 2009 1 次提交
    • P
      powerpc/perf_counter: Make sure PMU gets enabled properly · 01d0287f
      Paul Mackerras 提交于
      This makes sure that we call the platform-specific ppc_md.enable_pmcs
      function on each CPU before we try to use the PMU on that CPU.  If the
      CPU goes off-line and then on-line, we need to do the enable_pmcs call
      again, so we use the hw_perf_counter_setup hook to ensure that.  It gets
      called as each CPU comes online, but it isn't called on the CPU that is
      coming up, so this adds the CPU number as an argument to it (there were
      no non-empty instances of hw_perf_counter_setup before).
      
      This also arranges to set the pmcregs_in_use field of the lppaca (data
      structure shared with the hypervisor) on each CPU when we are using the
      PMU and clear it when we are not.  This allows the hypervisor to optimize
      partition switches by not saving/restoring the PMU registers when we
      aren't using the PMU.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      01d0287f
  2. 12 1月, 2009 1 次提交
    • P
      perf_counter: Always schedule all software counters in · dd0e6ba2
      Paul Mackerras 提交于
      Software counters aren't subject to the limitations imposed by the
      fixed number of hardware counter registers, so there is no reason not
      to enable them all in __perf_counter_sched_in.  Previously we used to
      break out of the loop when we got to a group that wouldn't fit on the
      PMU; with this we continue through the list but only schedule in
      software counters (or groups containing only software counters) from
      there on.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      dd0e6ba2
  3. 09 1月, 2009 4 次提交
    • P
      perf_counter: Add dummy perf_counter_print_debug function · 4eb96fcf
      Paul Mackerras 提交于
      Impact: minimize requirements on architectures
      
      Currently, an architecture just enabling CONFIG_PERF_COUNTERS but not
      providing any extra functions will fail to build with
      perf_counter_print_debug being undefined, since we don't provide an
      empty dummy definition like we do with the hw_perf_* functions.
      
      This provides an empty dummy perf_counter_print_debug() to make it
      easier for architectures to turn on CONFIG_PERF_COUNTERS.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      4eb96fcf
    • P
      perf_counter: Add optional hw_perf_group_sched_in arch function · 3cbed429
      Paul Mackerras 提交于
      Impact: extend perf_counter infrastructure
      
      This adds an optional hw_perf_group_sched_in() arch function that enables
      a whole group of counters in one go.  It returns 1 if it added the group
      successfully, 0 if it did nothing (and therefore the core needs to add
      the counters individually), or a negative number if an error occurred.
      It should add all the counters and enable any software counters in the
      group, or else add none of them and return an error.
      
      There are a couple of related changes/improvements in the group handling
      here:
      
      * As an optimization, group_sched_out() and group_sched_in() now check the
        state of the group leader, and do nothing if the leader is not active
        or disabled.
      
      * We now call hw_perf_save_disable/hw_perf_restore around the complete
        set of counter enable/disable calls in __perf_counter_sched_in/out,
        to give the arch code the opportunity to defer updating the hardware
        state until the hw_perf_restore call if it wants.
      
      * We no longer stop adding groups after we get to a group that has more
        than one counter.  We will ultimately add an option for a group to be
        exclusive.  The current code doesn't really implement exclusive groups
        anyway, since a group could end up going on with other counters that
        get added before it.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      3cbed429
    • P
      perf_counter: Fix the cpu_clock software counter · 9abf8a08
      Paul Mackerras 提交于
      Impact: bug fix
      
      Currently if you do (e.g.) timec -e -1 ls, it will report 0 for the
      value of the cpu_clock counter.  The reason is that the core assumes
      that a counter's count field is up-to-date when the counter is inactive,
      and doesn't call the counter's read function.  However, the cpu_clock
      counter code only updates the count in the read function.
      
      This fixes it by making both the read and disable functions update the
      count.  It also makes the counter ignore time passing while the counter
      is disabled, by making the enable function update the hw.prev_count field.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      9abf8a08
    • P
      perf_counter: Fix return value from dummy hw_perf_counter_init · ff6f0541
      Paul Mackerras 提交于
      Impact: fix oops-causing bug
      
      Currently, if you try to use perf_counters on an architecture that has
      no hardware support, and you select an event that doesn't map to any of
      the defined software counters, you get an oops rather than an error.
      This is because the dummy hw_perf_counter_init returns ERR_PTR(-EINVAL)
      but the caller (perf_counter_alloc) only tests for NULL.
      
      This makes the dummy hw_perf_counter_init return NULL instead.
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      ff6f0541
  4. 27 12月, 2008 1 次提交
  5. 23 12月, 2008 7 次提交
  6. 17 12月, 2008 1 次提交
  7. 15 12月, 2008 8 次提交
  8. 11 12月, 2008 11 次提交
    • I
      perf counters: clean up state transitions · 6a930700
      Ingo Molnar 提交于
      Impact: cleanup
      
      Introduce a proper enum for the 3 states of a counter:
      
      	PERF_COUNTER_STATE_OFF		= -1
      	PERF_COUNTER_STATE_INACTIVE	=  0
      	PERF_COUNTER_STATE_ACTIVE	=  1
      
      and rename counter->active to counter->state and propagate the
      changes everywhere.
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      6a930700
    • I
      perf counters: add prctl interface to disable/enable counters · 1d1c7ddb
      Ingo Molnar 提交于
      Add a way for self-monitoring tasks to disable/enable counters summarily,
      via a prctl:
      
      	PR_TASK_PERF_COUNTERS_DISABLE		31
      	PR_TASK_PERF_COUNTERS_ENABLE		32
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      1d1c7ddb
    • I
      perf counters: implement PERF_COUNT_TASK_CLOCK · bae43c99
      Ingo Molnar 提交于
      Impact: add new perf-counter type
      
      The 'task clock' counter counts the amount of time a task is executing,
      in nanoseconds. It stops ticking when a task is scheduled out either due
      to it blocking, sleeping or it being preempted.
      
      This counter type is a Linux kernel based abstraction, it is available
      even if the hardware does not support native hardware performance counters.
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      bae43c99
    • I
      perf counters: consolidate hw_perf save/restore APIs · 01b2838c
      Ingo Molnar 提交于
      Impact: cleanup
      
      Rename them to better match up the usual IRQ disable/enable APIs:
      
       hw_perf_disable_all()  => hw_perf_save_disable()
       hw_perf_restore_ctrl() => hw_perf_restore()
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      01b2838c
    • I
      perf counters: implement PERF_COUNT_CPU_CLOCK · 5c92d124
      Ingo Molnar 提交于
      Impact: add new perf-counter type
      
      The 'CPU clock' counter counts the amount of CPU clock time that is
      elapsing, in nanoseconds. (regardless of how much of it the task is
      spending on a CPU executing)
      
      This counter type is a Linux kernel based abstraction, it is available
      even if the hardware does not support native hardware performance counters.
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      5c92d124
    • I
      perf counters: hw driver API · 621a01ea
      Ingo Molnar 提交于
      Impact: restructure code, introduce hw_ops driver abstraction
      
      Introduce this abstraction to handle counter details:
      
       struct hw_perf_counter_ops {
      	void (*hw_perf_counter_enable)	(struct perf_counter *counter);
      	void (*hw_perf_counter_disable)	(struct perf_counter *counter);
      	void (*hw_perf_counter_read)	(struct perf_counter *counter);
       };
      
      This will be useful to support assymetric hw details, and it will also
      be useful to implement "software counters". (Counters that count kernel
      managed sw events such as pagefaults, context-switches, wall-clock time
      or task-local time.)
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      621a01ea
    • I
      perf counters: group counter, fixes · ccff286d
      Ingo Molnar 提交于
      Impact: bugfix
      
      Check that a group does not span outside the context of a CPU or a task.
      
      Also, do not allow deep recursive hierarchies.
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      ccff286d
    • I
      perf counters: add support for group counters · 04289bb9
      Ingo Molnar 提交于
      Impact: add group counters
      
      This patch adds the "counter groups" abstraction.
      
      Groups of counters behave much like normal 'single' counters, with a
      few semantic and behavioral extensions on top of that.
      
      A counter group is created by creating a new counter with the open()
      syscall's group-leader group_fd file descriptor parameter pointing
      to another, already existing counter.
      
      Groups of counters are scheduled in and out in one atomic group, and
      they are also roundrobin-scheduled atomically.
      
      Counters that are member of a group can also record events with an
      (atomic) extended timestamp that extends to all members of the group,
      if the record type is set to PERF_RECORD_GROUP.
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      04289bb9
    • I
      perf counters: restructure the API · 9f66a381
      Ingo Molnar 提交于
      Impact: clean up new API
      
      Thorough cleanup of the new perf counters API, we now get clean separation
      of the various concepts:
      
       - introduce perf_counter_hw_event to separate out the event source details
      
       - move special type flags into separate attributes: PERF_COUNT_NMI,
         PERF_COUNT_RAW
      
       - extend the type to u64 and reserve it fully to the architecture in the
         raw type case.
      
      And make use of all these changes in the core and x86 perfcounters code.
      
      Also change the syscall signature to:
      
        asmlinkage int sys_perf_counter_open(
      
      	struct perf_counter_hw_event	*hw_event_uptr		__user,
      	pid_t				pid,
      	int				cpu,
      	int				group_fd);
      
      ( Note that group_fd is unused for now - it's reserved for the counter
        groups abstraction. )
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      9f66a381
    • T
      perf counters: expand use of counter->event · dfa7c899
      Thomas Gleixner 提交于
      Impact: change syscall, cleanup
      
      Make use of the new perf_counters event type.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      dfa7c899
    • T
      perf counters: clean up 'raw' type API · eab656ae
      Thomas Gleixner 提交于
      Impact: cleanup
      
      Introduce a separate hw_event type.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      eab656ae
  9. 08 12月, 2008 1 次提交
    • T
      performance counters: core code · 0793a61d
      Thomas Gleixner 提交于
      Implement the core kernel bits of Performance Counters subsystem.
      
      The Linux Performance Counter subsystem provides an abstraction of
      performance counter hardware capabilities. It provides per task and per
      CPU counters, and it provides event capabilities on top of those.
      
      Performance counters are accessed via special file descriptors.
      There's one file descriptor per virtual counter used.
      
      The special file descriptor is opened via the perf_counter_open()
      system call:
      
       int
       perf_counter_open(u32 hw_event_type,
                         u32 hw_event_period,
                         u32 record_type,
                         pid_t pid,
                         int cpu);
      
      The syscall returns the new fd. The fd can be used via the normal
      VFS system calls: read() can be used to read the counter, fcntl()
      can be used to set the blocking mode, etc.
      
      Multiple counters can be kept open at a time, and the counters
      can be poll()ed.
      
      See more details in Documentation/perf-counters.txt.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      0793a61d