Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85c66be1 authored by Borislav Petkov's avatar Borislav Petkov Committed by Arnaldo Carvalho de Melo
Browse files

perf tools: Introduce tools/lib/lk library



This introduces the tools/lib/lk library, that will gradually have the
routines that now are used in tools/perf/ and other tools and that can
be shared.

Start by carving out debugfs routines for general use.

Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1361374353-30385-5-git-send-email-bp@alien8.de


[ committer note: Add tools/lib/lk/ to perf's MANIFEST so that its tarballs continue to build ]
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 9687b89d
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -33,7 +33,13 @@ help:
cpupower: FORCE
	$(call descend,power/$@)

firewire lguest perf usb virtio vm: FORCE
firewire guest usb virtio vm: FORCE
	$(call descend,$@)

liblk: FORCE
	$(call descend,lib/lk)

perf: liblk FORCE
	$(call descend,$@)

selftests: FORCE
@@ -61,7 +67,13 @@ install: cpupower_install firewire_install lguest_install perf_install \
cpupower_clean:
	$(call descend,power/cpupower,clean)

firewire_clean lguest_clean perf_clean usb_clean virtio_clean vm_clean:
firewire_clean lguest_clean usb_clean virtio_clean vm_clean:
	$(call descend,$(@:_clean=),clean)

liblk_clean:
	$(call descend,lib/lk,clean)

perf_clean: liblk_clean
	$(call descend,$(@:_clean=),clean)

selftests_clean:

tools/lib/lk/Makefile

0 → 100644
+35 −0
Original line number Diff line number Diff line
include ../../scripts/Makefile.include

# guard against environment variables
LIB_H=
LIB_OBJS=

LIB_H += debugfs.h

LIB_OBJS += $(OUTPUT)debugfs.o

LIBFILE = liblk.a

CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
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 $(OUTPUT)$@ $(LIB_OBJS)

$(LIB_OBJS): $(LIB_H)

$(OUTPUT)%.o: %.c
	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<
$(OUTPUT)%.s: %.c
	$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $<
$(OUTPUT)%.o: %.S
	$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $<

clean:
	$(RM) $(LIB_OBJS) $(LIBFILE)

.PHONY: clean
+13 −8
Original line number Diff line number Diff line
#include "util.h"
#include "debugfs.h"
#include "cache.h"

#include <linux/kernel.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <sys/vfs.h>
#include <sys/mount.h>
#include <linux/magic.h>
#include <linux/kernel.h>

#include "debugfs.h"

char debugfs_mountpoint[PATH_MAX + 1] = "/sys/kernel/debug";
char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events";

static const char *debugfs_known_mountpoints[] = {
static const char * const debugfs_known_mountpoints[] = {
	"/sys/kernel/debug/",
	"/debug/",
	0,
@@ -19,7 +24,7 @@ static bool debugfs_found;
/* find the path to the mounted debugfs */
const char *debugfs_find_mountpoint(void)
{
	const char **ptr;
	const char * const *ptr;
	char type[100];
	FILE *fp;

+31 −0
Original line number Diff line number Diff line
#ifndef __DEBUGFS_H__
#define __DEBUGFS_H__
#ifndef __LK_DEBUGFS_H__
#define __LK_DEBUGFS_H__

#define _STR(x) #x
#define STR(x) _STR(x)

/*
 * On most systems <limits.h> would have given us this, but  not on some systems
 * (e.g. GNU/Hurd).
 */
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif

#ifndef DEBUGFS_MAGIC
#define DEBUGFS_MAGIC          0x64626720
#endif

#ifndef PERF_DEBUGFS_ENVIRONMENT
#define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"
#endif

const char *debugfs_find_mountpoint(void);
int debugfs_valid_mountpoint(const char *debugfs);
@@ -9,4 +28,4 @@ void debugfs_set_path(const char *mountpoint);
extern char debugfs_mountpoint[];
extern char tracing_events_path[];

#endif /* __DEBUGFS_H__ */
#endif /* __LK_DEBUGFS_H__ */
+1 −0
Original line number Diff line number Diff line
tools/perf
tools/scripts
tools/lib/traceevent
tools/lib/lk
include/linux/const.h
include/linux/perf_event.h
include/linux/rbtree.h
Loading