[PATCH 08/20] perf: Export cpumap

Previous thread: [PATCH 01/20] perf: Start the massive restructuring by Borislav Petkov on Thursday, November 4, 2010 - 8:36 am. (1 message)

Next thread: [RFD] Perf generic context based exclusion/inclusion (was Re: [PATCH 0/4] Finer granularity and task/cgroup irq time accounting) by Frederic Weisbecker on Thursday, November 4, 2010 - 8:40 am. (4 messages)
From: Borislav Petkov
Date: Thursday, November 4, 2010 - 8:36 am

From: Borislav Petkov <borislav.petkov@amd.com>

Hi all,

I finally had some time to work on this thing again. This time it can
parse the MCE tracepoint and should be conceptually almost done. What
needs to be done now is fleshing out a bunch of details here and there.
I'm sending it early so that I can collect some more feedback.

So the patchset is ontop of 2.6.36 + Steven's trace_cmd restructuring
set from

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git tip/perf/parse-events

I'm adding his patches too here, for completeness (although they need
some more work).

I've also cherry-picked the bunch of EDAC's MCE injection stuff for
testing.

So, in the end of the day, if you do

echo 0x9c00410000010016 > /sys/devices/system/edac/mce/status

(0x9c.. is the MCE signature of a data cache L2 TLB multimatch, for
example)

echo 0 > /sys/devices/system/edac/mce/bank

(0 means bank 0, i.e. data cache errors)

after having loaded the mce_amd_inj injection testing module, the RAS
daemon get's the status signature in userspace:

...
DBG main: Read some mmapped data
DBG main: MCE status: 0x9c00410000010016

All of the remaining fields can be postprocessed in arbitrary manner
after that. The MCE decoding in the kernel can then be simplified by
sharing it with the daemon, if needed. But that's another story.

To the patches, individually:

#1. Start splitting perf_event.c as we talked last time. The remaining
units could be carved out from there based on functionality.

#2. persistent events registration

#3. ... and their first user.

#4,5: Steven's stuff. Btw, Steven, feel free to pick up any of the later
patches if it makes your life easier, like #6 for example.

#6: could go with the above

#7-#19: Export all the shared stuff to the different libraries. I've
splitted them to as small units as possible for easier review.

#20: Adds the daemon. Still full of debugging code since
work-in-progress.

Also, in order to make this work, I ...
From: Borislav Petkov
Date: Thursday, November 4, 2010 - 8:36 am

From: Borislav Petkov <borislav.petkov@amd.com>

Add the necessary glue to enable the mce_record tracepoint on boot
turning it into a persistent event. This exports the MCE buffer
read-only to a userspace daemon which will hook into it through debugfs
when booting is finished.

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
 arch/x86/include/asm/mce.h       |    8 ++++
 arch/x86/kernel/cpu/mcheck/mce.c |   84 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 92 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index c62c13c..c248038 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -91,6 +91,14 @@ struct mce_log {
 	struct mce entry[MCE_LOG_LEN];
 };
 
+/*
+ * a per-cpu descriptor of the persistent MCE tracepoint
+ */
+struct mce_tp_desc {
+	struct perf_event *event;
+	struct dentry *debugfs_entry;
+};
+
 #define MCE_OVERFLOW 0		/* bit 0 in flags means overflow */
 
 #define MCE_LOG_SIGNATURE	"MACHINECHECK"
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index ed41562..5ce3e72 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -95,8 +95,11 @@ static char			*mce_helper_argv[2] = { mce_helper, NULL };
 
 static DECLARE_WAIT_QUEUE_HEAD(mce_wait);
 static DEFINE_PER_CPU(struct mce, mces_seen);
+static DEFINE_PER_CPU(struct mce_tp_desc, mce_event);
 static int			cpu_missing;
 
+
+
 /*
  * CPU/chipset specific EDAC code can register a notifier call here to print
  * MCE errors in a human-readable form.
@@ -2052,6 +2055,86 @@ static void __cpuinit mce_reenable_cpu(void *h)
 	}
 }
 
+struct perf_event_attr pattr = {
+	.type		= PERF_TYPE_TRACEPOINT,
+	.size		= sizeof(pattr),
+	.sample_type	= PERF_SAMPLE_RAW,
+};
+
+static struct dentry *mce_add_event_debugfs(struct perf_event *event, int cpu)
+{
+	char buf[14];
+
+	sprintf(buf, "mce_record%d", cpu);
+
+	return debugfs_create_file(buf, ...
From: Ben Gamari
Date: Wednesday, November 10, 2010 - 2:15 pm

While MCE technically is a diagnostics service, do we want to start
adding dependencies on debugfs in long-running, common-place daemons? I
was under the impression we were to avoid using debugfs for anything
other than values for one-off debugging.

Cheers,

- Ben
--

From: Ingo Molnar
Date: Wednesday, November 10, 2010 - 3:21 pm

See this current discussion thread on lkml:

   [RFC][PATCH] perf: sysfs type id

Events are being added to sysfs as we want to avoid the debugfs dependency.

Thanks,

	Ingo
--

From: Borislav Petkov
Date: Wednesday, November 10, 2010 - 11:17 pm

Yep, event enumeration will land in /sysfs eventually but in this case
debugfs is used to export the buffers with the events recorded so far to
the daemon which mmaps them. And I remember also being mentioned that
debugfs will thus be always compiled in because of that.

In any case, we need some kind of a facility with which to export those
buffers for userspace to mmap. sysfs is clearly not that and debugfs is
what we currently use. I'm open for better suggestions though.

Thanks.

-- 
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
--

From: Ingo Molnar
Date: Thursday, November 11, 2010 - 1:58 am

The event ring-buffer can be mmap()-ed off the fd that sys_perf_event_open() gives. 
This is what all of tools/perf/ does - it uses debugfs only for even enumeration 
(which will move to sysfs).

Thanks,

	Ingo
--

From: Borislav Petkov
Date: Thursday, November 11, 2010 - 6:34 am

but then PeterZ suggested I should use debugfs to export the buffers
and not teach sys_perf_event_open of persistent events. Which is also
the right thing to do (maybe not through debugfs) since we want to have
a single per-cpu buffer with all MCEs in there which even multiple
userspace tools can access. So the question is, how do I mmap() those
properly?

So we either

1) use the perf syscall and teach it about persistent events and it always
returns the same fd whenever a persistent event is requested over its attr
argument;

2) use debugfs (current approach);

3) enable the persistent event and stash its fd in some /sysfs member
which the RAS daemon reads out and mmaps. This last one actually sounds
pretty neat.

4) another idea which I'm missing.

So what do you guys think?

-- 
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
--

From: Peter Zijlstra
Date: Thursday, November 11, 2010 - 8:38 am

Right, stashing the thing in sysfs, which you can open()+mmap() seems
the best way. Not sure you want to make it a RAS specific place, maybe a
generic persistent buffer place.

You'll get multiple files anyway, one per cpu, so maybe something like:

/sysfs/persistent_buffer/ras[0..n]


--

From: Borislav Petkov
Date: Thursday, November 11, 2010 - 8:55 am

Yeah, or even integrate it even further into the events hierarchy like
this:

/sys/.../cpu/events/mce		-> this is the trace_mce_record tracepoint
/sys/.../cpu/events/mce_pers	-> persistent buffer fd

or an additional level further down

/sys/.../cpu/events/mce/persistent/...

or whatever.

Generally I don't care too much where we put it at the end.

Thanks.

-- 
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
--

From: Ingo Molnar
Date: Thursday, November 11, 2010 - 10:30 am

It should be in a nice logical place though :-)

Thanks,

	Ingo
--

From: Borislav Petkov
Date: Thursday, November 4, 2010 - 8:36 am

From: Steven Rostedt <srostedt@redhat.com>

Move the parse-events.c code that originally came from trace-cmd into
tools/lib/ and use it to make a libparsevent.a library.

This patch moves the file with minimal changes to the code.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 tools/lib/Makefile                  |   43 +
 tools/lib/parse-events.c            | 3231 ++++++++++++++++++++++++++++++++++
 tools/lib/parse-events.h            |  295 ++++
 tools/perf/Makefile                 |   11 +-
 tools/perf/util/trace-event-parse.c | 3233 -----------------------------------
 tools/perf/util/trace-event.h       |  297 +----
 6 files changed, 3582 insertions(+), 3528 deletions(-)
 create mode 100644 tools/lib/Makefile
 create mode 100644 tools/lib/parse-events.c
 create mode 100644 tools/lib/parse-events.h
 delete mode 100644 tools/perf/util/trace-event-parse.c

diff --git a/tools/lib/Makefile b/tools/lib/Makefile
new file mode 100644
index 0000000..4a8ad38
--- /dev/null
+++ b/tools/lib/Makefile
@@ -0,0 +1,43 @@
+
+# Make the path relative to DESTDIR, not to prefix
+ifndef DESTDIR
+prefix = $(HOME)
+endif
+bindir_relative = bin
+bindir = $(prefix)/$(bindir_relative)
+mandir = share/man
+infodir = share/info
+sharedir = $(prefix)/share
+ifeq ($(prefix),/usr)
+sysconfdir = /etc
+else
+sysconfdir = $(prefix)/etc
+endif
+
+export prefix bindir sharedir sysconfdir
+
+CC = $(CROSS_COMPILE)gcc
+AR = $(CROSS_COMPILE)ar
+RM = rm -f
+TAR = tar
+FIND = find
+INSTALL = install
+RPMBUILD = rpmbuild
+PTHREAD_LIBS = -lpthread
+
+ifeq ("$(origin V)", "command line")
+  VERBOSE = $(V)
+endif
+ifndef VERBOSE
+  VERBOSE = 0
+endif
+
+all: libparsevent.a
+
+PEVENT_LIB_OBJS = parse-events.o
+
+$(OUTPUT)%.o: %.c
+	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
+
+libparsevent.a: $(PEVENT_LIB_OBJS)
+	$(RM) $@;  $(AR) rcs $@ $^
diff --git a/tools/lib/parse-events.c b/tools/lib/parse-events.c
new file mode 100644
index 0000000..3730389
--- /dev/null
+++ ...
From: Borislav Petkov
Date: Thursday, November 4, 2010 - 8:36 am

From: Borislav Petkov <borislav.petkov@amd.com>

Export /proc/mounts parser and other debugfs-related helpers for general
use. Also, exit if a valid debugfs mountpoint cannot be found.

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
 tools/Makefile                                     |    8 +-
 tools/lib/lk/Makefile                              |   38 +++
 tools/lib/lk/debugfs.c                             |  256 ++++++++++++++++++
 tools/lib/lk/debugfs.h                             |   31 +++
 tools/lib/lk/types.h                               |   17 ++
 tools/lib/lk/usage.c                               |   80 ++++++
 tools/lib/lk/util.h                                |  285 ++++++++++++++++++++
 tools/perf/Makefile                                |   11 +-
 tools/perf/bench/bench.h                           |    2 +
 tools/perf/bench/mem-memcpy.c                      |    2 +-
 tools/perf/bench/sched-messaging.c                 |    2 +-
 tools/perf/bench/sched-pipe.c                      |    2 +-
 tools/perf/builtin-annotate.c                      |    2 +-
 tools/perf/builtin-bench.c                         |    2 +-
 tools/perf/builtin-diff.c                          |    2 +-
 tools/perf/builtin-kmem.c                          |    2 +-
 tools/perf/builtin-kvm.c                           |    2 +-
 tools/perf/builtin-lock.c                          |    2 +-
 tools/perf/builtin-probe.c                         |    5 +-
 tools/perf/builtin-record.c                        |    2 +-
 tools/perf/builtin-report.c                        |    2 +-
 tools/perf/builtin-sched.c                         |    2 +-
 tools/perf/builtin-stat.c                          |    2 +-
 tools/perf/builtin-timechart.c                     |    2 +-
 tools/perf/builtin-top.c                           |    2 +-
 tools/perf/builtin-trace.c                         |    2 +-
 tools/perf/builtin.h                               |    2 +-
 tools/perf/perf.c                                 ...
From: Borislav Petkov
Date: Thursday, November 4, 2010 - 8:36 am

From: Borislav Petkov <borislav.petkov@amd.com>

Move tracing stuff into tools/lib/trace and rewire it back into perf.
Add a top-level Makefile which selects between targets depending
on the tool we want to build.

Also, add a Makefile.lib for common facilities used by all the
Makefiles. While at it, make sure objects output directory using O=
exists.

Finally, rename trace/util.h to trace/trace-util.h so as not to conflict
with perf's util.h.

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
 tools/Makefile                 |   47 +
 tools/lib/Makefile             |   49 -
 tools/lib/parse-events.c       | 4655 ----------------------------------------
 tools/lib/parse-events.h       |  719 -------
 tools/lib/parse-filter.c       | 2085 ------------------
 tools/lib/parse-utils.c        |  110 -
 tools/lib/trace-seq.c          |  153 --
 tools/lib/trace/Makefile       |   54 +
 tools/lib/trace/parse-events.c | 4655 ++++++++++++++++++++++++++++++++++++++++
 tools/lib/trace/parse-events.h |  719 +++++++
 tools/lib/trace/parse-filter.c | 2085 ++++++++++++++++++
 tools/lib/trace/parse-utils.c  |  110 +
 tools/lib/trace/trace-seq.c    |  153 ++
 tools/lib/trace/trace-util.h   |   64 +
 tools/lib/util.h               |   64 -
 tools/perf/Makefile            |   41 +-
 tools/perf/util/trace-event.h  |    2 +-
 tools/scripts/Makefile.lib     |   33 +
 18 files changed, 7923 insertions(+), 7875 deletions(-)
 create mode 100644 tools/Makefile
 delete mode 100644 tools/lib/Makefile
 delete mode 100644 tools/lib/parse-events.c
 delete mode 100644 tools/lib/parse-events.h
 delete mode 100644 tools/lib/parse-filter.c
 delete mode 100644 tools/lib/parse-utils.c
 delete mode 100644 tools/lib/trace-seq.c
 create mode 100644 tools/lib/trace/Makefile
 create mode 100644 tools/lib/trace/parse-events.c
 create mode 100644 tools/lib/trace/parse-events.h
 create mode 100644 tools/lib/trace/parse-filter.c
 create mode 100644 tools/lib/trace/parse-utils.c
 create mode 100644 ...
From: Borislav Petkov
Date: Thursday, November 4, 2010 - 8:36 am

From: Borislav Petkov <borislav.petkov@amd.com>

Export the mmap_read* helpers into tools/lib/perf/mmap.[ch]

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
 tools/Makefile              |    6 ++-
 tools/lib/perf/Makefile     |   35 ++++++++++++++
 tools/lib/perf/mmap.c       |   95 ++++++++++++++++++++++++++++++++++++++
 tools/lib/perf/mmap.h       |   15 ++++++
 tools/perf/Makefile         |    2 +-
 tools/perf/builtin-record.c |  107 ++++---------------------------------------
 tools/perf/builtin-top.c    |   28 ++---------
 7 files changed, 166 insertions(+), 122 deletions(-)
 create mode 100644 tools/lib/perf/Makefile
 create mode 100644 tools/lib/perf/mmap.c
 create mode 100644 tools/lib/perf/mmap.h

diff --git a/tools/Makefile b/tools/Makefile
index d3b1447..691f78b 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -34,7 +34,7 @@ export BASIC_CFLAGS
 PERF_TOP_DIR := $(CURDIR)
 export PERF_TOP_DIR
 
-perf: libparsevent lklib .FORCE
+perf: libparsevent lklib lkperflib .FORCE
 	$(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1)
 
 libparsevent: .FORCE
@@ -43,9 +43,13 @@ libparsevent: .FORCE
 lklib: .FORCE
 	$(QUIET_SUBDIR0)lib/lk/ $(QUIET_SUBDIR1)
 
+lkperflib: .FORCE
+	$(QUIET_SUBDIR0)lib/perf/ $(QUIET_SUBDIR1)
+
 clean:
 	$(QUIET_SUBDIR0)lib/trace/ $(QUIET_SUBDIR1) clean
 	$(QUIET_SUBDIR0)lib/lk/ $(QUIET_SUBDIR1) clean
+	$(QUIET_SUBDIR0)lib/perf/ $(QUIET_SUBDIR1) clean
 	$(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) clean
 
 .PHONY: clean .FORCE
diff --git a/tools/lib/perf/Makefile b/tools/lib/perf/Makefile
new file mode 100644
index 0000000..9942d52
--- /dev/null
+++ b/tools/lib/perf/Makefile
@@ -0,0 +1,35 @@
+include ../../scripts/Makefile.lib
+
+# guard against environment variables
+LIB_H=
+LIB_OBJS=
+
+LIB_H += mmap.h
+
+LIB_OBJS += mmap.o
+
+LIBFILE = $(LIB_OUTPUT)lkperflib.a
+
+CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
+EXTLIBS = -lpthread -lrt -lelf ...
From: Borislav Petkov
Date: Thursday, November 4, 2010 - 8:36 am

From: Borislav Petkov <borislav.petkov@amd.com>

This is generic code anyway and will be needed by other utils so move it
to a generic library.

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
 tools/lib/lk/Makefile                  |    5 +++++
 tools/lib/lk/rbtree.h                  |    1 +
 tools/perf/Makefile                    |    6 ------
 tools/perf/builtin-annotate.c          |    2 +-
 tools/perf/builtin-kmem.c              |    2 +-
 tools/perf/builtin-report.c            |    2 +-
 tools/perf/builtin-timechart.c         |    2 +-
 tools/perf/builtin-top.c               |    2 +-
 tools/perf/util/callchain.h            |    2 +-
 tools/perf/util/include/linux/rbtree.h |    1 -
 tools/perf/util/map.h                  |    2 +-
 tools/perf/util/session.h              |    2 +-
 tools/perf/util/sort.h                 |    2 +-
 tools/perf/util/strlist.h              |    2 +-
 tools/perf/util/symbol.h               |    2 +-
 tools/perf/util/thread.h               |    2 +-
 tools/perf/util/ui/browser.c           |    2 +-
 tools/perf/util/ui/browsers/hists.c    |    2 +-
 18 files changed, 20 insertions(+), 21 deletions(-)
 create mode 100644 tools/lib/lk/rbtree.h
 delete mode 100644 tools/perf/util/include/linux/rbtree.h

diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
index 985214a..32cf118 100644
--- a/tools/lib/lk/Makefile
+++ b/tools/lib/lk/Makefile
@@ -8,12 +8,15 @@ LIB_H += debugfs.h
 LIB_H += util.h
 LIB_H += types.h
 LIB_H += cpumap.h
+LIB_H += ../../../include/linux/rbtree.h
+LIB_H += rbtree.h
 
 LIB_OBJS += debugfs.o
 LIB_OBJS += usage.o
 LIB_OBJS += util.o
 LIB_OBJS += cpumap.o
 LIB_OBJS += ctype.o
+LIB_OBJS += rbtree.o
 
 LIBFILE = $(LIB_OUTPUT)lklib.a
 
@@ -29,6 +32,8 @@ $(LIBFILE): $(LIB_OBJS)
 
 $(LIB_OBJS): $(LIB_H)
 
+rbtree.o: ../../../lib/rbtree.c
+	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -I../../../include $<
 %.o: %.c
 	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
 %.s: %.c
diff --git ...
From: Borislav Petkov
Date: Thursday, November 4, 2010 - 8:36 am

From: Borislav Petkov <borislav.petkov@amd.com>

Move all bitops-related stuff together.

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
 tools/lib/lk/Makefile                  |    5 ++
 tools/lib/lk/bitmap.c                  |   21 ++++++
 tools/lib/lk/bitmap.h                  |   35 ++++++++++
 tools/lib/lk/bitops.h                  |   30 +++++++++
 tools/lib/lk/hweight.c                 |   31 +++++++++
 tools/lib/lk/kernel.h                  |  113 ++++++++++++++++++++++++++++++++
 tools/perf/Makefile                    |    6 --
 tools/perf/util/bitmap.c               |   21 ------
 tools/perf/util/build-id.c             |    2 +-
 tools/perf/util/event.h                |    1 +
 tools/perf/util/header.c               |    2 +-
 tools/perf/util/header.h               |    2 +-
 tools/perf/util/hweight.c              |   31 ---------
 tools/perf/util/include/asm/hweight.h  |    8 --
 tools/perf/util/include/linux/bitmap.h |   35 ----------
 tools/perf/util/include/linux/bitops.h |   27 --------
 tools/perf/util/include/linux/kernel.h |  111 -------------------------------
 tools/perf/util/map.h                  |    4 +-
 tools/perf/util/parse-options.h        |    2 +-
 tools/perf/util/pstack.c               |    2 +-
 tools/perf/util/session.c              |    2 +-
 tools/perf/util/strlist.h              |    1 +
 tools/perf/util/trace-event-info.c     |    2 +-
 23 files changed, 247 insertions(+), 247 deletions(-)
 create mode 100644 tools/lib/lk/bitmap.c
 create mode 100644 tools/lib/lk/bitmap.h
 create mode 100644 tools/lib/lk/bitops.h
 create mode 100644 tools/lib/lk/hweight.c
 create mode 100644 tools/lib/lk/kernel.h
 delete mode 100644 tools/perf/util/bitmap.c
 delete mode 100644 tools/perf/util/hweight.c
 delete mode 100644 tools/perf/util/include/asm/hweight.h
 delete mode 100644 tools/perf/util/include/linux/bitmap.h
 delete mode 100644 tools/perf/util/include/linux/bitops.h
 delete mode 100644 ...
From: Borislav Petkov
Date: Thursday, November 4, 2010 - 8:36 am

From: Borislav Petkov <borislav.petkov@amd.com>

Needed by other perf utils like map.c and symbol.c

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
 tools/lib/lk/Makefile              |    2 +
 tools/lib/lk/strlist.c             |  200 ++++++++++++++++++++++++++++++++++++
 tools/lib/lk/strlist.h             |   79 ++++++++++++++
 tools/perf/Makefile                |    2 -
 tools/perf/builtin-buildid-cache.c |    2 +-
 tools/perf/builtin-probe.c         |    2 +-
 tools/perf/builtin-report.c        |    2 +-
 tools/perf/builtin-timechart.c     |    2 +-
 tools/perf/util/event.c            |    2 +-
 tools/perf/util/probe-event.c      |    2 +-
 tools/perf/util/probe-event.h      |    2 +-
 tools/perf/util/sort.h             |    2 +-
 tools/perf/util/strlist.c          |  200 ------------------------------------
 tools/perf/util/strlist.h          |   79 --------------
 tools/perf/util/symbol.c           |    2 +-
 15 files changed, 290 insertions(+), 290 deletions(-)
 create mode 100644 tools/lib/lk/strlist.c
 create mode 100644 tools/lib/lk/strlist.h
 delete mode 100644 tools/perf/util/strlist.c
 delete mode 100644 tools/perf/util/strlist.h

diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
index d62e898..36395b1 100644
--- a/tools/lib/lk/Makefile
+++ b/tools/lib/lk/Makefile
@@ -14,6 +14,7 @@ LIB_H += bitops.h
 LIB_H += bitmap.h
 LIB_H += kernel.h
 LIB_H += compiler.h
+LIB_H += strlist.h
 
 LIB_OBJS += debugfs.o
 LIB_OBJS += usage.o
@@ -23,6 +24,7 @@ LIB_OBJS += ctype.o
 LIB_OBJS += rbtree.o
 LIB_OBJS += hweight.o
 LIB_OBJS += bitmap.o
+LIB_OBJS += strlist.o
 
 LIBFILE = $(LIB_OUTPUT)lklib.a
 
diff --git a/tools/lib/lk/strlist.c b/tools/lib/lk/strlist.c
new file mode 100644
index 0000000..6783a20
--- /dev/null
+++ b/tools/lib/lk/strlist.c
@@ -0,0 +1,200 @@
+/*
+ * (c) 2009 Arnaldo Carvalho de Melo <acme@redhat.com>
+ *
+ * Licensed under the GPLv2.
+ */
+
+#include "strlist.h"
+#include <errno.h>
+#include ...
From: Borislav Petkov
Date: Thursday, November 4, 2010 - 8:36 am

From: Borislav Petkov <borislav.petkov@amd.com>

Will be needed by stuff exported later, move perf-wide defines to
perf/config.ch temporarily.

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
 tools/lib/lk/compiler.h        |    2 +
 tools/lib/perf/Makefile        |    5 +
 tools/lib/perf/color.c         |  324 ++++++++++++++++++++++++++
 tools/lib/perf/color.h         |   51 ++++
 tools/lib/perf/config.c        |  502 ++++++++++++++++++++++++++++++++++++++++
 tools/lib/perf/config.h        |   31 +++
 tools/lib/perf/path.c          |  156 +++++++++++++
 tools/lib/trace/Makefile       |    2 +
 tools/lib/trace/parse-events.c |   11 +-
 tools/lib/trace/parse-events.h |    8 +-
 tools/lib/trace/parse-utils.c  |    3 +-
 tools/perf/Makefile            |    8 +-
 tools/perf/builtin-annotate.c  |    2 +-
 tools/perf/builtin-help.c      |    2 +
 tools/perf/builtin-report.c    |    2 +-
 tools/perf/builtin-timechart.c |    2 +-
 tools/perf/builtin-top.c       |    2 +-
 tools/perf/perf.c              |    1 +
 tools/perf/util/abspath.c      |    1 +
 tools/perf/util/alias.c        |    1 +
 tools/perf/util/cache.h        |   19 --
 tools/perf/util/color.c        |  324 --------------------------
 tools/perf/util/color.h        |   46 ----
 tools/perf/util/config.c       |  492 ---------------------------------------
 tools/perf/util/debug.c        |    2 +-
 tools/perf/util/environment.c  |    1 -
 tools/perf/util/exec_cmd.c     |   10 +
 tools/perf/util/help.c         |    2 +
 tools/perf/util/pager.c        |   15 +-
 tools/perf/util/path.c         |  156 -------------
 tools/perf/util/probe-event.c  |    2 +-
 tools/perf/util/sort.h         |    2 +-
 tools/perf/util/ui/browser.c   |    2 +-
 33 files changed, 1110 insertions(+), 1079 deletions(-)
 create mode 100644 tools/lib/perf/color.c
 create mode 100644 tools/lib/perf/color.h
 create mode 100644 tools/lib/perf/config.c
 create mode 100644 tools/lib/perf/config.h
 create mode 100644 ...
From: Borislav Petkov
Date: Thursday, November 4, 2010 - 8:36 am

From: Borislav Petkov <borislav.petkov@amd.com>

This one is generic enough so move it to lib/lk/string.c

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
 tools/lib/lk/Makefile         |    1 +
 tools/lib/lk/string.c         |  296 +++++++++++++++++++++++++++++++++++++++++
 tools/lib/lk/util.h           |    2 +-
 tools/perf/Makefile           |    1 -
 tools/perf/bench/mem-memcpy.c |    2 +-
 tools/perf/util/string.c      |  296 -----------------------------------------
 6 files changed, 299 insertions(+), 299 deletions(-)
 create mode 100644 tools/lib/lk/string.c
 delete mode 100644 tools/perf/util/string.c

diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
index 36395b1..b81f11c 100644
--- a/tools/lib/lk/Makefile
+++ b/tools/lib/lk/Makefile
@@ -25,6 +25,7 @@ LIB_OBJS += rbtree.o
 LIB_OBJS += hweight.o
 LIB_OBJS += bitmap.o
 LIB_OBJS += strlist.o
+LIB_OBJS += string.o
 
 LIBFILE = $(LIB_OUTPUT)lklib.a
 
diff --git a/tools/lib/lk/string.c b/tools/lib/lk/string.c
new file mode 100644
index 0000000..0b02099
--- /dev/null
+++ b/tools/lib/lk/string.c
@@ -0,0 +1,296 @@
+#include <lk/util.h>
+#include "string.h"
+
+#define K 1024LL
+/*
+ * lk_atoll()
+ * Parse (\d+)(b|B|kb|KB|mb|MB|gb|GB|tb|TB) (e.g. "256MB")
+ * and return its numeric value
+ */
+s64 lk_atoll(const char *str)
+{
+	unsigned int i;
+	s64 length = -1, unit = 1;
+
+	if (!isdigit(str[0]))
+		goto out_err;
+
+	for (i = 1; i < strlen(str); i++) {
+		switch (str[i]) {
+		case 'B':
+		case 'b':
+			break;
+		case 'K':
+			if (str[i + 1] != 'B')
+				goto out_err;
+			else
+				goto kilo;
+		case 'k':
+			if (str[i + 1] != 'b')
+				goto out_err;
+kilo:
+			unit = K;
+			break;
+		case 'M':
+			if (str[i + 1] != 'B')
+				goto out_err;
+			else
+				goto mega;
+		case 'm':
+			if (str[i + 1] != 'b')
+				goto out_err;
+mega:
+			unit = K * K;
+			break;
+		case 'G':
+			if (str[i + 1] != 'B')
+				goto out_err;
+			else
+				goto giga;
+		case ...
From: Borislav Petkov
Date: Thursday, November 4, 2010 - 8:36 am

From: Borislav Petkov <borislav.petkov@amd.com>

Those are needed for the RAS daemon.

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
 tools/lib/trace/parse-events.c     |   12 ++++++------
 tools/lib/trace/parse-events.h     |    5 +++++
 tools/lib/trace/trace-event-info.c |   10 +++++-----
 tools/lib/trace/trace-event.h      |    2 ++
 4 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/tools/lib/trace/parse-events.c b/tools/lib/trace/parse-events.c
index 1f95f87..02fc69b 100644
--- a/tools/lib/trace/parse-events.c
+++ b/tools/lib/trace/parse-events.c
@@ -45,7 +45,7 @@ static int show_warning = 1;
 			warning(fmt, ##__VA_ARGS__);	\
 	} while (0)
 
-static void init_input_buf(const char *buf, unsigned long long size)
+void init_input_buf(const char *buf, unsigned long long size)
 {
 	input_buf = buf;
 	input_buf_siz = size;
@@ -585,7 +585,7 @@ void pevent_print_printk(struct pevent *pevent)
 	}
 }
 
-static struct event_format *alloc_event(void)
+struct event_format *alloc_event(void)
 {
 	struct event_format *event;
 
@@ -1079,7 +1079,7 @@ static int read_expected_item(enum event_type expect, const char *str)
 	return __read_expected(expect, str, 0);
 }
 
-static char *event_read_name(void)
+char *event_read_name(void)
 {
 	char *token;
 
@@ -1099,7 +1099,7 @@ static char *event_read_name(void)
 	return NULL;
 }
 
-static int event_read_id(void)
+int event_read_id(void)
 {
 	char *token;
 	int id;
@@ -1394,7 +1394,7 @@ fail_expect:
 	return -1;
 }
 
-static int event_read_format(struct event_format *event)
+int event_read_format(struct event_format *event)
 {
 	char *token;
 	int ret;
@@ -4287,7 +4287,7 @@ int pevent_parse_event(struct pevent *pevent,
 		if (strcmp(event->name, "bprint") == 0)
 			event->flags |= EVENT_FL_ISBPRINT;
 	}
-		
+
 	event->id = event_read_id();
 	if (event->id < 0)
 		die("failed to read event id");
diff --git a/tools/lib/trace/parse-events.h b/tools/lib/trace/parse-events.h
index ...
From: Borislav Petkov
Date: Thursday, November 4, 2010 - 8:36 am

From: Borislav Petkov <borislav.petkov@amd.com>

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
 tools/Makefile     |    4 +
 tools/ras/Makefile |   16 +++
 tools/ras/rasd.c   |  305 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 325 insertions(+), 0 deletions(-)
 create mode 100644 tools/ras/Makefile
 create mode 100644 tools/ras/rasd.c

diff --git a/tools/Makefile b/tools/Makefile
index 691f78b..360454c 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -37,6 +37,9 @@ export PERF_TOP_DIR
 perf: libparsevent lklib lkperflib .FORCE
 	$(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1)
 
+ras: libparsevent lklib lkperflib .FORCE
+	$(QUIET_SUBDIR0)ras/ $(QUIET_SUBDIR1)
+
 libparsevent: .FORCE
 	$(QUIET_SUBDIR0)lib/trace/ $(QUIET_SUBDIR1)
 
@@ -51,5 +54,6 @@ clean:
 	$(QUIET_SUBDIR0)lib/lk/ $(QUIET_SUBDIR1) clean
 	$(QUIET_SUBDIR0)lib/perf/ $(QUIET_SUBDIR1) clean
 	$(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) clean
+	$(QUIET_SUBDIR0)ras/ $(QUIET_SUBDIR1) clean
 
 .PHONY: clean .FORCE
diff --git a/tools/ras/Makefile b/tools/ras/Makefile
new file mode 100644
index 0000000..370ae35
--- /dev/null
+++ b/tools/ras/Makefile
@@ -0,0 +1,16 @@
+include ../scripts/Makefile.lib
+
+CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 -DNO_NEWT_SUPPORT $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
+ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
+ALL_LDFLAGS = $(LDFLAGS)
+
+RASLIBS=$(LIB_OUTPUT)libparsevent.a $(LIB_OUTPUT)lklib.a $(LIB_OUTPUT)lkperflib.a
+
+rasd: rasd.o
+	$(QUIET_CC)$(CC) $(ALL_CFLAGS) -o $@ $^ $(RASLIBS)
+
+%.o: %.c
+	$(QUIET_CC)$(CC) $(ALL_CFLAGS) -c $<
+
+clean:
+	rm -rf *.o rasd
diff --git a/tools/ras/rasd.c b/tools/ras/rasd.c
new file mode 100644
index 0000000..2b02742
--- /dev/null
+++ b/tools/ras/rasd.c
@@ -0,0 +1,305 @@
+/*
+ * Linux RAS daemon.
+ *
+ * Initial code reused from Linux Daemon Writing HOWTO
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include ...
From: Borislav Petkov
Date: Thursday, November 4, 2010 - 8:36 am

From: Borislav Petkov <borislav.petkov@amd.com>

.. and put them into lib/trace/ for a wider use. Also, move a couple of
helpers from perf/util/parse-events.c -> lib/trace/trace-event-info.c.
While at it, merge duplicated enum trace_flag_type.

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
 tools/lib/lk/debugfs.c                             |    1 +
 tools/lib/lk/debugfs.h                             |    1 +
 tools/lib/trace/Makefile                           |    7 +-
 tools/lib/trace/parse-events.h                     |   12 +-
 tools/lib/trace/trace-event-info.c                 |  650 ++++++++++++++++++++
 tools/lib/trace/trace-event-parse.c                |  231 +++++++
 tools/lib/trace/trace-event-read.c                 |  541 ++++++++++++++++
 tools/lib/trace/trace-event.h                      |  115 ++++
 tools/perf/Makefile                                |    4 -
 tools/perf/builtin-kmem.c                          |    2 +-
 tools/perf/builtin-kvm.c                           |    2 +-
 tools/perf/builtin-lock.c                          |    2 +-
 tools/perf/builtin-sched.c                         |    2 +-
 tools/perf/builtin-timechart.c                     |   19 -
 tools/perf/builtin-trace.c                         |    2 +-
 tools/perf/scripts/perl/Perf-Trace-Util/Context.c  |    2 +-
 tools/perf/scripts/perl/Perf-Trace-Util/Context.xs |    2 +-
 .../perf/scripts/python/Perf-Trace-Util/Context.c  |    2 +-
 tools/perf/util/header.c                           |    7 +-
 tools/perf/util/parse-events.c                     |  103 +---
 tools/perf/util/parse-events.h                     |    9 +-
 tools/perf/util/probe-event.c                      |    2 +-
 .../perf/util/scripting-engines/trace-event-perl.c |    2 +-
 .../util/scripting-engines/trace-event-python.c    |    2 +-
 tools/perf/util/trace-event-info.c                 |  566 -----------------
 tools/perf/util/trace-event-parse.c                |  234 -------
 tools/perf/util/trace-event-read.c ...
From: Borislav Petkov
Date: Thursday, November 4, 2010 - 8:36 am

From: Borislav Petkov <borislav.petkov@amd.com>

Those suck in a bunch of other stuff. Put objects shared between
perf/util/ and lib/perf/ in lib/perf/config.ch for now, will go in
lib/perf/shared.ch later.

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
 tools/lib/lk/util.h                    |    2 +
 tools/lib/perf/Makefile                |    4 +
 tools/lib/perf/config.c                |    3 +
 tools/lib/perf/config.h                |    1 +
 tools/lib/perf/map.c                   |  682 +++++++++
 tools/lib/perf/map.h                   |  229 +++
 tools/lib/perf/symbol.c                | 2466 ++++++++++++++++++++++++++++++++
 tools/lib/perf/symbol.h                |  233 +++
 tools/perf/Makefile                    |    4 -
 tools/perf/builtin-annotate.c          |    2 +-
 tools/perf/builtin-buildid-cache.c     |    3 +-
 tools/perf/builtin-buildid-list.c      |    2 +-
 tools/perf/builtin-diff.c              |    2 +-
 tools/perf/builtin-inject.c            |    2 +-
 tools/perf/builtin-kmem.c              |    2 +-
 tools/perf/builtin-kvm.c               |    2 +-
 tools/perf/builtin-lock.c              |    2 +-
 tools/perf/builtin-probe.c             |    3 +-
 tools/perf/builtin-record.c            |    2 +-
 tools/perf/builtin-report.c            |    2 +-
 tools/perf/builtin-sched.c             |    2 +-
 tools/perf/builtin-stat.c              |    1 +
 tools/perf/builtin-test.c              |    2 +-
 tools/perf/builtin-timechart.c         |    2 +-
 tools/perf/builtin-top.c               |    2 +-
 tools/perf/builtin-trace.c             |    2 +-
 tools/perf/util/build-id.c             |    2 +-
 tools/perf/util/build-id.h             |    2 -
 tools/perf/util/callchain.h            |    2 +-
 tools/perf/util/debug.c                |    2 +-
 tools/perf/util/debug.h                |    1 -
 tools/perf/util/event.h                |    2 +-
 tools/perf/util/header.c               |    2 +-
 tools/perf/util/hist.h                 |    1 +
 ...
From: Borislav Petkov
Date: Thursday, November 4, 2010 - 8:36 am

From: Borislav Petkov <borislav.petkov@amd.com>

Sucked in by other utils later.

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
 tools/lib/lk/Makefile                    |    1 +
 tools/lib/lk/compiler.h                  |   12 ++++++++++++
 tools/perf/Makefile                      |    1 -
 tools/perf/bench/bench.h                 |    2 +-
 tools/perf/util/cache.h                  |    2 +-
 tools/perf/util/include/linux/compiler.h |   12 ------------
 tools/perf/util/map.h                    |    2 +-
 7 files changed, 16 insertions(+), 16 deletions(-)
 create mode 100644 tools/lib/lk/compiler.h
 delete mode 100644 tools/perf/util/include/linux/compiler.h

diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
index f074216..d62e898 100644
--- a/tools/lib/lk/Makefile
+++ b/tools/lib/lk/Makefile
@@ -13,6 +13,7 @@ LIB_H += rbtree.h
 LIB_H += bitops.h
 LIB_H += bitmap.h
 LIB_H += kernel.h
+LIB_H += compiler.h
 
 LIB_OBJS += debugfs.o
 LIB_OBJS += usage.o
diff --git a/tools/lib/lk/compiler.h b/tools/lib/lk/compiler.h
new file mode 100644
index 0000000..8e8cc91
--- /dev/null
+++ b/tools/lib/lk/compiler.h
@@ -0,0 +1,12 @@
+#ifndef __LK_COMPILER_H
+#define __LK_COMPILER_H
+
+#ifndef __always_inline
+#define __always_inline	inline
+#endif
+#define __user
+#define __attribute_const__
+
+#define __used		__attribute__((__unused__))
+
+#endif /* __LK_COMPILER_H */
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 6a4a4f5..2e18b37 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -334,7 +334,6 @@ LIB_H += ../../include/linux/perf_event.h
 LIB_H += ../../include/linux/list.h
 LIB_H += ../../include/linux/hash.h
 LIB_H += ../../include/linux/stringify.h
-LIB_H += util/include/linux/compiler.h
 LIB_H += util/include/linux/ctype.h
 LIB_H += util/include/linux/list.h
 LIB_H += util/include/linux/module.h
diff --git a/tools/perf/bench/bench.h b/tools/perf/bench/bench.h
index 0c7ee07..565fce8 100644
--- ...
From: Borislav Petkov
Date: Thursday, November 4, 2010 - 8:36 am

From: Borislav Petkov <borislav.petkov@amd.com>

This is needed for sharing common functionality.

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
 tools/lib/lk/Makefile          |    1 +
 tools/lib/lk/cpumap.c          |    1 +
 tools/lib/lk/util.c            |  116 ++++++++++++++++++++++++++++++++++++++++
 tools/lib/perf/Makefile        |    1 +
 tools/lib/perf/util.h          |    8 +++
 tools/perf/Makefile            |    1 -
 tools/perf/perf.h              |    3 -
 tools/perf/util/parse-events.h |    1 +
 tools/perf/util/util.c         |  116 ----------------------------------------
 9 files changed, 128 insertions(+), 120 deletions(-)
 create mode 100644 tools/lib/lk/util.c
 create mode 100644 tools/lib/perf/util.h
 delete mode 100644 tools/perf/util/util.c

diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
index ff94b2e..985214a 100644
--- a/tools/lib/lk/Makefile
+++ b/tools/lib/lk/Makefile
@@ -11,6 +11,7 @@ LIB_H += cpumap.h
 
 LIB_OBJS += debugfs.o
 LIB_OBJS += usage.o
+LIB_OBJS += util.o
 LIB_OBJS += cpumap.o
 LIB_OBJS += ctype.o
 
diff --git a/tools/lib/lk/cpumap.c b/tools/lib/lk/cpumap.c
index 7c3008a..0c6c12c 100644
--- a/tools/lib/lk/cpumap.c
+++ b/tools/lib/lk/cpumap.c
@@ -1,4 +1,5 @@
 #include <lk/util.h>
+#include <perf/util.h>
 #include <perf.h>
 #include "cpumap.h"
 #include <assert.h>
diff --git a/tools/lib/lk/util.c b/tools/lib/lk/util.c
new file mode 100644
index 0000000..4f35719
--- /dev/null
+++ b/tools/lib/lk/util.c
@@ -0,0 +1,116 @@
+#include <lk/util.h>
+#include <sys/mman.h>
+
+int mkdir_p(char *path, mode_t mode)
+{
+	struct stat st;
+	int err;
+	char *d = path;
+
+	if (*d != '/')
+		return -1;
+
+	if (stat(path, &st) == 0)
+		return 0;
+
+	while (*++d == '/');
+
+	while ((d = strchr(d, '/'))) {
+		*d = '\0';
+		err = stat(path, &st) && mkdir(path, mode);
+		*d++ = '/';
+		if (err)
+			return -1;
+		while (*d == '/')
+			++d;
+	}
+	return (stat(path, &st) && mkdir(path, mode)) ? -1 : ...
From: Borislav Petkov
Date: Thursday, November 4, 2010 - 8:36 am

From: Borislav Petkov <borislav.petkov@amd.com>

Export cpu counting and cpumap manipulating utils for general use. This
pulls ctype.c along.

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
---
 tools/lib/lk/Makefile       |    3 +
 tools/lib/lk/cpumap.c       |  114 +++++++++++++++++++++++++++++++++++++++++++
 tools/lib/lk/cpumap.h       |    7 +++
 tools/lib/lk/ctype.c        |   39 +++++++++++++++
 tools/perf/Makefile         |    3 -
 tools/perf/builtin-record.c |    2 +-
 tools/perf/builtin-stat.c   |    2 +-
 tools/perf/builtin-top.c    |    2 +-
 tools/perf/util/cpumap.c    |  114 -------------------------------------------
 tools/perf/util/cpumap.h    |    7 ---
 tools/perf/util/ctype.c     |   39 ---------------
 11 files changed, 166 insertions(+), 166 deletions(-)
 create mode 100644 tools/lib/lk/cpumap.c
 create mode 100644 tools/lib/lk/cpumap.h
 create mode 100644 tools/lib/lk/ctype.c
 delete mode 100644 tools/perf/util/cpumap.c
 delete mode 100644 tools/perf/util/cpumap.h
 delete mode 100644 tools/perf/util/ctype.c

diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
index 823bbb5..ff94b2e 100644
--- a/tools/lib/lk/Makefile
+++ b/tools/lib/lk/Makefile
@@ -7,9 +7,12 @@ LIB_OBJS=
 LIB_H += debugfs.h
 LIB_H += util.h
 LIB_H += types.h
+LIB_H += cpumap.h
 
 LIB_OBJS += debugfs.o
 LIB_OBJS += usage.o
+LIB_OBJS += cpumap.o
+LIB_OBJS += ctype.o
 
 LIBFILE = $(LIB_OUTPUT)lklib.a
 
diff --git a/tools/lib/lk/cpumap.c b/tools/lib/lk/cpumap.c
new file mode 100644
index 0000000..7c3008a
--- /dev/null
+++ b/tools/lib/lk/cpumap.c
@@ -0,0 +1,114 @@
+#include <lk/util.h>
+#include <perf.h>
+#include "cpumap.h"
+#include <assert.h>
+#include <stdio.h>
+
+int cpumap[MAX_NR_CPUS];
+
+static int default_cpu_map(void)
+{
+	int nr_cpus, i;
+
+	nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+	assert(nr_cpus <= MAX_NR_CPUS);
+	assert((int)nr_cpus >= 0);
+
+	for (i = 0; i < nr_cpus; ++i)
+		cpumap[i] = i;
+
+	return nr_cpus;
+}
+
+static ...
From: Borislav Petkov
Date: Thursday, November 4, 2010 - 8:36 am

From: Steven Rostedt <srostedt@redhat.com>

TBD

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 tools/lib/Makefile                                 |   10 +-
 tools/lib/parse-events.c                           | 3248 ++++++++++++++------
 tools/lib/parse-events.h                           |  604 ++++-
 tools/lib/parse-filter.c                           | 2085 +++++++++++++
 tools/lib/parse-utils.c                            |  110 +
 tools/lib/trace-seq.c                              |  153 +
 tools/lib/util.h                                   |   64 +
 tools/perf/Makefile                                |    8 +-
 tools/perf/builtin-kmem.c                          |    6 +-
 tools/perf/builtin-lock.c                          |   26 +-
 tools/perf/builtin-sched.c                         |   42 +-
 .../util/scripting-engines/trace-event-python.c    |   12 +-
 tools/perf/util/trace-event-info.c                 |    2 +
 tools/perf/util/trace-event-parse.c                |  234 ++
 tools/perf/util/trace-event-read.c                 |   24 +-
 tools/perf/util/trace-event.h                      |   79 +
 16 files changed, 5648 insertions(+), 1059 deletions(-)
 create mode 100644 tools/lib/parse-filter.c
 create mode 100644 tools/lib/parse-utils.c
 create mode 100644 tools/lib/trace-seq.c
 create mode 100644 tools/lib/util.h
 create mode 100644 tools/perf/util/trace-event-parse.c

diff --git a/tools/lib/Makefile b/tools/lib/Makefile
index 4a8ad38..206078b 100644
--- a/tools/lib/Makefile
+++ b/tools/lib/Makefile
@@ -34,10 +34,16 @@ endif
 
 all: libparsevent.a
 
-PEVENT_LIB_OBJS = parse-events.o
+PEVENT_LIB_OBJS += parse-events.o
+PEVENT_LIB_OBJS += parse-filter.o
+PEVENT_LIB_OBJS += parse-utils.o
+PEVENT_LIB_OBJS += trace-seq.o
 
 $(OUTPUT)%.o: %.c
-	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
+	$(QUIET_CC)$(CC) -g -o $@ -c $(ALL_CFLAGS) $<
 
 libparsevent.a: $(PEVENT_LIB_OBJS)
 	$(RM) $@;  $(AR) rcs $@ $^
+
+clean:
+	$(RM) *.a *.o *~ *.so
\ No newline at ...
From: Mauro Carvalho Chehab
Date: Friday, November 5, 2010 - 5:02 am

Hi Boris,


I tried to apply your patches here, but they didn't apply. i suspect that Steven
added some patches there at the meantime, as two patches on your series are already 
on his tree. IMO, the better would be if you could create a temporary tree or branch

This example looks quite ugly to me. I doubt anyone without a datasheet and after a
very careful inspection would know what 0x9c00410000010016 magic number means. I
suspect that writing a wrong magic number will also produce a completely undesired
result. So, the better it to keep the MCE code internally to the driver.

Also, writing a magic number to a node named as "status" seems weird to me.

IMO, instead, it should be something like:

--

From: Borislav Petkov
Date: Friday, November 5, 2010 - 6:46 am

Sure:


Right, this was only a hands-on example of what otherwise a script does.

That's not a problem since this is software-only injection. It actually
makes sense to be able to inject crap so that you can test the decoding
code:

[81953.494078] [Hardware Error]: MC5_STATUS: Uncorrected error, other errors lost: no, CPU context corrupt: yes, UECC Error
[81953.505714] [Hardware Error]: Corrupted FR MCE info?

Well, this way you inject a random error. But you want to control the
error types which you inject and set not only one but a couple of the
MCi_ bank MSRs. In that manner, you can inject the address at which a
certain MCE happens and so on.

So, basically, the long term goal is to have a tool which could do all
that. Maybe something like this:

perf inject --mce --functional-unit DC --uncorrectable --pcc-corrupt --virtual-address 0xdeadbeef ...

or

perf inject --mce --functional-unit IC --random --correctable --ecc

(I have long options so that it's clear what we do - we can make them
shorter in the actual case.) But you get the idea. This way, you can
inject all kinds of stuff and also in a human-readable form.

-- 
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632
--

Previous thread: [PATCH 01/20] perf: Start the massive restructuring by Borislav Petkov on Thursday, November 4, 2010 - 8:36 am. (1 message)

Next thread: [RFD] Perf generic context based exclusion/inclusion (was Re: [PATCH 0/4] Finer granularity and task/cgroup irq time accounting) by Frederic Weisbecker on Thursday, November 4, 2010 - 8:40 am. (4 messages)