15 Feb, 2011

1 commit

  • This patch introduces a new oprofile sample add function
    (oprofile_add_ext_hw_sample) that can also take task_struct as an
    argument, which is used by the hwsampler kernel module when copying
    hardware samples to OProfile buffers.

    Applied with following changes:
    * removed #include
    * whitespace changes
    * removed conditional compilation (CONFIG_HAVE_HWSAMPLER)
    * modified order of functions
    * fix missing function definition in header file

    Signed-off-by: Mahesh Salgaonkar
    Signed-off-by: Maran Pakkirisamy
    Signed-off-by: Heinz Graalfs
    Acked-by: Heiko Carstens
    Signed-off-by: Robert Richter

    Heinz Graalfs
     

29 Oct, 2010

1 commit

  • flush_scheduled_work() is deprecated and scheduled to be removed.
    sync_stop() currently cancels cpu_buffer works inside buffer_mutex and
    flushes the system workqueue outside. Instead, split end_cpu_work()
    into two parts - stopping further work enqueues and flushing works -
    and do the former inside buffer_mutex and latter outside.

    For stable kernels v2.6.35.y and v2.6.36.y.

    Signed-off-by: Tejun Heo
    Cc: stable@kernel.org
    Signed-off-by: Robert Richter

    Tejun Heo
     

25 Aug, 2010

1 commit

  • This patch fixes a crash during shutdown reported below. The crash is
    caused by accessing already freed task structs. The fix changes the
    order for registering and unregistering notifier callbacks.

    All notifiers must be initialized before buffers start working. To
    stop buffer synchronization we cancel all workqueues, unregister the
    notifier callback and then flush all buffers. After all of this we
    finally can free all tasks listed.

    This should avoid accessing freed tasks.

    On 22.07.10 01:14:40, Benjamin Herrenschmidt wrote:

    > So the initial observation is a spinlock bad magic followed by a crash
    > in the spinlock debug code:
    >
    > [ 1541.586531] BUG: spinlock bad magic on CPU#5, events/5/136
    > [ 1541.597564] Unable to handle kernel paging request for data at address 0x6b6b6b6b6b6b6d03
    >
    > Backtrace looks like:
    >
    > spin_bug+0x74/0xd4
    > ._raw_spin_lock+0x48/0x184
    > ._spin_lock+0x10/0x24
    > .get_task_mm+0x28/0x8c
    > .sync_buffer+0x1b4/0x598
    > .wq_sync_buffer+0xa0/0xdc
    > .worker_thread+0x1d8/0x2a8
    > .kthread+0xa8/0xb4
    > .kernel_thread+0x54/0x70
    >
    > So we are accessing a freed task struct in the work queue when
    > processing the samples.

    Reported-by: Benjamin Herrenschmidt
    Cc: stable@kernel.org
    Signed-off-by: Robert Richter

    Robert Richter
     

04 May, 2010

1 commit

  • http://lkml.org/lkml/2010/4/27/285

    Protect against dereferencing regs when it's NULL, and
    force a magic number into pc to prevent too deep processing.
    This approach permits the dropped samples to be tallied as
    invalid Instruction Pointer events.

    e.g. output from about 15mins at 10kHz sample rate:
    Nr. samples received: 2565380
    Nr. samples lost invalid pc: 4

    Signed-off-by: Phil Carmody
    Signed-off-by: Robert Richter

    Phil Carmody
     

23 Apr, 2010

2 commits

  • Conflicts:
    drivers/oprofile/cpu_buffer.c

    Signed-off-by: Robert Richter

    Robert Richter
     
  • oprofile used a double buffer scheme for its cpu event buffer
    to avoid races on reading with the old locked ring buffer.

    But that is obsolete now with the new ring buffer, so simply
    use a single buffer. This greatly simplifies the code and avoids
    a lot of sample drops on large runs, especially with call graph.

    Based on suggestions from Steven Rostedt

    For stable kernels from v2.6.32, but not earlier.

    Signed-off-by: Andi Kleen
    Cc: Steven Rostedt
    Cc: stable
    Signed-off-by: Robert Richter

    Andi Kleen
     

01 Apr, 2010

1 commit

  • Currently, when the ring buffer drops events, it does not record
    the fact that it did so. It does inform the writer that the event
    was dropped by returning a NULL event, but it does not put in any
    place holder where the event was dropped.

    This is not a trivial thing to add because the ring buffer mostly
    runs in overwrite (flight recorder) mode. That is, when the ring
    buffer is full, new data will overwrite old data.

    In a produce/consumer mode, where new data is simply dropped when
    the ring buffer is full, it is trivial to add the placeholder
    for dropped events. When there's more room to write new data, then
    a special event can be added to notify the reader about the dropped
    events.

    But in overwrite mode, any new write can overwrite events. A place
    holder can not be inserted into the ring buffer since there never
    may be room. A reader could also come in at anytime and miss the
    placeholder.

    Luckily, the way the ring buffer works, the read side can find out
    if events were lost or not, and how many events. Everytime a write
    takes place, if it overwrites the header page (the next read) it
    updates a "overrun" variable that keeps track of the number of
    lost events. When a reader swaps out a page from the ring buffer,
    it can record this number, perfom the swap, and then check to
    see if the number changed, and take the diff if it has, which would be
    the number of events dropped. This can be stored by the reader
    and returned to callers of the reader.

    Since the reader page swap will fail if the writer moved the head
    page since the time the reader page set up the swap, this gives room
    to record the overruns without worrying about races. If the reader
    sets up the pages, records the overrun, than performs the swap,
    if the swap succeeds, then the overrun variable has not been
    updated since the setup before the swap.

    For binary readers of the ring buffer, a flag is set in the header
    of each sub page (sub buffer) of the ring buffer. This flag is embedded
    in the size field of the data on the sub buffer, in the 31st bit (the size
    can be 32 or 64 bits depending on the architecture), but only 27
    bits needs to be used for the actual size (less actually).

    We could add a new field in the sub buffer header to also record the
    number of events dropped since the last read, but this will change the
    format of the binary ring buffer a bit too much. Perhaps this change can
    be made if the information on the number of events dropped is considered
    important enough.

    Note, the notification of dropped events is only used by consuming reads
    or peeking at the ring buffer. Iterating over the ring buffer does not
    keep this information because the necessary data is only available when
    a page swap is made, and the iterator does not swap out pages.

    Cc: Robert Richter
    Cc: Andi Kleen
    Cc: Li Zefan
    Cc: Arnaldo Carvalho de Melo
    Cc: "Luis Claudio R. Goncalves"
    Cc: Frederic Weisbecker
    Signed-off-by: Steven Rostedt

    Steven Rostedt
     

29 Oct, 2009

1 commit

  • This patch updates percpu related symbols in oprofile such that percpu
    symbols are unique and don't clash with local symbols. This serves
    two purposes of decreasing the possibility of global percpu symbol
    collision and allowing dropping per_cpu__ prefix from percpu symbols.

    * drivers/oprofile/cpu_buffer.c: s/cpu_buffer/op_cpu_buffer/

    Partly based on Rusty Russell's "alloc_percpu: rename percpu vars
    which cause name clashes" patch.

    Signed-off-by: Tejun Heo
    Acked-by: Robert Richter
    Cc: Rusty Russell

    Tejun Heo
     

12 Jun, 2009

1 commit


11 Jun, 2009

1 commit


07 May, 2009

1 commit

  • The unit of oprofile_cpu_buffer_size is in samples, but was allocated
    in bytes. This led to the allocation of too small cpu buffers. This
    patch recalculates the buffer size in bytes taking also the
    ring_buffer_event header size into account.

    Reported-by: Suravee Suthikulpanit
    Signed-off-by: Robert Richter

    Robert Richter
     

06 Feb, 2009

1 commit


18 Jan, 2009

1 commit


08 Jan, 2009

11 commits


30 Dec, 2008

4 commits


29 Dec, 2008

2 commits


17 Dec, 2008

1 commit


11 Dec, 2008

2 commits

  • The number of lost samples could be greater than the number of
    received samples. This patches fixes this. The implementation
    introduces return values for add_sample() and add_code().

    Signed-off-by: Robert Richter

    Robert Richter
     
  • This function is no longer available after the port to the new ring
    buffer. Its removal can lead to incomplete sampling sequences since
    IBS samples and backtraces are transfered in multiple samples. Due to
    a full buffer, samples could be lost any time. The userspace daemon
    has to live with such incomplete sampling sequences as long as the
    data within one sample is consistent.

    This will be fixed by changing the internal buffer data there all data
    of one IBS sample or a backtrace is packed in a single ring buffer
    entry. This is possible since the new ring buffer supports variable
    data size.

    Signed-off-by: Robert Richter

    Robert Richter
     

10 Dec, 2008

6 commits

  • This patch replaces the current oprofile cpu buffer implementation
    with the ring buffer provided by the tracing framework. The motivation
    here is to leave the pain of implementing ring buffers to others. Oh,
    no, there are more advantages. Main reason is the support of different
    sample sizes that could be stored in the buffer. Use cases for this
    are IBS and Cell spu profiling. Using the new ring buffer ensures
    valid and complete samples and allows copying the cpu buffer stateless
    without knowing its content. Second it will use generic kernel API and
    also reduce code size. And hopefully, there are less bugs.

    Since the new tracing ring buffer implementation uses spin locks to
    protect the buffer during read/write access, it is difficult to use
    the buffer in an NMI handler. In this case, writing to the buffer by
    the NMI handler (x86) could occur also during critical sections when
    reading the buffer. To avoid this, there are 2 buffers for independent
    read and write access. Read access is in process context only, write
    access only in the NMI handler. If the read buffer runs empty, both
    buffers are swapped atomically. There is potentially a small window
    during swapping where the buffers are disabled and samples could be
    lost.

    Using 2 buffers is a little bit overhead, but the solution is clear
    and does not require changes in the ring buffer implementation. It can
    be changed to a single buffer solution when the ring buffer access is
    implemented as non-locking atomic code.

    The new buffer requires more size to store the same amount of samples
    because each sample includes an u32 header. Also, there is more code
    to execute for buffer access. Nonetheless, the buffer implementation
    is proven in the ftrace environment and worth to use also in oprofile.

    Patches that changes the internal IBS buffer usage will follow.

    Cc: Steven Rostedt
    Signed-off-by: Robert Richter

    Robert Richter
     
  • This is in preparation for changes in the cpu buffer implementation.

    Signed-off-by: Robert Richter

    Robert Richter
     
  • This is in preparation for changes in the cpu buffer implementation.

    Signed-off-by: Robert Richter

    Robert Richter
     
  • This is in preparation for changes in the cpu buffer implementation.

    Signed-off-by: Robert Richter

    Robert Richter
     
  • Signed-off-by: Robert Richter

    Robert Richter
     
  • This fixes the coding style of some comments.

    Signed-off-by: Robert Richter

    Robert Richter
     

24 Oct, 2008

1 commit

  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile: (21 commits)
    OProfile: Fix buffer synchronization for IBS
    oprofile: hotplug cpu fix
    oprofile: fixing whitespaces in arch/x86/oprofile/*
    oprofile: fixing whitespaces in arch/x86/oprofile/*
    oprofile: fixing whitespaces in drivers/oprofile/*
    x86/oprofile: add the logic for enabling additional IBS bits
    x86/oprofile: reordering functions in nmi_int.c
    x86/oprofile: removing unused function parameter in add_ibs_begin()
    oprofile: more whitespace fixes
    oprofile: whitespace fixes
    OProfile: Rename IBS sysfs dir into "ibs_op"
    OProfile: Rework string handling in setup_ibs_files()
    OProfile: Rework oprofile_add_ibs_sample() function
    oprofile: discover counters for op ppro too
    oprofile: Implement Intel architectural perfmon support
    oprofile: Don't report Nehalem as core_2
    oprofile: drop const in num counters field
    Revert "Oprofile Multiplexing Patch"
    x86, oprofile: BUG: using smp_processor_id() in preemptible code
    x86/oprofile: fix on_each_cpu build error
    ...

    Manually fixed trivial conflicts in
    drivers/oprofile/{cpu_buffer.c,event_buffer.h}

    Linus Torvalds