Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1194828

Re: [PATCH RFC 2/3] x86: Add Intel PT logger

From Alexander Shishkin <alexander.shishkin@linux.intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH RFC 2/3] x86: Add Intel PT logger
Date 2015-07-29 08:10 +0200
Message-ID <pRsIV-83u-9@gated-at.bofh.it> (permalink)
References <pRrDc-6hN-1@gated-at.bofh.it> <pRrMS-6J2-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Takao Indoh <indou.takao@jp.fujitsu.com> writes:

> This patch provides Intel PT logging feature. When system boots with a
> parameter "intel_pt_log", log buffers for Intel PT are allocated and
> logging starts, then processor flow information is written in the log
> buffer by hardware like flight recorder. This is very helpful to
> investigate a cause of kernel panic.
>
> The log buffer size is specified by the parameter
> "intel_pt_log_buf_len=<size>". This buffer is used as circular buffer,
> therefore old events are overwritten by new events.

[skip]

> +static void enable_pt(int enable)
> +{
> +	u64 ctl;
> +
> +	rdmsrl(MSR_IA32_RTIT_CTL, ctl);

Ideally, you shouldn't need this rdmsr(), because in this code you
should know exactly which ctl bits you need set when you enable.

> +
> +	if (enable)
> +		ctl |= RTIT_CTL_TRACEEN;
> +	else
> +		ctl &= ~RTIT_CTL_TRACEEN;
> +
> +	wrmsrl(MSR_IA32_RTIT_CTL, ctl);
> +}

But the bigger problem with this approach is that it duplicates the
existing driver's functionality and some of the code, which just makes
it harder to maintain amoung other things.

Instead, we should be able to do use the existing perf functionality to
enable the system-wide tracing, so that it goes through the
driver. Another thing to remember is that you'd also need some of the
sideband data (vm mappings, context switches) to be able to properly
decode the trace, which also can come from perf. And it'd also be much
less code. The only missing piece is the code that would allocate the
ring buffer for such events.

Something like:

static DEFINE_PER_CPU(struct perf_event *, perf_kdump_event);

static struct perf_event_attr perf_kdump_attr;

...

static int perf_kdump_init(void)
{
        struct perf_event *event;
        int cpu;

        get_online_cpus();
        for_each_possible_cpu(cpu) {
                event = perf_create_kernel_counter(&perf_kdump_attr,
        					   cpu, NULL,
					           NULL, NULL);

		...

                ret = rb_alloc_kernel(event, perf_kdump_data_size, perf_kdump_aux_size);

                ...
                
                per_cpu(perf_kdump_event, cpu) = event;
        }
        put_online_cpus();
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH RFC 0/3] x86: Intel Processor Trace Logger Takao Indoh <indou.takao@jp.fujitsu.com> - 2015-07-29 07:00 +0200
  [PATCH RFC 3/3] x86: Stop Intel PT and save its registers when panic occurs Takao Indoh <indou.takao@jp.fujitsu.com> - 2015-07-29 07:00 +0200
  [PATCH RFC 1/3] x86: Add Intel PT common files Takao Indoh <indou.takao@jp.fujitsu.com> - 2015-07-29 07:00 +0200
    Re: [PATCH RFC 1/3] x86: Add Intel PT common files Thomas Gleixner <tglx@linutronix.de> - 2015-08-02 12:10 +0200
      Re: [PATCH RFC 1/3] x86: Add Intel PT common files Takao Indoh <indou.takao@jp.fujitsu.com> - 2015-08-03 05:20 +0200
  [PATCH RFC 2/3] x86: Add Intel PT logger Takao Indoh <indou.takao@jp.fujitsu.com> - 2015-07-29 07:10 +0200
    Re: [PATCH RFC 2/3] x86: Add Intel PT logger Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2015-07-29 08:10 +0200
      Re: [PATCH RFC 2/3] x86: Add Intel PT logger Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2015-07-29 11:10 +0200
        Re: [PATCH RFC 2/3] x86: Add Intel PT logger Takao Indoh <indou.takao@jp.fujitsu.com> - 2015-07-30 03:50 +0200
          Re: [PATCH RFC 2/3] x86: Add Intel PT logger Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2015-07-30 07:40 +0200
  Re: [PATCH RFC 0/3] x86: Intel Processor Trace Logger Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2015-07-29 07:50 +0200
    Re: [PATCH RFC 0/3] x86: Intel Processor Trace Logger Takao Indoh <indou.takao@jp.fujitsu.com> - 2015-07-29 08:00 +0200

csiph-web