Re: [RFC PATCH v6 25/32] perf tools: Add 'bpf.' config section to perf default config
On Thu, Jun 11, 2015 at 04:09:36PM +0800, Wangnan (F) wrote: > On 2015/6/11 15:45, Namhyung Kim wrote: > >On Tue, Jun 09, 2015 at 04:43:19PM -0700, Alexei Starovoitov wrote: > >>On 6/8/15 10:50 PM, Wang Nan wrote: > >>>perf_bpf_config() is added to parse 'bpf' section in perf config file. > >>>Following is an example: > >>> > >>> [bpf] > >>>clang-path = /llvm/bin/x86_64-linux-clang" > >>>llc-path = /llvm/bin/x86_64-linux-llc" > >>>clang-opt = "-nostdinc -isystem /llvm/lib/clang/include > >>> -I/kernel/arch/x86/include ..." > >>>llc-opt = "" > >>a section to specify -I flags to compile prog.c is useful, > >>but users shouldn't be populating it manually for kernel headers. > >>How about adding a script that can figure out $(LINUXINCLUDE) > >>automatically ? > >Maybe a dummy question. For what reason it needs such headers? Is it > >possible to have a (part of?) copy of needed bits in the perf source? > > > >Thanks, > >Namhyung > > It is improtant for eBPF script that it should be able to extract > information > from kernel pointers. For example: to extract registers from 'struct > pt_regs' and > to extract fields from 'struct page *'. I believe this is an improtant > reason > why we decide to use C-like language instead of designing a DLS. Therefore, > when > compiling .c to .o, kernel source is mandatory. Since we don't want to limit > the > ability of data accessing of eBPF scripts, we have to give it ability to > access all > kernel headers. Understood, thank you for the explanation! Namhyung -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v6 25/32] perf tools: Add 'bpf.' config section to perf default config
On 2015/6/11 15:45, Namhyung Kim wrote: On Tue, Jun 09, 2015 at 04:43:19PM -0700, Alexei Starovoitov wrote: On 6/8/15 10:50 PM, Wang Nan wrote: perf_bpf_config() is added to parse 'bpf' section in perf config file. Following is an example: [bpf] clang-path = /llvm/bin/x86_64-linux-clang" llc-path = /llvm/bin/x86_64-linux-llc" clang-opt = "-nostdinc -isystem /llvm/lib/clang/include -I/kernel/arch/x86/include ..." llc-opt = "" a section to specify -I flags to compile prog.c is useful, but users shouldn't be populating it manually for kernel headers. How about adding a script that can figure out $(LINUXINCLUDE) automatically ? Maybe a dummy question. For what reason it needs such headers? Is it possible to have a (part of?) copy of needed bits in the perf source? Thanks, Namhyung It is improtant for eBPF script that it should be able to extract information from kernel pointers. For example: to extract registers from 'struct pt_regs' and to extract fields from 'struct page *'. I believe this is an improtant reason why we decide to use C-like language instead of designing a DLS. Therefore, when compiling .c to .o, kernel source is mandatory. Since we don't want to limit the ability of data accessing of eBPF scripts, we have to give it ability to access all kernel headers. Thank you for reviewing. You can even invoke such flag detector from perf via something like: f = open /tmpdir/Makefile fprintf(f, "obj-y := dummy.o\n"); fprintf(f, "$(obj)/%%.o: $(src)/%%.c\n"); fprintf(f, "\t@echo -n \"$(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS)\" %s\n", cachefile); snprintf(cmd, "make -s -C /lib/modules/%s/build M=%s dummy.o", uts_release, tmpdir); system(cmd); read flags from cachefile and cache it for the future. ... or as independent script that populates .perfconfig -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v6 25/32] perf tools: Add 'bpf.' config section to perf default config
On Tue, Jun 09, 2015 at 04:43:19PM -0700, Alexei Starovoitov wrote: > On 6/8/15 10:50 PM, Wang Nan wrote: > >perf_bpf_config() is added to parse 'bpf' section in perf config file. > >Following is an example: > > > > [bpf] > >clang-path = /llvm/bin/x86_64-linux-clang" > >llc-path = /llvm/bin/x86_64-linux-llc" > >clang-opt = "-nostdinc -isystem /llvm/lib/clang/include > > -I/kernel/arch/x86/include ..." > >llc-opt = "" > > a section to specify -I flags to compile prog.c is useful, > but users shouldn't be populating it manually for kernel headers. > How about adding a script that can figure out $(LINUXINCLUDE) > automatically ? Maybe a dummy question. For what reason it needs such headers? Is it possible to have a (part of?) copy of needed bits in the perf source? Thanks, Namhyung > You can even invoke such flag detector from perf via something like: > f = open /tmpdir/Makefile > fprintf(f, "obj-y := dummy.o\n"); > fprintf(f, "$(obj)/%%.o: $(src)/%%.c\n"); > fprintf(f, "\t@echo -n \"$(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS)\" > > %s\n", cachefile); > snprintf(cmd, "make -s -C /lib/modules/%s/build M=%s dummy.o", >uts_release, tmpdir); > system(cmd); > read flags from cachefile and cache it for the future. > ... > or as independent script that populates .perfconfig > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v6 25/32] perf tools: Add 'bpf.' config section to perf default config
On Thu, Jun 11, 2015 at 04:09:36PM +0800, Wangnan (F) wrote: On 2015/6/11 15:45, Namhyung Kim wrote: On Tue, Jun 09, 2015 at 04:43:19PM -0700, Alexei Starovoitov wrote: On 6/8/15 10:50 PM, Wang Nan wrote: perf_bpf_config() is added to parse 'bpf' section in perf config file. Following is an example: [bpf] clang-path = /llvm/bin/x86_64-linux-clang llc-path = /llvm/bin/x86_64-linux-llc clang-opt = -nostdinc -isystem /llvm/lib/clang/include -I/kernel/arch/x86/include ... llc-opt = a section to specify -I flags to compile prog.c is useful, but users shouldn't be populating it manually for kernel headers. How about adding a script that can figure out $(LINUXINCLUDE) automatically ? Maybe a dummy question. For what reason it needs such headers? Is it possible to have a (part of?) copy of needed bits in the perf source? Thanks, Namhyung It is improtant for eBPF script that it should be able to extract information from kernel pointers. For example: to extract registers from 'struct pt_regs' and to extract fields from 'struct page *'. I believe this is an improtant reason why we decide to use C-like language instead of designing a DLS. Therefore, when compiling .c to .o, kernel source is mandatory. Since we don't want to limit the ability of data accessing of eBPF scripts, we have to give it ability to access all kernel headers. Understood, thank you for the explanation! Namhyung -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v6 25/32] perf tools: Add 'bpf.' config section to perf default config
On Tue, Jun 09, 2015 at 04:43:19PM -0700, Alexei Starovoitov wrote: On 6/8/15 10:50 PM, Wang Nan wrote: perf_bpf_config() is added to parse 'bpf' section in perf config file. Following is an example: [bpf] clang-path = /llvm/bin/x86_64-linux-clang llc-path = /llvm/bin/x86_64-linux-llc clang-opt = -nostdinc -isystem /llvm/lib/clang/include -I/kernel/arch/x86/include ... llc-opt = a section to specify -I flags to compile prog.c is useful, but users shouldn't be populating it manually for kernel headers. How about adding a script that can figure out $(LINUXINCLUDE) automatically ? Maybe a dummy question. For what reason it needs such headers? Is it possible to have a (part of?) copy of needed bits in the perf source? Thanks, Namhyung You can even invoke such flag detector from perf via something like: f = open /tmpdir/Makefile fprintf(f, obj-y := dummy.o\n); fprintf(f, $(obj)/%%.o: $(src)/%%.c\n); fprintf(f, \t@echo -n \$(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS)\ %s\n, cachefile); snprintf(cmd, make -s -C /lib/modules/%s/build M=%s dummy.o, uts_release, tmpdir); system(cmd); read flags from cachefile and cache it for the future. ... or as independent script that populates .perfconfig -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v6 25/32] perf tools: Add 'bpf.' config section to perf default config
On 2015/6/11 15:45, Namhyung Kim wrote: On Tue, Jun 09, 2015 at 04:43:19PM -0700, Alexei Starovoitov wrote: On 6/8/15 10:50 PM, Wang Nan wrote: perf_bpf_config() is added to parse 'bpf' section in perf config file. Following is an example: [bpf] clang-path = /llvm/bin/x86_64-linux-clang llc-path = /llvm/bin/x86_64-linux-llc clang-opt = -nostdinc -isystem /llvm/lib/clang/include -I/kernel/arch/x86/include ... llc-opt = a section to specify -I flags to compile prog.c is useful, but users shouldn't be populating it manually for kernel headers. How about adding a script that can figure out $(LINUXINCLUDE) automatically ? Maybe a dummy question. For what reason it needs such headers? Is it possible to have a (part of?) copy of needed bits in the perf source? Thanks, Namhyung It is improtant for eBPF script that it should be able to extract information from kernel pointers. For example: to extract registers from 'struct pt_regs' and to extract fields from 'struct page *'. I believe this is an improtant reason why we decide to use C-like language instead of designing a DLS. Therefore, when compiling .c to .o, kernel source is mandatory. Since we don't want to limit the ability of data accessing of eBPF scripts, we have to give it ability to access all kernel headers. Thank you for reviewing. You can even invoke such flag detector from perf via something like: f = open /tmpdir/Makefile fprintf(f, obj-y := dummy.o\n); fprintf(f, $(obj)/%%.o: $(src)/%%.c\n); fprintf(f, \t@echo -n \$(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS)\ %s\n, cachefile); snprintf(cmd, make -s -C /lib/modules/%s/build M=%s dummy.o, uts_release, tmpdir); system(cmd); read flags from cachefile and cache it for the future. ... or as independent script that populates .perfconfig -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v6 25/32] perf tools: Add 'bpf.' config section to perf default config
On 6/9/15 7:23 PM, Wangnan (F) wrote: I'll embed this script in my next version. fine, let's use the script for now and inform the user that they would need to manually copy the flags into .perfconfig -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v6 25/32] perf tools: Add 'bpf.' config section to perf default config
On 2015/6/10 9:09, Alexei Starovoitov wrote: On 6/9/15 5:47 PM, Wangnan (F) wrote: On 2015/6/10 7:43, Alexei Starovoitov wrote: On 6/8/15 10:50 PM, Wang Nan wrote: perf_bpf_config() is added to parse 'bpf' section in perf config file. Following is an example: [bpf] clang-path = /llvm/bin/x86_64-linux-clang" llc-path = /llvm/bin/x86_64-linux-llc" clang-opt = "-nostdinc -isystem /llvm/lib/clang/include -I/kernel/arch/x86/include ..." llc-opt = "" a section to specify -I flags to compile prog.c is useful, but users shouldn't be populating it manually for kernel headers. How about adding a script that can figure out $(LINUXINCLUDE) automatically ? You can even invoke such flag detector from perf via something like: f = open /tmpdir/Makefile fprintf(f, "obj-y := dummy.o\n"); fprintf(f, "$(obj)/%%.o: $(src)/%%.c\n"); fprintf(f, "\t@echo -n \"$(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS)\" > %s\n", cachefile); snprintf(cmd, "make -s -C /lib/modules/%s/build M=%s dummy.o", uts_release, tmpdir); system(cmd); read flags from cachefile and cache it for the future. ... or as independent script that populates .perfconfig That's cool, but could I implement it later? Introducing such stuffs I think --clang-opts shouldn't be introduced without automatic flag finder. Ease of use is important. What about automatic finder failed? It is possible that user environment doesn't have kbuild directory installed, should we make it another deadend? Then these 'ease of use' design is useless for me because in embedded area usecases are always rare. I think we can hide --clang-opt from cmdline, make it reside in .perfconfig only, and pop some messages on it when failure. Most of the time users need to config only once. Still not very hard, right? also introduces a lot of trouble tasks: 1. Dependency on make and kernel build. We should search make and kbuild dir dynamically and also gives users the right to specify them by theirselves. A lot of configuration options should be appended: --make-path=/path/to/make --kbuild-dir=kernel/build/dir in cmdline and [kbuild] make_path = /path/to/make kbuild_dir = /path/to/kbuild in .perfconfig. they're not mandatory. If 'make' is not in a PATH, it's dead end. kernel build is very likely installed in /lib/modules/ 2. Selection of architectures. Although currently we want it to work only when we dynamically compile a script, I think finally we should consider cross compiling bpf objects. Then cmdline generation becomes complex. Also, --arch and [kbuild.arch] should also be introduced. that's a rare use case. This one can be added later. 3. Kernel dependency. Consider if kernel decides to change its interface... change what interface? 'make M=' ? sure. then lots of scripts will be broken. 'make M=' is unlikely to be changed. However it is possible for kernel to append more variable for specifying include, or devide $(NOSTDINC_FLAGS) $(LINUXINCLUDE) and $(EXTRA_CFLAGS) into smaller pieces. I'm not quite sure whether those make variables are part of kbuild interface. I think currently we can pop some messages to let user know how to get include dirs manually, let further patches to do it for them automatically. P.S. Have you tested your Makefile? It doesn't work for me: works as a charm: $ cat /home/ast/ff/Makefile obj-y := dummy.o $(obj)/%.o: $(src)/%.c @echo -n "$(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS)" > /tmp/xxx $ make -s -C /w/net-next/bld_x64 M=/home/ast/ff dummy.o $ cat /tmp/xxx -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.7/include -I../arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated -I../include -Iinclude -I../arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I../include/uapi -Iinclude/generated/uapi -include ../include/linux/kconfig.h Finally I made it work. dummy.c must exist on current directory. What we are talking about seems not very suit to be implemented using C. It should be implemented using a shell script: #!/usr/bin/env sh TMPDIR=`mktemp -d` cat << EOF > $TMPDIR/Makefile obj-y := dummy.o \$(obj)/%.o: \$(src)/%.c @echo -n "\$(NOSTDINC_FLAGS) \$(LINUXINCLUDE) \$(EXTRA_CFLAGS)" > $TMPDIR/cflags EOF touch $TMPDIR/dummy.c DEFAULT_KBUILD_DIR=/lib/modules/`uname -r`/build if ! test -d "$KBUILD_DIR" then KBUILD_DIR=$DEFAULT_KBUILD_DIR fi make -s -C $KBUILD_DIR M=$TMPDIR $OTHER_OPTS dummy.o 2>/dev/null cat $TMPDIR/cflags 2>/dev/null RET=$? rm -rf $TMPDIR exit $RET In this script, we can inject KBUILD_DIR and OTHER_OPTS to select another kbuild directory and "ARCH=" option. I'll embed this script in my next version. Thaknk you. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v6 25/32] perf tools: Add 'bpf.' config section to perf default config
On 6/9/15 5:47 PM, Wangnan (F) wrote: On 2015/6/10 7:43, Alexei Starovoitov wrote: On 6/8/15 10:50 PM, Wang Nan wrote: perf_bpf_config() is added to parse 'bpf' section in perf config file. Following is an example: [bpf] clang-path = /llvm/bin/x86_64-linux-clang" llc-path = /llvm/bin/x86_64-linux-llc" clang-opt = "-nostdinc -isystem /llvm/lib/clang/include -I/kernel/arch/x86/include ..." llc-opt = "" a section to specify -I flags to compile prog.c is useful, but users shouldn't be populating it manually for kernel headers. How about adding a script that can figure out $(LINUXINCLUDE) automatically ? You can even invoke such flag detector from perf via something like: f = open /tmpdir/Makefile fprintf(f, "obj-y := dummy.o\n"); fprintf(f, "$(obj)/%%.o: $(src)/%%.c\n"); fprintf(f, "\t@echo -n \"$(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS)\" > %s\n", cachefile); snprintf(cmd, "make -s -C /lib/modules/%s/build M=%s dummy.o", uts_release, tmpdir); system(cmd); read flags from cachefile and cache it for the future. ... or as independent script that populates .perfconfig That's cool, but could I implement it later? Introducing such stuffs I think --clang-opts shouldn't be introduced without automatic flag finder. Ease of use is important. also introduces a lot of trouble tasks: 1. Dependency on make and kernel build. We should search make and kbuild dir dynamically and also gives users the right to specify them by theirselves. A lot of configuration options should be appended: --make-path=/path/to/make --kbuild-dir=kernel/build/dir in cmdline and [kbuild] make_path = /path/to/make kbuild_dir = /path/to/kbuild in .perfconfig. they're not mandatory. If 'make' is not in a PATH, it's dead end. kernel build is very likely installed in /lib/modules/ 2. Selection of architectures. Although currently we want it to work only when we dynamically compile a script, I think finally we should consider cross compiling bpf objects. Then cmdline generation becomes complex. Also, --arch and [kbuild.arch] should also be introduced. that's a rare use case. This one can be added later. 3. Kernel dependency. Consider if kernel decides to change its interface... change what interface? 'make M=' ? sure. then lots of scripts will be broken. I think currently we can pop some messages to let user know how to get include dirs manually, let further patches to do it for them automatically. P.S. Have you tested your Makefile? It doesn't work for me: works as a charm: $ cat /home/ast/ff/Makefile obj-y := dummy.o $(obj)/%.o: $(src)/%.c @echo -n "$(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS)" > /tmp/xxx $ make -s -C /w/net-next/bld_x64 M=/home/ast/ff dummy.o $ cat /tmp/xxx -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.7/include -I../arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated -I../include -Iinclude -I../arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I../include/uapi -Iinclude/generated/uapi -include ../include/linux/kconfig.h -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v6 25/32] perf tools: Add 'bpf.' config section to perf default config
On 2015/6/10 7:43, Alexei Starovoitov wrote: On 6/8/15 10:50 PM, Wang Nan wrote: perf_bpf_config() is added to parse 'bpf' section in perf config file. Following is an example: [bpf] clang-path = /llvm/bin/x86_64-linux-clang" llc-path = /llvm/bin/x86_64-linux-llc" clang-opt = "-nostdinc -isystem /llvm/lib/clang/include -I/kernel/arch/x86/include ..." llc-opt = "" a section to specify -I flags to compile prog.c is useful, but users shouldn't be populating it manually for kernel headers. How about adding a script that can figure out $(LINUXINCLUDE) automatically ? You can even invoke such flag detector from perf via something like: f = open /tmpdir/Makefile fprintf(f, "obj-y := dummy.o\n"); fprintf(f, "$(obj)/%%.o: $(src)/%%.c\n"); fprintf(f, "\t@echo -n \"$(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS)\" > %s\n", cachefile); snprintf(cmd, "make -s -C /lib/modules/%s/build M=%s dummy.o", uts_release, tmpdir); system(cmd); read flags from cachefile and cache it for the future. ... or as independent script that populates .perfconfig That's cool, but could I implement it later? Introducing such stuffs also introduces a lot of trouble tasks: 1. Dependency on make and kernel build. We should search make and kbuild dir dynamically and also gives users the right to specify them by theirselves. A lot of configuration options should be appended: --make-path=/path/to/make --kbuild-dir=kernel/build/dir in cmdline and [kbuild] make_path = /path/to/make kbuild_dir = /path/to/kbuild in .perfconfig. 2. Selection of architectures. Although currently we want it to work only when we dynamically compile a script, I think finally we should consider cross compiling bpf objects. Then cmdline generation becomes complex. Also, --arch and [kbuild.arch] should also be introduced. 3. Kernel dependency. Consider if kernel decides to change its interface... I think currently we can pop some messages to let user know how to get include dirs manually, let further patches to do it for them automatically. P.S. Have you tested your Makefile? It doesn't work for me: # cat ./Makefile obj-y := dummy.o $(obj)/%.o: $(src)/%.c @echo -n "$(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS)" > # make -s -C kernel/build/dir M=`pwd` dummy.o make[2]: *** No rule to make target `dummy.o'. Stop. make[1]: *** [sub-make] Error 2 make: *** [__sub-make] Error 2 Thank you. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v6 25/32] perf tools: Add 'bpf.' config section to perf default config
On 6/8/15 10:50 PM, Wang Nan wrote: perf_bpf_config() is added to parse 'bpf' section in perf config file. Following is an example: [bpf] clang-path = /llvm/bin/x86_64-linux-clang" llc-path = /llvm/bin/x86_64-linux-llc" clang-opt = "-nostdinc -isystem /llvm/lib/clang/include -I/kernel/arch/x86/include ..." llc-opt = "" a section to specify -I flags to compile prog.c is useful, but users shouldn't be populating it manually for kernel headers. How about adding a script that can figure out $(LINUXINCLUDE) automatically ? You can even invoke such flag detector from perf via something like: f = open /tmpdir/Makefile fprintf(f, "obj-y := dummy.o\n"); fprintf(f, "$(obj)/%%.o: $(src)/%%.c\n"); fprintf(f, "\t@echo -n \"$(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS)\" > %s\n", cachefile); snprintf(cmd, "make -s -C /lib/modules/%s/build M=%s dummy.o", uts_release, tmpdir); system(cmd); read flags from cachefile and cache it for the future. ... or as independent script that populates .perfconfig -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v6 25/32] perf tools: Add 'bpf.' config section to perf default config
On 6/8/15 10:50 PM, Wang Nan wrote: perf_bpf_config() is added to parse 'bpf' section in perf config file. Following is an example: [bpf] clang-path = /llvm/bin/x86_64-linux-clang llc-path = /llvm/bin/x86_64-linux-llc clang-opt = -nostdinc -isystem /llvm/lib/clang/include -I/kernel/arch/x86/include ... llc-opt = a section to specify -I flags to compile prog.c is useful, but users shouldn't be populating it manually for kernel headers. How about adding a script that can figure out $(LINUXINCLUDE) automatically ? You can even invoke such flag detector from perf via something like: f = open /tmpdir/Makefile fprintf(f, obj-y := dummy.o\n); fprintf(f, $(obj)/%%.o: $(src)/%%.c\n); fprintf(f, \t@echo -n \$(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS)\ %s\n, cachefile); snprintf(cmd, make -s -C /lib/modules/%s/build M=%s dummy.o, uts_release, tmpdir); system(cmd); read flags from cachefile and cache it for the future. ... or as independent script that populates .perfconfig -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v6 25/32] perf tools: Add 'bpf.' config section to perf default config
On 6/9/15 5:47 PM, Wangnan (F) wrote: On 2015/6/10 7:43, Alexei Starovoitov wrote: On 6/8/15 10:50 PM, Wang Nan wrote: perf_bpf_config() is added to parse 'bpf' section in perf config file. Following is an example: [bpf] clang-path = /llvm/bin/x86_64-linux-clang llc-path = /llvm/bin/x86_64-linux-llc clang-opt = -nostdinc -isystem /llvm/lib/clang/include -I/kernel/arch/x86/include ... llc-opt = a section to specify -I flags to compile prog.c is useful, but users shouldn't be populating it manually for kernel headers. How about adding a script that can figure out $(LINUXINCLUDE) automatically ? You can even invoke such flag detector from perf via something like: f = open /tmpdir/Makefile fprintf(f, obj-y := dummy.o\n); fprintf(f, $(obj)/%%.o: $(src)/%%.c\n); fprintf(f, \t@echo -n \$(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS)\ %s\n, cachefile); snprintf(cmd, make -s -C /lib/modules/%s/build M=%s dummy.o, uts_release, tmpdir); system(cmd); read flags from cachefile and cache it for the future. ... or as independent script that populates .perfconfig That's cool, but could I implement it later? Introducing such stuffs I think --clang-opts shouldn't be introduced without automatic flag finder. Ease of use is important. also introduces a lot of trouble tasks: 1. Dependency on make and kernel build. We should search make and kbuild dir dynamically and also gives users the right to specify them by theirselves. A lot of configuration options should be appended: --make-path=/path/to/make --kbuild-dir=kernel/build/dir in cmdline and [kbuild] make_path = /path/to/make kbuild_dir = /path/to/kbuild in .perfconfig. they're not mandatory. If 'make' is not in a PATH, it's dead end. kernel build is very likely installed in /lib/modules/ 2. Selection of architectures. Although currently we want it to work only when we dynamically compile a script, I think finally we should consider cross compiling bpf objects. Then cmdline generation becomes complex. Also, --arch and [kbuild.arch] should also be introduced. that's a rare use case. This one can be added later. 3. Kernel dependency. Consider if kernel decides to change its interface... change what interface? 'make M=' ? sure. then lots of scripts will be broken. I think currently we can pop some messages to let user know how to get include dirs manually, let further patches to do it for them automatically. P.S. Have you tested your Makefile? It doesn't work for me: works as a charm: $ cat /home/ast/ff/Makefile obj-y := dummy.o $(obj)/%.o: $(src)/%.c @echo -n $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) /tmp/xxx $ make -s -C /w/net-next/bld_x64 M=/home/ast/ff dummy.o $ cat /tmp/xxx -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.7/include -I../arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated -I../include -Iinclude -I../arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I../include/uapi -Iinclude/generated/uapi -include ../include/linux/kconfig.h -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v6 25/32] perf tools: Add 'bpf.' config section to perf default config
On 2015/6/10 7:43, Alexei Starovoitov wrote: On 6/8/15 10:50 PM, Wang Nan wrote: perf_bpf_config() is added to parse 'bpf' section in perf config file. Following is an example: [bpf] clang-path = /llvm/bin/x86_64-linux-clang llc-path = /llvm/bin/x86_64-linux-llc clang-opt = -nostdinc -isystem /llvm/lib/clang/include -I/kernel/arch/x86/include ... llc-opt = a section to specify -I flags to compile prog.c is useful, but users shouldn't be populating it manually for kernel headers. How about adding a script that can figure out $(LINUXINCLUDE) automatically ? You can even invoke such flag detector from perf via something like: f = open /tmpdir/Makefile fprintf(f, obj-y := dummy.o\n); fprintf(f, $(obj)/%%.o: $(src)/%%.c\n); fprintf(f, \t@echo -n \$(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS)\ %s\n, cachefile); snprintf(cmd, make -s -C /lib/modules/%s/build M=%s dummy.o, uts_release, tmpdir); system(cmd); read flags from cachefile and cache it for the future. ... or as independent script that populates .perfconfig That's cool, but could I implement it later? Introducing such stuffs also introduces a lot of trouble tasks: 1. Dependency on make and kernel build. We should search make and kbuild dir dynamically and also gives users the right to specify them by theirselves. A lot of configuration options should be appended: --make-path=/path/to/make --kbuild-dir=kernel/build/dir in cmdline and [kbuild] make_path = /path/to/make kbuild_dir = /path/to/kbuild in .perfconfig. 2. Selection of architectures. Although currently we want it to work only when we dynamically compile a script, I think finally we should consider cross compiling bpf objects. Then cmdline generation becomes complex. Also, --arch and [kbuild.arch] should also be introduced. 3. Kernel dependency. Consider if kernel decides to change its interface... I think currently we can pop some messages to let user know how to get include dirs manually, let further patches to do it for them automatically. P.S. Have you tested your Makefile? It doesn't work for me: # cat ./Makefile obj-y := dummy.o $(obj)/%.o: $(src)/%.c @echo -n $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) # make -s -C kernel/build/dir M=`pwd` dummy.o make[2]: *** No rule to make target `dummy.o'. Stop. make[1]: *** [sub-make] Error 2 make: *** [__sub-make] Error 2 Thank you. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v6 25/32] perf tools: Add 'bpf.' config section to perf default config
On 2015/6/10 9:09, Alexei Starovoitov wrote: On 6/9/15 5:47 PM, Wangnan (F) wrote: On 2015/6/10 7:43, Alexei Starovoitov wrote: On 6/8/15 10:50 PM, Wang Nan wrote: perf_bpf_config() is added to parse 'bpf' section in perf config file. Following is an example: [bpf] clang-path = /llvm/bin/x86_64-linux-clang llc-path = /llvm/bin/x86_64-linux-llc clang-opt = -nostdinc -isystem /llvm/lib/clang/include -I/kernel/arch/x86/include ... llc-opt = a section to specify -I flags to compile prog.c is useful, but users shouldn't be populating it manually for kernel headers. How about adding a script that can figure out $(LINUXINCLUDE) automatically ? You can even invoke such flag detector from perf via something like: f = open /tmpdir/Makefile fprintf(f, obj-y := dummy.o\n); fprintf(f, $(obj)/%%.o: $(src)/%%.c\n); fprintf(f, \t@echo -n \$(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS)\ %s\n, cachefile); snprintf(cmd, make -s -C /lib/modules/%s/build M=%s dummy.o, uts_release, tmpdir); system(cmd); read flags from cachefile and cache it for the future. ... or as independent script that populates .perfconfig That's cool, but could I implement it later? Introducing such stuffs I think --clang-opts shouldn't be introduced without automatic flag finder. Ease of use is important. What about automatic finder failed? It is possible that user environment doesn't have kbuild directory installed, should we make it another deadend? Then these 'ease of use' design is useless for me because in embedded area usecases are always rare. I think we can hide --clang-opt from cmdline, make it reside in .perfconfig only, and pop some messages on it when failure. Most of the time users need to config only once. Still not very hard, right? also introduces a lot of trouble tasks: 1. Dependency on make and kernel build. We should search make and kbuild dir dynamically and also gives users the right to specify them by theirselves. A lot of configuration options should be appended: --make-path=/path/to/make --kbuild-dir=kernel/build/dir in cmdline and [kbuild] make_path = /path/to/make kbuild_dir = /path/to/kbuild in .perfconfig. they're not mandatory. If 'make' is not in a PATH, it's dead end. kernel build is very likely installed in /lib/modules/ 2. Selection of architectures. Although currently we want it to work only when we dynamically compile a script, I think finally we should consider cross compiling bpf objects. Then cmdline generation becomes complex. Also, --arch and [kbuild.arch] should also be introduced. that's a rare use case. This one can be added later. 3. Kernel dependency. Consider if kernel decides to change its interface... change what interface? 'make M=' ? sure. then lots of scripts will be broken. 'make M=' is unlikely to be changed. However it is possible for kernel to append more variable for specifying include, or devide $(NOSTDINC_FLAGS) $(LINUXINCLUDE) and $(EXTRA_CFLAGS) into smaller pieces. I'm not quite sure whether those make variables are part of kbuild interface. I think currently we can pop some messages to let user know how to get include dirs manually, let further patches to do it for them automatically. P.S. Have you tested your Makefile? It doesn't work for me: works as a charm: $ cat /home/ast/ff/Makefile obj-y := dummy.o $(obj)/%.o: $(src)/%.c @echo -n $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) /tmp/xxx $ make -s -C /w/net-next/bld_x64 M=/home/ast/ff dummy.o $ cat /tmp/xxx -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.7/include -I../arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated -I../include -Iinclude -I../arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I../include/uapi -Iinclude/generated/uapi -include ../include/linux/kconfig.h Finally I made it work. dummy.c must exist on current directory. What we are talking about seems not very suit to be implemented using C. It should be implemented using a shell script: #!/usr/bin/env sh TMPDIR=`mktemp -d` cat EOF $TMPDIR/Makefile obj-y := dummy.o \$(obj)/%.o: \$(src)/%.c @echo -n \$(NOSTDINC_FLAGS) \$(LINUXINCLUDE) \$(EXTRA_CFLAGS) $TMPDIR/cflags EOF touch $TMPDIR/dummy.c DEFAULT_KBUILD_DIR=/lib/modules/`uname -r`/build if ! test -d $KBUILD_DIR then KBUILD_DIR=$DEFAULT_KBUILD_DIR fi make -s -C $KBUILD_DIR M=$TMPDIR $OTHER_OPTS dummy.o 2/dev/null cat $TMPDIR/cflags 2/dev/null RET=$? rm -rf $TMPDIR exit $RET In this script, we can inject KBUILD_DIR and OTHER_OPTS to select another kbuild directory and ARCH= option. I'll embed this script in my next version. Thaknk you. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC PATCH v6 25/32] perf tools: Add 'bpf.' config section to perf default config
On 6/9/15 7:23 PM, Wangnan (F) wrote: I'll embed this script in my next version. fine, let's use the script for now and inform the user that they would need to manually copy the flags into .perfconfig -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/