Patchwork [2/3] Add Perf tools support

login
register
mail settings
Submitter Kaiwan Billimoria
Date Jan. 3, 2013, 7:50 a.m.
Message ID <CAPDLWs-otw90dvsw7oVra=-+oNJZ0-SeiXE1CoXh1WUxNhq2vQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/209191/
State Superseded
Commit 209760
Headers show

Comments

Kaiwan Billimoria - Jan. 3, 2013, 7:50 a.m.
Signed-off-by: Kaiwan Billimoria <kaiwan.billimoria@gmail.com>
---
 linux/linux.mk |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

 LINUX_INSTALL_IMAGES = YES
Thomas Petazzoni - Jan. 3, 2013, 10:23 a.m.
Dear Kaiwan Billimoria,

On Thu, 3 Jan 2013 13:20:39 +0530, Kaiwan Billimoria wrote:

> + # FIXME: Where should we place the perf kernel patch? Online?
> + # Temporarily, at least, it's under linux/
> + BR2_LINUX_KERNEL_PATCH += "$(HOST_DIR)/../../linux/perf.patch"

No, we don't modify BR2 variables.

> +all:

Arggh, this is *horrible*. Why do you believe you are allowed to
overload the "all" target?

> +	$(info Building Perf...)
> +	$(TARGET_MAKE_ENV) $(MAKE) ARCH=$(ARCH)
> CROSS_COMPILE=$(TARGET_CROSS) NO_LIBELF=1 -C $(LINUX_DIR)/tools/perf

This should be part of LINUX_BUILD_CMDS

> +	# Perf: Copy the perf binary executable to the target rootfs
> +	cp -f $(LINUX_DIR)/tools/perf/perf $(TARGET_DIR)/usr/sbin

This should be part of LINUX_INSTALL_TARGET_CMDS

And doing that will help you solve the problem you mentioned in your
cover letter ("the 'perf' binary executable is being built after the
root filesystem is tar-red").

That said, I am not sure we want this thing in linux/linux.mk. Maybe
I'd prefer a package/perf/perf.mk, which depends on BR2_LINUX_KERNEL
and re-uses the source code extracted in $(LINUX_DIR).

Best regards,

Thomas
Kaiwan Billimoria - Jan. 3, 2013, 12:54 p.m.
Dear Thomas Petazzoni,

Excuse my silly stuff & poor knowledge of the 'make'/build system !  :-p
Pl see more qs below..

>> + # FIXME: Where should we place the perf kernel patch? Online?
>> + # Temporarily, at least, it's under linux/
>> + BR2_LINUX_KERNEL_PATCH += "$(HOST_DIR)/../../linux/perf.patch"
>
> No, we don't modify BR2 variables.

So, how exactly do we do this then?

>> +all:
>
> Arggh, this is *horrible*. Why do you believe you are allowed to
> overload the "all" target?

Right. Forgive my basic qs, but what's the right approach?

>
> That said, I am not sure we want this thing in linux/linux.mk. Maybe
> I'd prefer a package/perf/perf.mk, which depends on BR2_LINUX_KERNEL
> and re-uses the source code extracted in $(LINUX_DIR).

Ok, will try working on this approach as well.
Not free now for a bit, will come back to this soon & keep you posted..

Thanks again for all valuable inputs..
Best,
Kaiwan.

>
> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, Free Electrons
> Kernel, drivers, real-time and embedded Linux
> development, consulting, training and support.
> http://free-electrons.com

Patch

diff --git a/linux/linux.mk b/linux/linux.mk
index e852f62..056a745 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -31,6 +31,27 @@  LINUX_SITE := $(LINUX_SITE)testing/
 endif # -rc
 endif

+#--- Perf: validate: perf minimally requires kernel ver >= 2.6.31
+ifeq ($(BR2_LINUX_KERNEL_USERMODE_TOOLS_PERF), y)
+ ifeq ($(findstring x2.6.,x$(LINUX_VERSION)),x2.6.)
+  LINUXVER_SPCS = $(subst ., ,$(LINUX_VERSION))
+  REL = $(word 3, $(LINUXVER_SPCS))
+  res = $(shell [ ${REL} -lt 31 ] && echo n || echo y )
+  ifeq ($(res), n)
+   $(error Perf minimally requires a kernel ver >= 2.6.31 ! Aborting...)
+  endif
+ endif
+ # FIXME: Where should we place the perf kernel patch? Online?
+ # Temporarily, at least, it's under linux/
+ BR2_LINUX_KERNEL_PATCH += "$(HOST_DIR)/../../linux/perf.patch"
+
+all:
+	$(info Building Perf...)
+	$(TARGET_MAKE_ENV) $(MAKE) ARCH=$(ARCH)
CROSS_COMPILE=$(TARGET_CROSS) NO_LIBELF=1 -C $(LINUX_DIR)/tools/perf
+	# Perf: Copy the perf binary executable to the target rootfs
+	cp -f $(LINUX_DIR)/tools/perf/perf $(TARGET_DIR)/usr/sbin
+endif
+
 LINUX_PATCHES = $(call qstrip,$(BR2_LINUX_KERNEL_PATCH))