Skip to contentSkip to conversation

RAS daemon prototype, v2

RFC PATCH In review Borislav Petkov 5 participants 22 messages Aug 6, 2010 – Sep 1, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover RAS daemon prototype, v2

From: Borislav Petkov <[email protected]>

Hi,

I finally found some time for a second take at the ras daemon. This one is based on Steven's trace-cmd integration into perf:

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

which is still alpha, as are those patches too, btw. I'm sending them now as a RFC/FYI type-thing only, work on them continues.

I've tried to incorporate and accomodate all comments from the last round. Using debugfs files for mmaping the perf buffers makes the code much simpler and introduces a lot less changes to the perf tool wrt to exporting stuff into the library for external use.

The are still unresolved issues like the VM_SHARED check in perf_mmap() which fails for read-only files in debugfs. Peter, what is your take at this, do we want to relax that for persistent read-only events?

Also, I need this hunk otherwise I'm oopsing on exit:

---

kernel/perf_event.c +3 -1
index 8ff5292..8edb400 100644
@@ -2665,7 +2665,9 @@ static void perf_mmap_close(struct vm_area_struct *vma)
                struct user_struct *user = event->mmap_user;
                struct perf_buffer *buffer = event->buffer;
 
-               atomic_long_sub((size >> PAGE_SHIFT) + 1, &user->locked_vm);
+               if (user)
+                       atomic_long_sub((size >> PAGE_SHIFT) + 1, &user->locked_vm);
+
                vma->vm_mm->locked_vm -= event->mmap_locked;
                rcu_assign_pointer(event->buffer, NULL);
                mutex_unlock(&event->mmap_mutex);

--

and I'll add it as an additional patch to the series if there are no objections. See, we add the current user when we mmap but on already allocated event buffers we skip that by exiting early so this change should be fine for events with preallocated buffers, right?

@Arnaldo: I think this version should take care of the build issues you had last time.

To the individual patches:

#1-2: added for completeness here, already upstream #3: export perf funcs for mce
#4: initialize persistence mce event and allocate buffers #5: move Steven's trace-cmd stuff to tools/lib/trace #6-8: needed by the ras daemon and others maybe #9: rough ras daemon skeleton, will flesh out later

Thanks for all your comments last time.

--

Changelog:

V1:

here's the first rough version of all the jerky code that attempts to implement a RAS daemon listening for MCEs using perf. This is a preview code only, I still need to figure out how to do the sample parsing the easiest and flesh out the daemon functionality a bit more. Also, I wanted to reuse as much code as possible therefore a lot had to be reengineered with the perf tool and all its library-like compilation units.

With this, you can do

make perf

or

make ras

and build the respective tool.

Even though I tried to split the patchset for easier review, please bear in mind that there are some fat guys there (241K is the biggest one). However, they don't do anything special except moving code around. As such, they might not appear on lkml due to vger size constraints so I've upped the whole patchset also at

git://git.kernel.org/pub/scm/linux/kernel/git/bp/bp.git perf-v1

The patchset is based on tip/perf/core from last week. Here are some more details to some of the patches individually:

2: enables the mce tracepoint unconditionally. I had a problem with perf_event_attr.sample_period which is checked in perf_swevent_add(). Currently, I'm setting it to ULLONG_MAX but this is icky. I'd much rather have the check do something like

	if (event->type != PERF_EVENT_TYPE_PERSISTENT)
		if (!hwc->sample_period)
			return;

or similar.

4: sys_perf_event_open needs to know about already allocated and enabled events.

5-10: carves out a bunch of generic perf compilation units into a common lib. Split into 5 patches for easier review.

12-14: those are pulled in when exporting parse_events.c for external use.

16: lib/perf/misc.c contains functions and global variables like pager_in_use() or perf_guest or usage_with_options() which are used in generic utilities but are strictly perf-specific. Long term we should strive in making the library self-contained and getting rid of those.

19-20: those are only needed for testing, they'll go in over the edac tree in the next merge window. Added for completeness here.

21: only bare-bones implementation, needs a lot of fleshing out

Anyways, please have a look and let me know either way :)

Thanks,
Boris.

#1 lore raw

RFC PATCH 1/9 x86, mce: Notify about corrected events too

From: Borislav Petkov <[email protected]>

Notify all parties registered on the mce decoder chain about logged correctable MCEs.

---
 arch/x86/kernel/cpu/mcheck/mce.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/x86/kernel/cpu/mcheck/mce.c +1 -0
index 18cc425..1970ef9 100644
@@ -600,6 +600,7 @@ void machine_check_poll(enum mcp_flags flags, mce_banks_t *b)
 		 */
 		if (!(flags & MCP_DONTLOG) && !mce_dont_log_ce) {
 			mce_log(&m);
+			atomic_notifier_call_chain(&x86_mce_decoder_chain, 0, &m);
 			add_taint(TAINT_MACHINE_CHECK);
 		}
 
Signature · 1 line
1.7.1
#2 lore raw

RFC PATCH 2/9 amd64_edac: Remove polling mechanism

In reply to Borislav Petkov

From: Borislav Petkov <[email protected]>

Switch to reusing the mcheck core's machine check polling mechanism instead of duplicating functionality by using the EDAC polling routine.

Correct formatting while at it.

---
 drivers/edac/amd64_edac.c   |  118 -------------------------------------------
 drivers/edac/edac_mce_amd.c |   16 +++---
 2 files changed, 8 insertions(+), 126 deletions(-)
drivers/edac/amd64_edac.c +0 -118
index ac9f798..f9f5f1e 100644
@@ -1975,107 +1975,6 @@ static int get_channel_from_ecc_syndrome(struct mem_ctl_info *mci, u16 syndrome)
 }
 
 /*
- * Check for valid error in the NB Status High register. If so, proceed to read
- * NB Status Low, NB Address Low and NB Address High registers and store data
- * into error structure.
- *
- * Returns:
- *	- 1: if hardware regs contains valid error info
- *	- 0: if no valid error is indicated
- */
-static int amd64_get_error_info_regs(struct mem_ctl_info *mci,
-				     struct err_regs *regs)
-{
-	struct amd64_pvt *pvt;
-	struct pci_dev *misc_f3_ctl;
-
-	pvt = mci->pvt_info;
-	misc_f3_ctl = pvt->misc_f3_ctl;
-
-	if (amd64_read_pci_cfg(misc_f3_ctl, K8_NBSH, &regs->nbsh))
-		return 0;
-
-	if (!(regs->nbsh & K8_NBSH_VALID_BIT))
-		return 0;
-
-	/* valid error, read remaining error information registers */
-	if (amd64_read_pci_cfg(misc_f3_ctl, K8_NBSL, &regs->nbsl) ||
-	    amd64_read_pci_cfg(misc_f3_ctl, K8_NBEAL, &regs->nbeal) ||
-	    amd64_read_pci_cfg(misc_f3_ctl, K8_NBEAH, &regs->nbeah) ||
-	    amd64_read_pci_cfg(misc_f3_ctl, K8_NBCFG, &regs->nbcfg))
-		return 0;
-
-	return 1;
-}
-
-/*
- * This function is called to retrieve the error data from hardware and store it
- * in the info structure.
- *
- * Returns:
- *	- 1: if a valid error is found
- *	- 0: if no error is found
- */
-static int amd64_get_error_info(struct mem_ctl_info *mci,
-				struct err_regs *info)
-{
-	struct amd64_pvt *pvt;
-	struct err_regs regs;
-
-	pvt = mci->pvt_info;
-
-	if (!amd64_get_error_info_regs(mci, info))
-		return 0;
-
-	/*
-	 * Here's the problem with the K8's EDAC reporting: There are four
-	 * registers which report pieces of error information. They are shared
-	 * between CEs and UEs. Furthermore, contrary to what is stated in the
-	 * BKDG, the overflow bit is never used! Every error always updates the
-	 * reporting registers.
-	 *
-	 * Can you see the race condition? All four error reporting registers
-	 * must be read before a new error updates them! There is no way to read
-	 * all four registers atomically. The best than can be done is to detect
-	 * that a race has occured and then report the error without any kind of
-	 * precision.
-	 *
-	 * What is still positive is that errors are still reported and thus
-	 * problems can still be detected - just not localized because the
-	 * syndrome and address are spread out across registers.
-	 *
-	 * Grrrrr!!!!!  Here's hoping that AMD fixes this in some future K8 rev.
-	 * UEs and CEs should have separate register sets with proper overflow
-	 * bits that are used! At very least the problem can be fixed by
-	 * honoring the ErrValid bit in 'nbsh' and not updating registers - just
-	 * set the overflow bit - unless the current error is CE and the new
-	 * error is UE which would be the only situation for overwriting the
-	 * current values.
-	 */
-
-	regs = *info;
-
-	/* Use info from the second read - most current */
-	if (unlikely(!amd64_get_error_info_regs(mci, info)))
-		return 0;
-
-	/* clear the error bits in hardware */
-	pci_write_bits32(pvt->misc_f3_ctl, K8_NBSH, 0, K8_NBSH_VALID_BIT);
-
-	/* Check for the possible race condition */
-	if ((regs.nbsh != info->nbsh) ||
-	     (regs.nbsl != info->nbsl) ||
-	     (regs.nbeah != info->nbeah) ||
-	     (regs.nbeal != info->nbeal)) {
-		amd64_mc_printk(mci, KERN_WARNING,
-				"hardware STATUS read access race condition "
-				"detected!\n");
-		return 0;
-	}
-	return 1;
-}
-
-/*
  * Handle any Correctable Errors (CEs) that have occurred. Check for valid ERROR
  * ADDRESS and process.
  */
@@ -2199,20 +2098,6 @@ void amd64_decode_bus_error(int node_id, struct err_regs *regs)
 }
 
 /*
- * The main polling 'check' function, called FROM the edac core to perform the
- * error checking and if an error is encountered, error processing.
- */
-static void amd64_check(struct mem_ctl_info *mci)
-{
-	struct err_regs regs;
-
-	if (amd64_get_error_info(mci, &regs)) {
-		struct amd64_pvt *pvt = mci->pvt_info;
-		amd_decode_nb_mce(pvt->mc_node_id, &regs, 1);
-	}
-}
-
-/*
  * Input:
  *	1) struct amd64_pvt which contains pvt->dram_f2_ctl pointer
  *	2) AMD Family index value
@@ -2739,9 +2624,6 @@ static void amd64_setup_mci_misc_attributes(struct mem_ctl_info *mci)
 	mci->dev_name		= pci_name(pvt->dram_f2_ctl);
 	mci->ctl_page_to_phys	= NULL;
 
-	/* IMPORTANT: Set the polling 'check' function in this module */
-	mci->edac_check		= amd64_check;
-
 	/* memory scrubber interface */
 	mci->set_sdram_scrub_rate = amd64_set_scrub_rate;
 	mci->get_sdram_scrub_rate = amd64_get_scrub_rate;
drivers/edac/edac_mce_amd.c +8 -8
index 97e64bc..bae9351 100644
@@ -133,7 +133,7 @@ static void amd_decode_dc_mce(u64 mc0_status)
 	u32 ec  = mc0_status & 0xffff;
 	u32 xec = (mc0_status >> 16) & 0xf;
 
-	pr_emerg(" Data Cache Error");
+	pr_emerg("Data Cache Error");
 
 	if (xec == 1 && TLB_ERROR(ec))
 		pr_cont(": %s TLB multimatch.\n", LL_MSG(ec));
@@ -176,7 +176,7 @@ static void amd_decode_ic_mce(u64 mc1_status)
 	u32 ec  = mc1_status & 0xffff;
 	u32 xec = (mc1_status >> 16) & 0xf;
 
-	pr_emerg(" Instruction Cache Error");
+	pr_emerg("Instruction Cache Error");
 
 	if (xec == 1 && TLB_ERROR(ec))
 		pr_cont(": %s TLB multimatch.\n", LL_MSG(ec));
@@ -233,7 +233,7 @@ static void amd_decode_bu_mce(u64 mc2_status)
 	u32 ec = mc2_status & 0xffff;
 	u32 xec = (mc2_status >> 16) & 0xf;
 
-	pr_emerg(" Bus Unit Error");
+	pr_emerg("Bus Unit Error");
 
 	if (xec == 0x1)
 		pr_cont(" in the write data buffers.\n");
@@ -275,7 +275,7 @@ static void amd_decode_ls_mce(u64 mc3_status)
 	u32 ec  = mc3_status & 0xffff;
 	u32 xec = (mc3_status >> 16) & 0xf;
 
-	pr_emerg(" Load Store Error");
+	pr_emerg("Load Store Error");
 
 	if (xec == 0x0) {
 		u8 rrrr = (ec >> 4) & 0xf;
@@ -304,7 +304,7 @@ void amd_decode_nb_mce(int node_id, struct err_regs *regs, int handle_errors)
 	if (TLB_ERROR(ec) && !report_gart_errors)
 		return;
 
-	pr_emerg(" Northbridge Error, node %d", node_id);
+	pr_emerg("Northbridge Error, node %d", node_id);
 
 	/*
 	 * F10h, revD can disable ErrCpu[3:0] so check that first and also the
@@ -342,13 +342,13 @@ static void amd_decode_fr_mce(u64 mc5_status)
 static inline void amd_decode_err_code(unsigned int ec)
 {
 	if (TLB_ERROR(ec)) {
-		pr_emerg(" Transaction: %s, Cache Level %s\n",
+		pr_emerg("Transaction: %s, Cache Level %s\n",
 			 TT_MSG(ec), LL_MSG(ec));
 	} else if (MEM_ERROR(ec)) {
-		pr_emerg(" Transaction: %s, Type: %s, Cache Level: %s",
+		pr_emerg("Transaction: %s, Type: %s, Cache Level: %s",
 			 RRRR_MSG(ec), TT_MSG(ec), LL_MSG(ec));
 	} else if (BUS_ERROR(ec)) {
-		pr_emerg(" Transaction type: %s(%s), %s, Cache Level: %s, "
+		pr_emerg("Transaction type: %s(%s), %s, Cache Level: %s, "
 			 "Participating Processor: %s\n",
 			  RRRR_MSG(ec), II_MSG(ec), TO_MSG(ec), LL_MSG(ec),
 			  PP_MSG(ec));
Signature · 1 line
1.7.1
#3 lore raw

RFC PATCH 3/9 perf_events: Export an assortment of functions

In reply to Borislav Petkov

From: Borislav Petkov <[email protected]>

... for other in-kernel users.

---
 include/linux/perf_event.h |   19 +++++++++++++++++++
 kernel/perf_event.c        |   19 +++++++++----------
 2 files changed, 28 insertions(+), 10 deletions(-)
include/linux/perf_event.h +19 -0
index 937495c..ea2b91c 100644
@@ -14,6 +14,7 @@
 #ifndef _LINUX_PERF_EVENT_H
 #define _LINUX_PERF_EVENT_H
 
+#include <linux/poll.h>
 #include <linux/types.h>
 #include <linux/ioctl.h>
 #include <asm/byteorder.h>
@@ -1019,6 +1020,15 @@ extern int perf_swevent_get_recursion_context(void);
 extern void perf_swevent_put_recursion_context(int rctx);
 extern void perf_event_enable(struct perf_event *event);
 extern void perf_event_disable(struct perf_event *event);
+extern struct perf_buffer *
+perf_buffer_alloc(int nr_pages, long watermark, int cpu, int flags);
+extern void perf_buffer_put(struct perf_buffer *buffer);
+extern unsigned int perf_poll(struct file *file, poll_table *wait);
+extern long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
+extern int perf_mmap(struct file *file, struct vm_area_struct *vma);
+extern int perf_fasync(int fd, struct file *filp, int on);
+extern int perf_release(struct inode *inode, struct file *file);
+
 #else
 static inline void
 perf_event_task_sched_in(struct task_struct *task)			{ }
@@ -1056,6 +1066,15 @@ static inline int  perf_swevent_get_recursion_context(void)		{ return -1; }
 static inline void perf_swevent_put_recursion_context(int rctx)		{ }
 static inline void perf_event_enable(struct perf_event *event)		{ }
 static inline void perf_event_disable(struct perf_event *event)		{ }
+extern struct perf_buffer *
+perf_buffer_alloc(int nr_pages, long watermark, int cpu, int flags)	{ return NULL; }
+static inline void perf_buffer_put(struct perf_buffer *buffer)		{}
+static inline unsigned int perf_poll(struct file *file, poll_table *wait) { return 0; }
+static inline long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { return -ENOTTY; }
+static inline int perf_mmap(struct file *file, struct vm_area_struct *vma) { return -EINVAL; }
+static inline int perf_fasync(int fd, struct file *filp, int on) { return 0; }
+static inline int perf_release(struct inode *inode, struct file *file) { return -EINVAL; }
+
 #endif
 
 #define perf_output_put(handle, x) \
kernel/perf_event.c +9 -10
index c772a3d..8ff5292 100644
@@ -14,7 +14,6 @@
 #include <linux/cpu.h>
 #include <linux/smp.h>
 #include <linux/file.h>
-#include <linux/poll.h>
 #include <linux/slab.h>
 #include <linux/hash.h>
 #include <linux/sysfs.h>
@@ -1881,7 +1880,7 @@ static void free_event_rcu(struct rcu_head *head)
 }
 
 static void perf_pending_sync(struct perf_event *event);
-static void perf_buffer_put(struct perf_buffer *buffer);
+void perf_buffer_put(struct perf_buffer *buffer);
 
 static void free_event(struct perf_event *event)
 {
@@ -1953,7 +1952,7 @@ EXPORT_SYMBOL_GPL(perf_event_release_kernel);
 /*
  * Called when the last reference to the file is gone.
  */
-static int perf_release(struct inode *inode, struct file *file)
+int perf_release(struct inode *inode, struct file *file)
 {
 	struct perf_event *event = file->private_data;
 
@@ -2121,7 +2120,7 @@ perf_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
 	return perf_read_hw(event, buf, count);
 }
 
-static unsigned int perf_poll(struct file *file, poll_table *wait)
+unsigned int perf_poll(struct file *file, poll_table *wait)
 {
 	struct perf_event *event = file->private_data;
 	struct perf_buffer *buffer;
@@ -2239,7 +2238,7 @@ static int perf_event_set_output(struct perf_event *event,
 				 struct perf_event *output_event);
 static int perf_event_set_filter(struct perf_event *event, void __user *arg);
 
-static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
 	struct perf_event *event = file->private_data;
 	void (*func)(struct perf_event *);
@@ -2424,7 +2423,7 @@ static void *perf_mmap_alloc_page(int cpu)
 	return page_address(page);
 }
 
-static struct perf_buffer *
+struct perf_buffer *
 perf_buffer_alloc(int nr_pages, long watermark, int cpu, int flags)
 {
 	struct perf_buffer *buffer;
@@ -2541,7 +2540,7 @@ static void perf_buffer_free(struct perf_buffer *buffer)
 	schedule_work(&buffer->work);
 }
 
-static struct perf_buffer *
+struct perf_buffer *
 perf_buffer_alloc(int nr_pages, long watermark, int cpu, int flags)
 {
 	struct perf_buffer *buffer;
@@ -2642,7 +2641,7 @@ static struct perf_buffer *perf_buffer_get(struct perf_event *event)
 	return buffer;
 }
 
-static void perf_buffer_put(struct perf_buffer *buffer)
+void perf_buffer_put(struct perf_buffer *buffer)
 {
 	if (!atomic_dec_and_test(&buffer->refcount))
 		return;
@@ -2683,7 +2682,7 @@ static const struct vm_operations_struct perf_mmap_vmops = {
 	.page_mkwrite	= perf_mmap_fault,
 };
 
-static int perf_mmap(struct file *file, struct vm_area_struct *vma)
+int perf_mmap(struct file *file, struct vm_area_struct *vma)
 {
 	struct perf_event *event = file->private_data;
 	unsigned long user_locked, user_lock_limit;
@@ -2785,7 +2784,7 @@ unlock:
 	return ret;
 }
 
-static int perf_fasync(int fd, struct file *filp, int on)
+int perf_fasync(int fd, struct file *filp, int on)
 {
 	struct inode *inode = filp->f_path.dentry->d_inode;
 	struct perf_event *event = filp->private_data;
Signature · 1 line
1.7.1
#4 lore raw

RFC PATCH 4/9 mce: Add persistent events

In reply to Borislav Petkov

From: Borislav Petkov <[email protected]>

Add the required glue to enable the mce_record tracepoint on boot thus simulating a persistent event with allocated buffers. Userspace daemon will hook into it later when booting is done. Export mce buffer read-only through debugfs.

---
 arch/x86/kernel/cpu/mcheck/mce.c |  135 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 135 insertions(+), 0 deletions(-)
arch/x86/kernel/cpu/mcheck/mce.c +135 -0
index 1970ef9..cdff254 100644
@@ -95,6 +95,7 @@ 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 perf_event *, mce_event);
 static int			cpu_missing;
 
 /*
@@ -2064,6 +2065,137 @@ 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 | PERF_SAMPLE_CPU | PERF_SAMPLE_TIME,
+};
+
+static int mce_enable_perf_event_on_cpu(int cpu)
+{
+	struct perf_event *event;
+	struct perf_buffer *buffer;
+
+	if (!event_mce_record.event.type) {
+		printk(KERN_ERR "mce: Tracepoint not enumerated yet!\n");
+		return -EINVAL;
+	}
+	pattr.config = event_mce_record.event.type;
+	pattr.sample_period = ULLONG_MAX;
+
+	event = perf_event_create_kernel_counter(&pattr, cpu, -1, NULL);
+	if (IS_ERR(event))
+		return -EINVAL;
+
+	buffer = perf_buffer_alloc(128, 0, cpu, 0);
+	if (IS_ERR(buffer))
+		goto err;
+
+	rcu_assign_pointer(event->buffer, buffer);
+	per_cpu(mce_event, cpu) = event;
+
+	perf_event_enable(event);
+
+	return 0;
+
+err:
+	perf_event_release_kernel(event);
+	return -EINVAL;
+}
+
+static void mce_disable_perf_event_on_cpu(int cpu)
+{
+	struct perf_event *event = per_cpu(mce_event, cpu);
+
+	if (!event)
+		return;
+
+	perf_event_disable(event);
+
+	if (event->buffer) {
+		perf_buffer_put(event->buffer);
+		rcu_assign_pointer(event->buffer, NULL);
+	}
+
+	per_cpu(mce_event, cpu) = NULL;
+
+	perf_event_release_kernel(event);
+}
+
+static int mce_perf_open(struct inode *inode, struct file *file)
+{
+	file->private_data = inode->i_private;
+
+	return 0;
+}
+
+static const struct file_operations perf_mce_fops = {
+	.llseek		= no_llseek,
+	.open		= mce_perf_open,
+	.poll		= perf_poll,
+	.unlocked_ioctl	= perf_ioctl,
+	.compat_ioctl	= perf_ioctl,
+	.mmap		= perf_mmap,
+	.fasync		= perf_fasync,
+	.release	= perf_release,
+};
+
+static int mce_add_perf_debugfs_entry(struct dentry *dmce, int cpu)
+{
+	struct dentry *fmce_record;
+	char buf[14];
+
+	sprintf(buf, "mce_record%d", cpu);
+
+	fmce_record = debugfs_create_file(buf, S_IRUGO, dmce,
+					  per_cpu(mce_event, cpu),
+					  &perf_mce_fops);
+
+	if (!fmce_record)
+		return -ENOMEM;
+
+	return 0;
+}
+
+static int mcheck_init_perf_event(void)
+{
+	int cpu, err = 0;
+
+	get_online_cpus();
+
+	for_each_online_cpu(cpu) {
+		err = mce_enable_perf_event_on_cpu(cpu);
+		if (err) {
+			printk(KERN_ERR "mce: error initializing mce tracepoint"
+					" on cpu %d\n", cpu);
+			goto unwind;
+		}
+
+		err = mce_add_perf_debugfs_entry(mce_get_debugfs_dir(), cpu);
+		if (err) {
+			printk(KERN_ERR "mce: error adding debugfs entry"
+					"on cpu %d\n", cpu);
+			goto unwind;
+		}
+	}
+	goto unlock;
+
+unwind:
+	for (--cpu; cpu >= 0; cpu--)
+		mce_disable_perf_event_on_cpu(cpu);
+
+unlock:
+	put_online_cpus();
+
+	return err;
+}
+
+/*
+ * This has to run after after event_trace_init() which is an fs_initcall()
+ * currently
+ */
+device_initcall(mcheck_init_perf_event);
+
 /* Get notified when a cpu comes on/off. Be hotplug friendly. */
 static int __cpuinit
 mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
@@ -2077,6 +2209,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
 		mce_create_device(cpu);
 		if (threshold_cpu_callback)
 			threshold_cpu_callback(action, cpu);
+		mce_enable_perf_event_on_cpu(cpu);
 		break;
 	case CPU_DEAD:
 	case CPU_DEAD_FROZEN:
@@ -2088,6 +2221,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
 	case CPU_DOWN_PREPARE_FROZEN:
 		del_timer_sync(t);
 		smp_call_function_single(cpu, mce_disable_cpu, &action, 1);
+		mce_disable_perf_event_on_cpu(cpu);
 		break;
 	case CPU_DOWN_FAILED:
 	case CPU_DOWN_FAILED_FROZEN:
@@ -2097,6 +2231,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
 			add_timer_on(t, cpu);
 		}
 		smp_call_function_single(cpu, mce_reenable_cpu, &action, 1);
+		mce_enable_perf_event_on_cpu(cpu);
 		break;
 	case CPU_POST_DEAD:
 		/* intentionally ignoring frozen here */
Signature · 1 line
1.7.1
maintainer
#5 lore raw

Re: [RFC PATCH 4/9] mce: Add persistent events

arch/x86/kernel/cpu/mcheck/mce.c static void __cpuinit mce_reenable_cpu(void *h) · line 2141

Quoted 10 lines · Borislav Petkov
arch/x86/kernel/cpu/mcheck/mce.c +10 -0
+static const struct file_operations perf_mce_fops = {
+       .llseek         = no_llseek,
+       .open           = mce_perf_open,
+       .poll           = perf_poll,
+       .unlocked_ioctl = perf_ioctl,
+       .compat_ioctl   = perf_ioctl,
+       .mmap           = perf_mmap,
+       .fasync         = perf_fasync,
+       .release        = perf_release,
+}; 

I'd rather see this part of the persistent bits live in kernel/perf_event.c, that way you don't need the previous patch either.

#6 lore raw

Re: [RFC PATCH 4/9] mce: Add persistent events

Quoted 15 lines · Peter Zijlstra

arch/x86/kernel/cpu/mcheck/mce.c static void __cpuinit mce_reenable_cpu(void *h) · line 2141

Quoted 10 lines · Borislav Petkov
arch/x86/kernel/cpu/mcheck/mce.c +10 -0
+static const struct file_operations perf_mce_fops = {
+       .llseek         = no_llseek,
+       .open           = mce_perf_open,
+       .poll           = perf_poll,
+       .unlocked_ioctl = perf_ioctl,
+       .compat_ioctl   = perf_ioctl,
+       .mmap           = perf_mmap,
+       .fasync         = perf_fasync,
+       .release        = perf_release,
+}; 

I'd rather see this part of the persistent bits live in kernel/perf_event.c, that way you don't need the previous patch either.

This is part of what I hate about the perf design. The fact that everything needs to be very coupled. I would like the infrastructure to be more flexible.

If this does not work, we should have a better internal API that lets this be done. Otherwise we will have this mce fops in core code that has no business being there.

-- Steve

#7 lore raw

Re: [RFC PATCH 4/9] mce: Add persistent events

Quoted 17 lines · Steven Rostedt
Quoted 15 lines · Peter Zijlstra

arch/x86/kernel/cpu/mcheck/mce.c static void __cpuinit mce_reenable_cpu(void *h) · line 2141

Quoted 10 lines · Borislav Petkov
arch/x86/kernel/cpu/mcheck/mce.c +10 -0
+static const struct file_operations perf_mce_fops = {
+       .llseek         = no_llseek,
+       .open           = mce_perf_open,
+       .poll           = perf_poll,
+       .unlocked_ioctl = perf_ioctl,
+       .compat_ioctl   = perf_ioctl,
+       .mmap           = perf_mmap,
+       .fasync         = perf_fasync,
+       .release        = perf_release,
+}; 

I'd rather see this part of the persistent bits live in kernel/perf_event.c, that way you don't need the previous patch either.

Quoted 3 lines

This is part of what I hate about the perf design. The fact that everything needs to be very coupled. I would like the infrastructure to be more flexible.

Well, Peter's comment was mostly about not making this arch specific but core kernel - the new bits can live in kernel/perf_event_persistent.c just fine.

There is no 'flexibility' in each arch doing the same thing with small variations.

More generally i agree with you that better modularization helps - a nice improvement in this area would be to do a kernel/perf_event/
splitup: i.e. split kernel/perf_event.c (which is getting a tad big) into:

kernel/events/output.c
kernel/events/trace.c
kernel/events/core.c
kernel/events/syscall.c
kernel/events/persistent.c

Maybe even move hw_breakpoint.c there, etc. There's already various wrappers in perf_event.c that could be split out of the core code to increase modularity. Later on we could have a sysfs.c, etc.

Any taker for such a massive restructuring? :)

Thanks,

Ingo

#8 lore raw

Re: [RFC PATCH 4/9] mce: Add persistent events

Quoted 11 lines · Ingo Molnar

More generally i agree with you that better modularization helps - a nice improvement in this area would be to do a kernel/perf_event/
splitup: i.e. split kernel/perf_event.c (which is getting a tad big) into:

kernel/events/output.c
kernel/events/trace.c
kernel/events/core.c
kernel/events/syscall.c
kernel/events/persistent.c

Quoted 5 lines

Maybe even move hw_breakpoint.c there, etc. There's already various wrappers in perf_event.c that could be split out of the core code to increase modularity. Later on we could have a sysfs.c, etc.

Any taker for such a massive restructuring? :)

I'm willing to help out. Just need to get past all the confs I seemed to be going to lately. I feel I'm traveling once a month. Of course my recent vacations did not help any ;-)

-- Steve

#9 lore raw

RFC PATCH 5/9 perf: Move trace stuff into tools/lib/trace

In reply to Borislav Petkov

From: Borislav Petkov <[email protected]>

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.

---
 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 tools/lib/trace/trace-seq.c
 create mode 100644 tools/lib/trace/trace-util.h
 delete mode 100644 tools/lib/util.h
 create mode 100644 tools/scripts/Makefile.lib
tools/Makefile new file +47 -0
new file mode 100644
index 0000000..430b25e
@@ -0,0 +1,47 @@
+include scripts/Makefile.lib
+
+# Include saner warnings here, which can catch bugs:
+#
+EXTRA_WARNINGS := -Wformat
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-security
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-y2k
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Winit-self
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wpacked
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wredundant-decls
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstack-protector
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-aliasing=3
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-default
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-enum
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wno-system-headers
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wundef
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wvolatile-register-var
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wwrite-strings
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wbad-function-cast
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-declarations
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-prototypes
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wnested-externs
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes
+EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement
+
+export EXTRA_WARNINGS
+
+# lib includes for submake
+BASIC_CFLAGS = -I$(CURDIR)/lib/trace -I$(CURDIR)/perf -I$(CURDIR)/perf/util/include
+export BASIC_CFLAGS
+
+PERF_TOP_DIR := $(CURDIR)
+export PERF_TOP_DIR
+
+perf: libparsevent .FORCE
+	$(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1)
+
+libparsevent: .FORCE
+	$(QUIET_SUBDIR0)lib/trace/ $(QUIET_SUBDIR1)
+
+clean:
+	$(QUIET_SUBDIR0)lib/trace/ $(QUIET_SUBDIR1) clean
+	$(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) clean
+
+.PHONY: clean .FORCE
tools/lib/Makefile deleted +0 -49

50 lines not on this page · raw message

tools/lib/parse-events.c deleted +0 -4655

2,903 lines not on this page · raw message

tools/lib/parse-events.h deleted +0 -719

719 lines not on this page · raw message

tools/lib/parse-filter.c deleted +0 -2085

2,085 lines not on this page · raw message

tools/lib/parse-utils.c deleted +0 -110

110 lines not on this page · raw message

tools/lib/trace-seq.c deleted +0 -153

153 lines not on this page · raw message

tools/lib/trace/Makefile new file +54 -0

54 lines not on this page · raw message

tools/lib/trace/parse-events.c new file +4655 -0

4,655 lines not on this page · raw message

tools/lib/trace/parse-events.h new file +719 -0

719 lines not on this page · raw message

tools/lib/trace/parse-filter.c new file +2085 -0

2,085 lines not on this page · raw message

tools/lib/trace/parse-utils.c new file +110 -0

110 lines not on this page · raw message

tools/lib/trace/trace-seq.c new file +153 -0

153 lines not on this page · raw message

tools/lib/trace/trace-util.h new file +64 -0

64 lines not on this page · raw message

tools/lib/util.h deleted +0 -64

64 lines not on this page · raw message

tools/perf/Makefile +2 -39

41 lines not on this page · raw message

tools/perf/util/trace-event.h +1 -1
index e9923bc..6597c73 100644

Lines of this file are not shown. View the raw message.

tools/scripts/Makefile.lib new file +33 -0
new file mode 100644
index 0000000..f125d62

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.1

Part of the diff is not shown here. View the raw message.

#10 lore raw

Re: [RFC PATCH 5/9] perf: Move trace stuff into tools/lib/trace

Quoted 10 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>

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.

Quoted 6 lines

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

---

I'll merge this patch into my tree, and that should make it easier for you.

-- Steve

#11 lore raw

Re: [RFC PATCH 5/9] perf: Move trace stuff into tools/lib/trace

From: Steven Rostedt <[email protected]>
Date: Tue, Aug 31, 2010 at 08:15:44PM -0400

Quoted 15 lines · Borislav Petkov
Quoted 14 lines

From: Borislav Petkov <[email protected]>

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.

Quoted 6 lines
Quoted 2 lines

---

I'll merge this patch into my tree, and that should make it easier for you.

Yeah, that's cool. FYI, Arnaldo wanted to have that toplevel-Makefile thing too (tools/Makefile) so there might be some conflicts depending on how far he is.

Thanks Steven.

Signature · 8 lines
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
#12 lore raw

Re: [RFC PATCH 5/9] perf: Move trace stuff into tools/lib/trace

Quoted 6 lines · Borislav Petkov
Quoted 2 lines

I'll merge this patch into my tree, and that should make it easier for you.

Yeah, that's cool. FYI, Arnaldo wanted to have that toplevel-Makefile thing too (tools/Makefile) so there might be some conflicts depending on how far he is.

OK, thanks for letting me know. I'll get into contact with Arnaldo and sort it out.

-- Steve

#13 lore raw

RFC PATCH 6/9 perf: Export debugfs utilities

In reply to Borislav Petkov

From: Borislav Petkov <[email protected]>

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

---
 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                                  |   23 +--
 tools/perf/perf.h                                  |    2 +-
 tools/perf/util/build-id.c                         |    2 +-
 tools/perf/util/cache.h                            |    4 +-
 tools/perf/util/callchain.c                        |    2 +-
 tools/perf/util/config.c                           |    2 +-
 tools/perf/util/cpumap.c                           |    2 +-
 tools/perf/util/debug.c                            |    2 +-
 tools/perf/util/debugfs.c                          |  240 ----------------
 tools/perf/util/debugfs.h                          |   25 --
 tools/perf/util/header.c                           |    2 +-
 tools/perf/util/header.h                           |    2 +-
 tools/perf/util/hist.c                             |    2 +-
 tools/perf/util/include/linux/ctype.h              |    2 +-
 tools/perf/util/map.h                              |    2 +-
 tools/perf/util/parse-events.c                     |    5 +-
 tools/perf/util/parse-options.c                    |    2 +-
 tools/perf/util/probe-event.c                      |    5 +-
 tools/perf/util/probe-finder.c                     |    2 +-
 tools/perf/util/probe-finder.h                     |    2 +-
 tools/perf/util/pstack.c                           |    2 +-
 .../perf/util/scripting-engines/trace-event-perl.c |    2 +-
 .../util/scripting-engines/trace-event-python.c    |    2 +-
 tools/perf/util/session.c                          |    2 +-
 tools/perf/util/sort.h                             |    2 +-
 tools/perf/util/string.c                           |    2 +-
 tools/perf/util/svghelper.h                        |    2 +-
 tools/perf/util/thread.c                           |    2 +-
 tools/perf/util/trace-event-info.c                 |    3 +-
 tools/perf/util/trace-event-parse.c                |    2 +-
 tools/perf/util/trace-event-read.c                 |    2 +-
 tools/perf/util/trace-event-scripting.c            |    2 +-
 tools/perf/util/types.h                            |   17 --
 tools/perf/util/usage.c                            |   80 ------
 tools/perf/util/util.c                             |    2 +-
 tools/perf/util/util.h                             |  285 --------------------
 tools/perf/util/values.c                           |    2 +-
 tools/perf/util/values.h                           |    2 +-
 65 files changed, 782 insertions(+), 728 deletions(-)
 create mode 100644 tools/lib/lk/Makefile
 create mode 100644 tools/lib/lk/debugfs.c
 create mode 100644 tools/lib/lk/debugfs.h
 create mode 100644 tools/lib/lk/types.h
 create mode 100644 tools/lib/lk/usage.c
 create mode 100644 tools/lib/lk/util.h
 delete mode 100644 tools/perf/util/debugfs.c
 delete mode 100644 tools/perf/util/debugfs.h
 delete mode 100644 tools/perf/util/types.h
 delete mode 100644 tools/perf/util/usage.c
 delete mode 100644 tools/perf/util/util.h
tools/Makefile +6 -2
index 430b25e..d3b1447 100644
@@ -28,20 +28,24 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement
 export EXTRA_WARNINGS
 
 # lib includes for submake
-BASIC_CFLAGS = -I$(CURDIR)/lib/trace -I$(CURDIR)/perf -I$(CURDIR)/perf/util/include
+BASIC_CFLAGS = -I$(CURDIR)/lib/trace -I$(CURDIR)/lib -I$(CURDIR)/perf -I$(CURDIR)/perf/util/include
 export BASIC_CFLAGS
 
 PERF_TOP_DIR := $(CURDIR)
 export PERF_TOP_DIR
 
-perf: libparsevent .FORCE
+perf: libparsevent lklib .FORCE
 	$(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1)
 
 libparsevent: .FORCE
 	$(QUIET_SUBDIR0)lib/trace/ $(QUIET_SUBDIR1)
 
+lklib: .FORCE
+	$(QUIET_SUBDIR0)lib/lk/ $(QUIET_SUBDIR1)
+
 clean:
 	$(QUIET_SUBDIR0)lib/trace/ $(QUIET_SUBDIR1) clean
+	$(QUIET_SUBDIR0)lib/lk/ $(QUIET_SUBDIR1) clean
 	$(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) clean
 
 .PHONY: clean .FORCE
tools/lib/lk/Makefile new file +38 -0
new file mode 100644
index 0000000..823bbb5
@@ -0,0 +1,38 @@
+include ../../scripts/Makefile.lib
+
+# guard against environment variables
+LIB_H=
+LIB_OBJS=
+
+LIB_H += debugfs.h
+LIB_H += util.h
+LIB_H += types.h
+
+LIB_OBJS += debugfs.o
+LIB_OBJS += usage.o
+
+LIBFILE = $(LIB_OUTPUT)lklib.a
+
+CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
+EXTLIBS = -lpthread -lrt -lelf -lm
+ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
+ALL_LDFLAGS = $(LDFLAGS)
+
+RM = rm -f
+
+$(LIBFILE): $(LIB_OBJS)
+	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
+
+$(LIB_OBJS): $(LIB_H)
+
+%.o: %.c
+	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
+%.s: %.c
+	$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
+%.o: %.S
+	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
+
+clean:
+	$(RM) $(LIB_OBJS) $(LIBFILE)
+
+.PHONY: clean
tools/lib/lk/debugfs.c new file +256 -0

256 lines not on this page · raw message

tools/lib/lk/debugfs.h new file +31 -0
new file mode 100644
index 0000000..5970f0b
@@ -0,0 +1,31 @@
+#ifndef __DEBUGFS_H__
+#define __DEBUGFS_H__
+
+#include <sys/mount.h>
+#include <sys/types.h>
+
+#ifndef MAX_PATH
+# define MAX_PATH 256
+#endif
+
+#ifndef STR
+# define _STR(x) #x
+# define STR(x) _STR(x)
+#endif
+
+#define LK_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"
+
+extern char debugfs_mntpt[];
+
+extern const char *debugfs_find_mountpoint(void);
+extern int debugfs_valid_mountpoint(const char *debugfs);
+extern int debugfs_valid_entry(const char *path);
+extern char *debugfs_mount(const char *mountpoint);
+extern int debugfs_umount(void);
+extern int debugfs_write(const char *entry, const char *value);
+extern int debugfs_read(const char *entry, char *buffer, size_t size);
+extern void debugfs_force_cleanup(void);
+extern int debugfs_make_path(const char *element, char *buffer, int size);
+extern int get_debugfs_mntpt(void);
+
+#endif /* __DEBUGFS_H__ */
tools/lib/lk/types.h new file +17 -0
new file mode 100644
index 0000000..eda6c0c
@@ -0,0 +1,17 @@
+#ifndef __LK_TYPES_H
+#define __LK_TYPES_H
+
+/*
+ * We define u64 as unsigned long long for every architecture
+ * so that we can print it with %Lx without getting warnings.
+ */
+typedef unsigned long long u64;
+typedef signed long long   s64;
+typedef unsigned int	   u32;
+typedef signed int	   s32;
+typedef unsigned short	   u16;
+typedef signed short	   s16;
+typedef unsigned char	   u8;
+typedef signed char	   s8;
+
+#endif /* __LK_TYPES_H */
tools/lib/lk/usage.c new file +80 -0

80 lines not on this page · raw message

tools/lib/lk/util.h new file +285 -0

285 lines not on this page · raw message

tools/perf/Makefile +3 -8
index dbab506..3938844 100644
@@ -270,7 +270,7 @@ endif
 # Those must not be GNU-specific; they are shared with perl/ which may
 # be built by a different compiler. (Note that this is an artifact now
 # but it still might be nice to keep that distinction.)
-BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include
+BASIC_CFLAGS += -Iarch/$(ARCH)/include
 BASIC_LDFLAGS =
 
 # Guard against environment variables
@@ -328,7 +328,7 @@ export PERL_PATH
 
 LIB_FILE=$(OUTPUT)libperf.a
 
-EXTRA_LIB_FILE=$(LIB_OUTPUT)libparsevent.a
+EXTRA_LIB_FILES=$(LIB_OUTPUT)libparsevent.a $(LIB_OUTPUT)lklib.a
 
 LIB_H += ../../include/linux/perf_event.h
 LIB_H += ../../include/linux/rbtree.h
@@ -360,16 +360,13 @@ LIB_H += util/cache.h
 LIB_H += util/callchain.h
 LIB_H += util/build-id.h
 LIB_H += util/debug.h
-LIB_H += util/debugfs.h
 LIB_H += util/event.h
 LIB_H += util/exec_cmd.h
-LIB_H += util/types.h
 LIB_H += util/levenshtein.h
 LIB_H += util/map.h
 LIB_H += util/parse-options.h
 LIB_H += util/parse-events.h
 LIB_H += util/quote.h
-LIB_H += util/util.h
 LIB_H += util/header.h
 LIB_H += util/help.h
 LIB_H += util/session.h
@@ -395,7 +392,6 @@ LIB_OBJS += $(OUTPUT)util/alias.o
 LIB_OBJS += $(OUTPUT)util/build-id.o
 LIB_OBJS += $(OUTPUT)util/config.o
 LIB_OBJS += $(OUTPUT)util/ctype.o
-LIB_OBJS += $(OUTPUT)util/debugfs.o
 LIB_OBJS += $(OUTPUT)util/environment.o
 LIB_OBJS += $(OUTPUT)util/event.o
 LIB_OBJS += $(OUTPUT)util/exec_cmd.o
@@ -412,7 +408,6 @@ LIB_OBJS += $(OUTPUT)util/quote.o
 LIB_OBJS += $(OUTPUT)util/strbuf.o
 LIB_OBJS += $(OUTPUT)util/string.o
 LIB_OBJS += $(OUTPUT)util/strlist.o
-LIB_OBJS += $(OUTPUT)util/usage.o
 LIB_OBJS += $(OUTPUT)util/wrapper.o
 LIB_OBJS += $(OUTPUT)util/sigchain.o
 LIB_OBJS += $(OUTPUT)util/symbol.o
@@ -465,7 +460,7 @@ BUILTIN_OBJS += $(OUTPUT)builtin-kvm.o
 BUILTIN_OBJS += $(OUTPUT)builtin-test.o
 BUILTIN_OBJS += $(OUTPUT)builtin-inject.o
 
-PERFLIBS = $(LIB_FILE) $(EXTRA_LIB_FILE)
+PERFLIBS = $(LIB_FILE) $(EXTRA_LIB_FILES)
 
 #
 # Platform specific tweaks
tools/perf/bench/bench.h +2 -0
index f7781c6..0c7ee07 100644
@@ -1,6 +1,8 @@
 #ifndef BENCH_H
 #define BENCH_H
 
+#include <linux/compiler.h>
+
 extern int bench_sched_messaging(int argc, const char **argv, const char *prefix);
 extern int bench_sched_pipe(int argc, const char **argv, const char *prefix);
 extern int bench_mem_memcpy(int argc, const char **argv, const char *prefix __used);
tools/perf/bench/mem-memcpy.c +1 -1
index 38dae74..1b2f508 100644
@@ -8,7 +8,7 @@
 #include <ctype.h>
 
 #include "../perf.h"
-#include "../util/util.h"
+#include <lk/util.h>
 #include "../util/parse-options.h"
 #include "../util/header.h"
 #include "bench.h"
tools/perf/bench/sched-messaging.c +1 -1
index d1d1b30..37f12ad 100644
@@ -10,7 +10,7 @@
  */
 
 #include "../perf.h"
-#include "../util/util.h"
+#include <lk/util.h>
 #include "../util/parse-options.h"
 #include "../builtin.h"
 #include "bench.h"
tools/perf/bench/sched-pipe.c +1 -1
index d9ab3ce..9b05c92 100644
@@ -11,7 +11,7 @@
  */
 
 #include "../perf.h"
-#include "../util/util.h"
+#include <lk/util.h>
 #include "../util/parse-options.h"
 #include "../builtin.h"
 #include "bench.h"
tools/perf/builtin-annotate.c +1 -1
index fd20670..03f80e9 100644
@@ -7,7 +7,7 @@
  */
 #include "builtin.h"
 
-#include "util/util.h"
+#include <lk/util.h>
 
 #include "util/color.h"
 #include <linux/list.h>
tools/perf/builtin-bench.c +1 -1
index fcb9626..4ae8ea2 100644
@@ -17,7 +17,7 @@
  */
 
 #include "perf.h"
-#include "util/util.h"
+#include <lk/util.h>
 #include "util/parse-options.h"
 #include "builtin.h"
 #include "bench/bench.h"
tools/perf/builtin-diff.c +1 -1
index 39e6627..2f5a711 100644
@@ -12,7 +12,7 @@
 #include "util/session.h"
 #include "util/sort.h"
 #include "util/symbol.h"
-#include "util/util.h"
+#include <lk/util.h>
 
 #include <stdlib.h>
 
tools/perf/builtin-kmem.c +1 -1
index 97b3970..95901eb 100644
@@ -1,7 +1,7 @@
 #include "builtin.h"
 #include "perf.h"
 
-#include "util/util.h"
+#include <lk/util.h>
 #include "util/cache.h"
 #include "util/symbol.h"
 #include "util/thread.h"
tools/perf/builtin-kvm.c +1 -1
index 34d1e85..3e5d0fc 100644
@@ -1,7 +1,7 @@
 #include "builtin.h"
 #include "perf.h"
 
-#include "util/util.h"
+#include <lk/util.h>
 #include "util/cache.h"
 #include "util/symbol.h"
 #include "util/thread.h"
tools/perf/builtin-lock.c +1 -1
index fbc512a..76253d7 100644
@@ -1,7 +1,7 @@
 #include "builtin.h"
 #include "perf.h"
 
-#include "util/util.h"
+#include <lk/util.h>
 #include "util/cache.h"
 #include "util/symbol.h"
 #include "util/thread.h"
tools/perf/builtin-probe.c +3 -2
index 5455186..066cc49 100644
@@ -32,13 +32,14 @@
 #include <string.h>
 
 #undef _GNU_SOURCE
+#include <lk/util.h>
+#include <lk/debugfs.h>
+
 #include "perf.h"
 #include "builtin.h"
-#include "util/util.h"
 #include "util/strlist.h"
 #include "util/symbol.h"
 #include "util/debug.h"
-#include "util/debugfs.h"
 #include "util/parse-options.h"
 #include "util/probe-finder.h"
 #include "util/probe-event.h"
tools/perf/builtin-record.c +1 -1
index b938796..7447269 100644
@@ -12,7 +12,7 @@
 #include "perf.h"
 
 #include "util/build-id.h"
-#include "util/util.h"
+#include <lk/util.h>
 #include "util/parse-options.h"
 #include "util/parse-events.h"
 
tools/perf/builtin-report.c +1 -1
index ce42bba..e97d480 100644
@@ -7,7 +7,7 @@
  */
 #include "builtin.h"
 
-#include "util/util.h"
+#include <lk/util.h>
 
 #include "util/color.h"
 #include <linux/list.h>
tools/perf/builtin-sched.c +1 -1
index 3e98de5..a9ec0c3 100644
@@ -1,7 +1,7 @@
 #include "builtin.h"
 #include "perf.h"
 
-#include "util/util.h"
+#include <lk/util.h>
 #include "util/cache.h"
 #include "util/symbol.h"
 #include "util/thread.h"
tools/perf/builtin-stat.c +1 -1
index a6b4d44..12dabd3 100644
@@ -39,7 +39,7 @@
 
 #include "perf.h"
 #include "builtin.h"
-#include "util/util.h"
+#include <lk/util.h>
 #include "util/parse-options.h"
 #include "util/parse-events.h"
 #include "util/event.h"
tools/perf/builtin-timechart.c +1 -1
index 5161619..b6628a0 100644
@@ -14,7 +14,7 @@
 
 #include "builtin.h"
 
-#include "util/util.h"
+#include <lk/util.h>
 
 #include "util/color.h"
 #include <linux/list.h>
tools/perf/builtin-top.c +1 -1
index 1e8e92e..8d94e16 100644
@@ -24,7 +24,7 @@
 #include "util/session.h"
 #include "util/symbol.h"
 #include "util/thread.h"
-#include "util/util.h"
+#include <lk/util.h>
 #include <linux/rbtree.h>
 #include "util/parse-options.h"
 #include "util/parse-events.h"
tools/perf/builtin-trace.c +1 -1
index 294da72..41e892d 100644
@@ -1,6 +1,6 @@
 #include "builtin.h"
 
-#include "util/util.h"
+#include <lk/util.h>
 #include "util/cache.h"
 #include "util/symbol.h"
 #include "util/thread.h"
tools/perf/builtin.h +1 -1
index 921245b..08e69d2 100644
@@ -1,7 +1,7 @@
 #ifndef BUILTIN_H
 #define BUILTIN_H
 
-#include "util/util.h"
+#include <lk/util.h>
 #include "util/strbuf.h"
 
 extern const char perf_version_string[];
tools/perf/perf.c +6 -17
index cdd6c03..1fa597c 100644
@@ -6,14 +6,14 @@
  * This is the main hub from which the sub-commands (perf stat,
  * perf top, perf record, perf report, etc.) are started.
  */
-#include "builtin.h"
+#include <lk/debugfs.h>
 
+#include "builtin.h"
 #include "util/exec_cmd.h"
 #include "util/cache.h"
 #include "util/quote.h"
 #include "util/run-command.h"
 #include "util/parse-events.h"
-#include "util/debugfs.h"
 
 const char perf_usage_string[] =
 	"perf [--version] [--help] COMMAND [ARGS]";
@@ -29,8 +29,6 @@ struct pager_config {
 	int val;
 };
 
-static char debugfs_mntpt[MAXPATHLEN];
-
 static int pager_command_config(const char *var, const char *value, void *data)
 {
 	struct pager_config *c = data;
@@ -85,7 +83,7 @@ static void set_debugfs_path(void)
 {
 	char *path;
 
-	path = getenv(PERF_DEBUGFS_ENVIRONMENT);
+	path = getenv(LK_DEBUGFS_ENVIRONMENT);
 	snprintf(debugfs_path, MAXPATHLEN, "%s/%s", path ?: debugfs_mntpt,
 		 "tracing/events");
 }
@@ -415,17 +413,6 @@ static int run_argv(int *argcp, const char ***argv)
 	return done_alias;
 }
 
-/* mini /proc/mounts parser: searching for "^blah /mount/point debugfs" */
-static void get_debugfs_mntpt(void)
-{
-	const char *path = debugfs_mount(NULL);
-
-	if (path)
-		strncpy(debugfs_mntpt, path, sizeof(debugfs_mntpt));
-	else
-		debugfs_mntpt[0] = '\0';
-}
-
 int main(int argc, const char **argv)
 {
 	const char *cmd;
@@ -434,7 +421,9 @@ int main(int argc, const char **argv)
 	if (!cmd)
 		cmd = "perf-help";
 	/* get debugfs mount point from /proc/mounts */
-	get_debugfs_mntpt();
+	if(get_debugfs_mntpt())
+		die("cannot find debugfs mountpoint");
+
 	/*
 	 * "perf-xxxx" is the same as "perf xxxx", but we obviously:
 	 *
tools/perf/perf.h +1 -1
index ef7aa0a..2344078 100644
@@ -79,7 +79,7 @@ void get_term_dimensions(struct winsize *ws);
 #include <sys/syscall.h>
 
 #include "../../include/linux/perf_event.h"
-#include "util/types.h"
+#include <lk/types.h>
 #include <stdbool.h>
 
 /*
tools/perf/util/build-id.c +1 -1
index 5c26e2d..5de09e2 100644
@@ -6,7 +6,7 @@
  * Copyright (C) 2009, 2010 Red Hat Inc.
  * Copyright (C) 2009, 2010 Arnaldo Carvalho de Melo <[email protected]>
  */
-#include "util.h"
+#include <lk/util.h>
 #include <stdio.h>
 #include "build-id.h"
 #include "event.h"
tools/perf/util/cache.h +2 -2
index 27e9ebe..ce83e82 100644
@@ -2,9 +2,10 @@
 #define __PERF_CACHE_H
 
 #include <stdbool.h>
-#include "util.h"
+#include <lk/util.h>
 #include "strbuf.h"
 #include "../perf.h"
+#include <linux/compiler.h>
 
 #define CMD_EXEC_PATH "--exec-path"
 #define CMD_PERF_DIR "--perf-dir="
@@ -15,7 +16,6 @@
 #define PERF_WORK_TREE_ENVIRONMENT "PERF_WORK_TREE"
 #define EXEC_PATH_ENVIRONMENT "PERF_EXEC_PATH"
 #define DEFAULT_PERF_DIR_ENVIRONMENT ".perf"
-#define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"
 
 typedef int (*config_fn_t)(const char *, const char *, void *);
 extern int perf_default_config(const char *, const char *, void *);
tools/perf/util/callchain.c +1 -1
index f231f43..56fe538 100644
@@ -15,7 +15,7 @@
 #include <errno.h>
 #include <math.h>
 
-#include "util.h"
+#include <lk/util.h>
 #include "callchain.h"
 
 bool ip_callchain__valid(struct ip_callchain *chain, const event_t *event)
tools/perf/util/config.c +1 -1
index e02d78c..bb2f5a0 100644
@@ -5,7 +5,7 @@
  * Copyright (C) Johannes Schindelin, 2005
  *
  */
-#include "util.h"
+#include <lk/util.h>
 #include "cache.h"
 #include "exec_cmd.h"
 
tools/perf/util/cpumap.c +1 -1
index 0f9b8d7..8ef8cef 100644
@@ -1,4 +1,4 @@
-#include "util.h"
+#include <lk/util.h>
 #include "../perf.h"
 #include "cpumap.h"
 #include <assert.h>
tools/perf/util/debug.c +1 -1
index 318dab1..96cb72a 100644
@@ -10,7 +10,7 @@
 #include "color.h"
 #include "event.h"
 #include "debug.h"
-#include "util.h"
+#include <lk/util.h>
 
 int verbose = 0;
 bool dump_trace = false;
tools/perf/util/debugfs.c deleted +0 -240

240 lines not on this page · raw message

tools/perf/util/debugfs.h deleted +0 -25
deleted file mode 100644
index 83a0287..0000000
@@ -1,25 +0,0 @@
-#ifndef __DEBUGFS_H__
-#define __DEBUGFS_H__
-
-#include <sys/mount.h>
-
-#ifndef MAX_PATH
-# define MAX_PATH 256
-#endif
-
-#ifndef STR
-# define _STR(x) #x
-# define STR(x) _STR(x)
-#endif
-
-extern const char *debugfs_find_mountpoint(void);
-extern int debugfs_valid_mountpoint(const char *debugfs);
-extern int debugfs_valid_entry(const char *path);
-extern char *debugfs_mount(const char *mountpoint);
-extern int debugfs_umount(void);
-extern int debugfs_write(const char *entry, const char *value);
-extern int debugfs_read(const char *entry, char *buffer, size_t size);
-extern void debugfs_force_cleanup(void);
-extern int debugfs_make_path(const char *element, char *buffer, int size);
-
-#endif /* __DEBUGFS_H__ */
tools/perf/util/header.c +1 -1
index d7e67b1..0ebd301 100644
@@ -8,7 +8,7 @@
 #include <linux/list.h>
 #include <linux/kernel.h>
 
-#include "util.h"
+#include <lk/util.h>
 #include "header.h"
 #include "../perf.h"
 #include "trace-event.h"
tools/perf/util/header.h +1 -1
index 402ac24..fb6f0eb 100644
@@ -4,7 +4,7 @@
 #include "../../../include/linux/perf_event.h"
 #include <sys/types.h>
 #include <stdbool.h>
-#include "types.h"
+#include <lk/types.h>
 #include "event.h"
 
 #include <linux/bitmap.h>
tools/perf/util/hist.c +1 -1
index 7b5848c..54b9168 100644
@@ -1,4 +1,4 @@
-#include "util.h"
+#include <lk/util.h>
 #include "build-id.h"
 #include "hist.h"
 #include "session.h"
tools/perf/util/include/linux/ctype.h +1 -1
index a53d4ee..0698f26 100644
@@ -1 +1 @@
-#include "../util.h"
+#include <lk/util.h>
tools/perf/util/map.h +1 -1
index f391345..c7ed844 100644
@@ -6,7 +6,7 @@
 #include <linux/rbtree.h>
 #include <stdio.h>
 #include <stdbool.h>
-#include "types.h"
+#include <lk/types.h>
 
 enum map_type {
 	MAP__FUNCTION = 0,
tools/perf/util/parse-events.c +3 -2
index 4af5bd5..01686b5 100644
@@ -1,5 +1,7 @@
+#include <lk/util.h>
+#include <lk/debugfs.h>
+
 #include "../../../include/linux/hw_breakpoint.h"
-#include "util.h"
 #include "../perf.h"
 #include "parse-options.h"
 #include "parse-events.h"
@@ -8,7 +10,6 @@
 #include "symbol.h"
 #include "cache.h"
 #include "header.h"
-#include "debugfs.h"
 
 int				nr_counters;
 
tools/perf/util/parse-options.c +1 -1
index 99d02aa..25b57fc 100644
@@ -1,4 +1,4 @@
-#include "util.h"
+#include <lk/util.h>
 #include "parse-options.h"
 #include "cache.h"
 
tools/perf/util/probe-event.c +3 -2
index 4445a1e..9511e5c 100644
@@ -33,7 +33,9 @@
 #include <limits.h>
 
 #undef _GNU_SOURCE
-#include "util.h"
+#include <lk/util.h>
+#include <lk/debugfs.h>
+
 #include "event.h"
 #include "string.h"
 #include "strlist.h"
@@ -42,7 +44,6 @@
 #include "color.h"
 #include "symbol.h"
 #include "thread.h"
-#include "debugfs.h"
 #include "trace-event.h"	/* For __unused */
 #include "probe-event.h"
 #include "probe-finder.h"
tools/perf/util/probe-finder.c +1 -1
index f88070e..71a0f7d 100644
@@ -36,7 +36,7 @@
 #include "string.h"
 #include "event.h"
 #include "debug.h"
-#include "util.h"
+#include <lk/util.h>
 #include "symbol.h"
 #include "probe-finder.h"
 
tools/perf/util/probe-finder.h +1 -1
index e1f61dc..470611b 100644
@@ -2,7 +2,7 @@
 #define _PROBE_FINDER_H
 
 #include <stdbool.h>
-#include "util.h"
+#include <lk/util.h>
 #include "probe-event.h"
 
 #define MAX_PATH_LEN		 256
tools/perf/util/pstack.c +1 -1
index 13d36fa..aacedb8 100644
@@ -4,7 +4,7 @@
  * (c) 2010 Arnaldo Carvalho de Melo <[email protected]>
  */
 
-#include "util.h"
+#include <lk/util.h>
 #include "pstack.h"
 #include <linux/kernel.h>
 #include <stdlib.h>
tools/perf/util/scripting-engines/trace-event-perl.c +1 -1
index b059dc5..78af7d1 100644
@@ -26,7 +26,7 @@
 #include <errno.h>
 
 #include "../../perf.h"
-#include "../util.h"
+#include <lk/util.h>
 #include "../trace-event.h"
 
 #include <EXTERN.h>
tools/perf/util/scripting-engines/trace-event-python.c +1 -1
index 9e8d535..524d355 100644
@@ -28,7 +28,7 @@
 #include <errno.h>
 
 #include "../../perf.h"
-#include "../util.h"
+#include <lk/util.h>
 #include "../trace-event.h"
 
 PyMODINIT_FUNC initperf_trace_context(void);
tools/perf/util/session.c +1 -1
index 0307918..3beab6e 100644
@@ -9,7 +9,7 @@
 
 #include "session.h"
 #include "sort.h"
-#include "util.h"
+#include <lk/util.h>
 
 static int perf_session__open(struct perf_session *self, bool force)
 {
tools/perf/util/sort.h +1 -1
index 560c855..8ead949 100644
@@ -2,7 +2,7 @@
 #define __PERF_SORT_H
 #include "../builtin.h"
 
-#include "util.h"
+#include <lk/util.h>
 
 #include "color.h"
 #include <linux/list.h>
tools/perf/util/string.c +1 -1
index 0409fc7..881ef63 100644
@@ -1,4 +1,4 @@
-#include "util.h"
+#include <lk/util.h>
 #include "string.h"
 
 #define K 1024LL
tools/perf/util/svghelper.h +1 -1
index e078198..ac74b40 100644
@@ -1,7 +1,7 @@
 #ifndef __PERF_SVGHELPER_H
 #define __PERF_SVGHELPER_H
 
-#include "types.h"
+#include <lk/types.h>
 
 extern void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end);
 extern void svg_box(int Yslot, u64 start, u64 end, const char *type);
tools/perf/util/thread.c +1 -1
index 9a448b4..81d5d73 100644
@@ -4,7 +4,7 @@
 #include <string.h>
 #include "session.h"
 #include "thread.h"
-#include "util.h"
+#include <lk/util.h>
 #include "debug.h"
 
 /* Skip "." and ".." directories */
tools/perf/util/trace-event-info.c +2 -1
index d5083d8..44831be 100644
@@ -36,9 +36,10 @@
 #include <stdbool.h>
 #include <linux/kernel.h>
 
+#include <lk/debugfs.h>
+
 #include "../perf.h"
 #include "trace-event.h"
-#include "debugfs.h"
 
 #define VERSION "0.5"
 
tools/perf/util/trace-event-parse.c +1 -1
index c1d3097..489907c 100644
@@ -27,7 +27,7 @@
 
 #undef _GNU_SOURCE
 #include "../perf.h"
-#include "util.h"
+#include <lk/util.h>
 #include "trace-event.h"
 
 int header_page_size_size;
tools/perf/util/trace-event-read.c +1 -1
index 188e100..d42a5a9 100644
@@ -37,7 +37,7 @@
 #include <errno.h>
 
 #include "../perf.h"
-#include "util.h"
+#include <lk/util.h>
 #include "trace-event.h"
 
 static int input_fd;
tools/perf/util/trace-event-scripting.c +1 -1
index 7ea983a..dae67df 100644
@@ -26,7 +26,7 @@
 #include <errno.h>
 
 #include "../perf.h"
-#include "util.h"
+#include <lk/util.h>
 #include "trace-event.h"
 
 struct scripting_context *scripting_context;
tools/perf/util/types.h deleted +0 -17
deleted file mode 100644
index 7d6b833..0000000
@@ -1,17 +0,0 @@
-#ifndef __PERF_TYPES_H
-#define __PERF_TYPES_H
-
-/*
- * We define u64 as unsigned long long for every architecture
- * so that we can print it with %Lx without getting warnings.
- */
-typedef unsigned long long u64;
-typedef signed long long   s64;
-typedef unsigned int	   u32;
-typedef signed int	   s32;
-typedef unsigned short	   u16;
-typedef signed short	   s16;
-typedef unsigned char	   u8;
-typedef signed char	   s8;
-
-#endif /* __PERF_TYPES_H */
tools/perf/util/usage.c deleted +0 -80

80 lines not on this page · raw message

tools/perf/util/util.c +1 -1
index 2142656..4f35719 100644
@@ -1,4 +1,4 @@
-#include "util.h"
+#include <lk/util.h>
 #include <sys/mman.h>
 
 int mkdir_p(char *path, mode_t mode)
tools/perf/util/util.h deleted +0 -285

285 lines not on this page · raw message

tools/perf/util/values.c +1 -1
index cfa55d6..648fc48 100644
@@ -1,6 +1,6 @@
 #include <stdlib.h>
 
-#include "util.h"
+#include <lk/util.h>
 #include "values.h"
 
 void perf_read_values_init(struct perf_read_values *values)
tools/perf/util/values.h +1 -1
index 2fa967e..f762cb7 100644
@@ -1,7 +1,7 @@
 #ifndef __PERF_VALUES_H
 #define __PERF_VALUES_H
 
-#include "types.h"
+#include <lk/types.h>
 
 struct perf_read_values {
 	int threads;
Signature · 1 line
1.7.1
#14 lore raw

RFC PATCH 7/9 perf: Export cpumap

In reply to Borislav Petkov

From: Borislav Petkov <[email protected]>

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

---
 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
tools/lib/lk/Makefile +3 -0
index 823bbb5..ff94b2e 100644
@@ -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
 
tools/lib/lk/cpumap.c new file +114 -0

114 lines not on this page · raw message

tools/lib/lk/cpumap.h new file +7 -0
new file mode 100644
index 0000000..1d7bd56
@@ -0,0 +1,7 @@
+#ifndef __LK_CPUMAP_H
+#define __LK_CPUMAP_H
+
+extern int read_cpu_map(const char *cpu_list);
+extern int cpumap[];
+
+#endif /* __LK_CPUMAP_H */
tools/lib/lk/ctype.c new file +39 -0
new file mode 100644
index 0000000..aada3ac
@@ -0,0 +1,39 @@
+/*
+ * Sane locale-independent, ASCII ctype.
+ *
+ * No surprises, and works with signed and unsigned chars.
+ */
+#include "util.h"
+
+enum {
+	S = GIT_SPACE,
+	A = GIT_ALPHA,
+	D = GIT_DIGIT,
+	G = GIT_GLOB_SPECIAL,	/* *, ?, [, \\ */
+	R = GIT_REGEX_SPECIAL,	/* $, (, ), +, ., ^, {, | * */
+	P = GIT_PRINT_EXTRA,	/* printable - alpha - digit - glob - regex */
+
+	PS = GIT_SPACE | GIT_PRINT_EXTRA,
+};
+
+unsigned char sane_ctype[256] = {
+/*	0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F			    */
+
+	0, 0, 0, 0, 0, 0, 0, 0, 0, S, S, 0, 0, S, 0, 0,		/*   0.. 15 */
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,		/*  16.. 31 */
+	PS,P, P, P, R, P, P, P, R, R, G, R, P, P, R, P,		/*  32.. 47 */
+	D, D, D, D, D, D, D, D, D, D, P, P, P, P, P, G,		/*  48.. 63 */
+	P, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,		/*  64.. 79 */
+	A, A, A, A, A, A, A, A, A, A, A, G, G, P, R, P,		/*  80.. 95 */
+	P, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,		/*  96..111 */
+	A, A, A, A, A, A, A, A, A, A, A, R, R, P, P, 0,		/* 112..127 */
+	/* Nothing in the 128.. range */
+};
+
+const char *graph_line =
+	"_____________________________________________________________________"
+	"_____________________________________________________________________";
+const char *graph_dotted_line =
+	"---------------------------------------------------------------------"
+	"---------------------------------------------------------------------"
+	"---------------------------------------------------------------------";
tools/perf/Makefile +0 -3
index 3938844..7171f27 100644
@@ -385,13 +385,11 @@ LIB_H += util/trace-event.h
 LIB_H += util/probe-finder.h
 LIB_H += util/probe-event.h
 LIB_H += util/pstack.h
-LIB_H += util/cpumap.h
 
 LIB_OBJS += $(OUTPUT)util/abspath.o
 LIB_OBJS += $(OUTPUT)util/alias.o
 LIB_OBJS += $(OUTPUT)util/build-id.o
 LIB_OBJS += $(OUTPUT)util/config.o
-LIB_OBJS += $(OUTPUT)util/ctype.o
 LIB_OBJS += $(OUTPUT)util/environment.o
 LIB_OBJS += $(OUTPUT)util/event.o
 LIB_OBJS += $(OUTPUT)util/exec_cmd.o
@@ -430,7 +428,6 @@ LIB_OBJS += $(OUTPUT)util/sort.o
 LIB_OBJS += $(OUTPUT)util/hist.o
 LIB_OBJS += $(OUTPUT)util/probe-event.o
 LIB_OBJS += $(OUTPUT)util/util.o
-LIB_OBJS += $(OUTPUT)util/cpumap.o
 
 BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
 
tools/perf/builtin-record.c +1 -1
index 7447269..e55aa5b 100644
@@ -21,7 +21,7 @@
 #include "util/debug.h"
 #include "util/session.h"
 #include "util/symbol.h"
-#include "util/cpumap.h"
+#include <lk/cpumap.h>
 
 #include <unistd.h>
 #include <sched.h>
tools/perf/builtin-stat.c +1 -1
index 12dabd3..1f60239 100644
@@ -45,7 +45,7 @@
 #include "util/event.h"
 #include "util/debug.h"
 #include "util/header.h"
-#include "util/cpumap.h"
+#include <lk/cpumap.h>
 #include "util/thread.h"
 
 #include <sys/prctl.h>
tools/perf/builtin-top.c +1 -1
index 8d94e16..9813351 100644
@@ -28,7 +28,7 @@
 #include <linux/rbtree.h>
 #include "util/parse-options.h"
 #include "util/parse-events.h"
-#include "util/cpumap.h"
+#include <lk/cpumap.h>
 
 #include "util/debug.h"
 
tools/perf/util/cpumap.c deleted +0 -114

114 lines not on this page · raw message

tools/perf/util/cpumap.h deleted +0 -7
deleted file mode 100644
index 3e60f56..0000000
@@ -1,7 +0,0 @@
-#ifndef __PERF_CPUMAP_H
-#define __PERF_CPUMAP_H
-
-extern int read_cpu_map(const char *cpu_list);
-extern int cpumap[];
-
-#endif /* __PERF_CPUMAP_H */
tools/perf/util/ctype.c deleted +0 -39
deleted file mode 100644
index 3507362..0000000
@@ -1,39 +0,0 @@
-/*
- * Sane locale-independent, ASCII ctype.
- *
- * No surprises, and works with signed and unsigned chars.
- */
-#include "cache.h"
-
-enum {
-	S = GIT_SPACE,
-	A = GIT_ALPHA,
-	D = GIT_DIGIT,
-	G = GIT_GLOB_SPECIAL,	/* *, ?, [, \\ */
-	R = GIT_REGEX_SPECIAL,	/* $, (, ), +, ., ^, {, | * */
-	P = GIT_PRINT_EXTRA,	/* printable - alpha - digit - glob - regex */
-
-	PS = GIT_SPACE | GIT_PRINT_EXTRA,
-};
-
-unsigned char sane_ctype[256] = {
-/*	0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F			    */
-
-	0, 0, 0, 0, 0, 0, 0, 0, 0, S, S, 0, 0, S, 0, 0,		/*   0.. 15 */
-	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,		/*  16.. 31 */
-	PS,P, P, P, R, P, P, P, R, R, G, R, P, P, R, P,		/*  32.. 47 */
-	D, D, D, D, D, D, D, D, D, D, P, P, P, P, P, G,		/*  48.. 63 */
-	P, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,		/*  64.. 79 */
-	A, A, A, A, A, A, A, A, A, A, A, G, G, P, R, P,		/*  80.. 95 */
-	P, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A,		/*  96..111 */
-	A, A, A, A, A, A, A, A, A, A, A, R, R, P, P, 0,		/* 112..127 */
-	/* Nothing in the 128.. range */
-};
-
-const char *graph_line =
-	"_____________________________________________________________________"
-	"_____________________________________________________________________";
-const char *graph_dotted_line =
-	"---------------------------------------------------------------------"
-	"---------------------------------------------------------------------"
-	"---------------------------------------------------------------------";
Signature · 1 line
1.7.1
#15 lore raw

Re: [RFC PATCH 7/9] perf: Export cpumap

Em Fri, Aug 06, 2010 at 04:25:11PM +0200, Borislav Petkov escreveu:

Quoted 6 lines

From: Borislav Petkov <[email protected]>

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

Is this independent of previous patches? I.e. to be applied to current perf/core?

- Arnaldo

#16 lore raw

Re: [RFC PATCH 7/9] perf: Export cpumap

From: Arnaldo Carvalho de Melo <[email protected]>
Date: Fri, Aug 06, 2010 at 10:39:12AM -0400

Quoted 10 lines

Em Fri, Aug 06, 2010 at 04:25:11PM +0200, Borislav Petkov escreveu:

Quoted 6 lines

From: Borislav Petkov <[email protected]>

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

Is this independent of previous patches? I.e. to be applied to current perf/core?

I'm afraid not since earlier patches in the series introduce the toplevel Makefile that glues all the different tools/lib/* parts together. However, I could extract the toplevel Makefile parts and cpumap.c and ctype.c if you really need it now - I've been doing this so often lately that I could do it with my eyes closed now :o).

Signature · 8 lines
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
#17 lore raw

Re: [RFC PATCH 7/9] perf: Export cpumap

Em Fri, Aug 06, 2010 at 04:49:39PM +0200, Borislav Petkov escreveu:

Quoted 9 lines

From: Arnaldo Carvalho de Melo <[email protected]>

Quoted 2 lines

Is this independent of previous patches? I.e. to be applied to current perf/core?

I'm afraid not since earlier patches in the series introduce the toplevel Makefile that glues all the different tools/lib/* parts together. However, I could extract the toplevel Makefile parts and cpumap.c and ctype.c if you really need it now - I've been doing this so often lately that I could do it with my eyes closed now :o).

:-)

We need to get back at merging that series, so some patch series installments, with say, 3 or 4 patches each, would be great.

- Arnaldo

#18 lore raw

Re: [RFC PATCH 7/9] perf: Export cpumap

From: Arnaldo Carvalho de Melo <[email protected]>
Date: Fri, Aug 06, 2010 at 12:14:13PM -0300

Quoted 10 lines
Quoted 5 lines

I'm afraid not since earlier patches in the series introduce the toplevel Makefile that glues all the different tools/lib/* parts together. However, I could extract the toplevel Makefile parts and cpumap.c and ctype.c if you really need it now - I've been doing this so often lately that I could do it with my eyes closed now :o).

:-)

We need to get back at merging that series, so some patch series installments, with say, 3 or 4 patches each, would be great.

Yeah, I just want to wait first until all the churn on the kernel side settles and we have agreed on the perf_event.c part which would also determine what needs exporting on the userspace side.

But if you need stuff exported from perf/util/ for other tools too and if you tell me which ones, I could cook up something real soon...

Signature · 8 lines
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
#19 lore raw

Re: [RFC PATCH 7/9] perf: Export cpumap

Em Fri, Aug 06, 2010 at 06:04:41PM +0200, Borislav Petkov escreveu:

Quoted 14 lines

From: Arnaldo Carvalho de Melo <[email protected]>
Date: Fri, Aug 06, 2010 at 12:14:13PM -0300

Quoted 10 lines
Quoted 5 lines

I'm afraid not since earlier patches in the series introduce the toplevel Makefile that glues all the different tools/lib/* parts together. However, I could extract the toplevel Makefile parts and cpumap.c and ctype.c if you really need it now - I've been doing this so often lately that I could do it with my eyes closed now :o).

:-)

We need to get back at merging that series, so some patch series installments, with say, 3 or 4 patches each, would be great.

Quoted 6 lines

Yeah, I just want to wait first until all the churn on the kernel side settles and we have agreed on the perf_event.c part which would also determine what needs exporting on the userspace side.

But if you need stuff exported from perf/util/ for other tools too and if you tell me which ones, I could cook up something real soon...

I'll try to do what I once said I would, that is to have a tools/samples/ (stuff exercising tools/ library interfaces) counterpart to samples/ (stuff exercising kernel interfaces).

I'll use what you have already posted that applies, tools/Makefile, trying to solve that -C isssue.

Will shoot for having this merged early next week to avoid breaking the promise once more 8-)

- Arnaldo

#20 lore raw

RFC PATCH 8/9 perf: Carve out mmap helpers for general use

In reply to Borislav Petkov

From: Borislav Petkov <[email protected]>

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

---
 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
tools/Makefile +5 -1
index d3b1447..691f78b 100644
@@ -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
tools/lib/perf/Makefile new file +35 -0
new file mode 100644
index 0000000..9942d52
@@ -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 -lm
+ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
+ALL_LDFLAGS = $(LDFLAGS)
+
+RM = rm -f
+
+$(LIBFILE): $(LIB_OBJS)
+	$(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(LIB_OBJS)
+
+$(LIB_OBJS): $(LIB_H)
+
+%.o: %.c
+	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
+%.s: %.c
+	$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
+%.o: %.S
+	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
+
+clean:
+	$(RM) $(LIB_OBJS) $(LIBFILE)
+
+.PHONY: clean
tools/lib/perf/mmap.c new file +95 -0

95 lines not on this page · raw message

tools/lib/perf/mmap.h new file +15 -0
new file mode 100644
index 0000000..b6622e5
@@ -0,0 +1,15 @@
+#ifndef __PERF_MMAP_H
+#define __PERF_MMAP_H
+
+struct mmap_data {
+	int			counter;
+	void			*base;
+	unsigned int		mask;
+	unsigned int		prev;
+};
+
+unsigned long mmap_read_head(struct mmap_data *md);
+unsigned long mmap_read_all(struct mmap_data *, int,
+			    void (*write_output)(void *, size_t));
+
+#endif /* __PERF_MMAP_H */
tools/perf/Makefile +1 -1
index 7171f27..6a7d019 100644
@@ -328,7 +328,7 @@ export PERL_PATH
 
 LIB_FILE=$(OUTPUT)libperf.a
 
-EXTRA_LIB_FILES=$(LIB_OUTPUT)libparsevent.a $(LIB_OUTPUT)lklib.a
+EXTRA_LIB_FILES=$(LIB_OUTPUT)libparsevent.a $(LIB_OUTPUT)lklib.a $(LIB_OUTPUT)lkperflib.a
 
 LIB_H += ../../include/linux/perf_event.h
 LIB_H += ../../include/linux/rbtree.h
tools/perf/builtin-record.c +9 -98

159 lines not on this page · raw message

tools/perf/builtin-top.c +6 -22
index 9813351..5fc6bd4 100644
@@ -24,11 +24,8 @@
 #include "util/session.h"
 #include "util/symbol.h"
 #include "util/thread.h"
-#include <lk/util.h>
-#include <linux/rbtree.h>
 #include "util/parse-options.h"
 #include "util/parse-events.h"
-#include <lk/cpumap.h>
 
 #include "util/debug.h"
 
@@ -52,6 +49,11 @@
 #include <sys/uio.h>
 #include <sys/mman.h>
 
+#include <lk/util.h>
+#include <lk/cpumap.h>
+#include <perf/mmap.h>
+
+#include <linux/rbtree.h>
 #include <linux/unistd.h>
 #include <linux/types.h>
 
@@ -1102,24 +1104,6 @@ static int event__process(event_t *event, struct perf_session *session)
 	return 0;
 }
 
-struct mmap_data {
-	int			counter;
-	void			*base;
-	int			mask;
-	unsigned int		prev;
-};
-
-static unsigned int mmap_read_head(struct mmap_data *md)
-{
-	struct perf_event_mmap_page *pc = md->base;
-	int head;
-
-	head = pc->data_head;
-	rmb();
-
-	return head;
-}
-
 static void perf_session__mmap_read_counter(struct perf_session *self,
 					    struct mmap_data *md)
 {
@@ -1137,7 +1121,7 @@ static void perf_session__mmap_read_counter(struct perf_session *self,
 	 * In either case, truncate and restart at head.
 	 */
 	diff = head - old;
-	if (diff > md->mask / 2 || diff < 0) {
+	if ((unsigned)diff > md->mask / 2 || diff < 0) {
 		fprintf(stderr, "WARNING: failed to keep up with mmap data.\n");
 
 		/*
Signature · 1 line
1.7.1
#21 lore raw

RFC PATCH 9/9 tools, ras: Add a RAS daemon

In reply to Borislav Petkov

From: Borislav Petkov <[email protected]>

---
 tools/Makefile     |    4 ++
 tools/ras/Makefile |   16 ++++++
 tools/ras/rasd.c   |  144 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 164 insertions(+), 0 deletions(-)
 create mode 100644 tools/ras/Makefile
 create mode 100644 tools/ras/rasd.c
tools/Makefile +4 -0
index 691f78b..360454c 100644
@@ -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
tools/ras/Makefile new file +16 -0
new file mode 100644
index 0000000..3aebe5a
@@ -0,0 +1,16 @@
+include ../scripts/Makefile.lib
+
+CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(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 $(RASLIBS)
+	$(QUIET_CC)$(CC) $(ALL_CFLAGS) -o $@ $^ $(RASLIBS)
+
+%.o: %.c
+	$(QUIET_CC)$(CC) $(ALL_CFLAGS) -c $<
+
+clean:
+	rm -rf *.o rasd
tools/ras/rasd.c new file +144 -0

144 lines not on this page · raw message

Signature · 1 line
1.7.1