* Re: [PATCH 05/21] perf: rewire generic library stuff, p1 [not found] ` <20100701161054.GF8902@ghostprotocols.net> @ 2010-07-01 16:17 ` Borislav Petkov 2010-07-01 17:14 ` Arnaldo Carvalho de Melo 0 siblings, 1 reply; 8+ messages in thread From: Borislav Petkov @ 2010-07-01 16:17 UTC (permalink / raw) To: Arnaldo Carvalho de Melo Cc: Steven Rostedt, Peter Zijlstra, Ingo Molnar, Frederic Weisbecker, LKML From: Arnaldo Carvalho de Melo <acme@infradead.org> Date: Thu, Jul 01, 2010 at 12:10:54PM -0400 Hi Arnaldo, > Em Thu, Jul 01, 2010 at 12:47:37PM -0300, Arnaldo Carvalho de Melo escreveu: > > Em Thu, Jul 01, 2010 at 03:49:19PM +0200, Borislav Petkov escreveu: > > > From: Borislav Petkov <borislav.petkov@amd.com> > > > > > > Carve out generic library stuff into tools/lib/lk/ and rewire it with > > > 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. > > > > Testing this now, thanks, > > Needs the patch below for "make O=~/build/perf tools" to continue > working. Needs some more polishing so as not to break the non O= case. > > After lunch will investigate why my usual way to build the tools isn't working > anymore, some missing -I probably: > > [acme@emilia linux-2.6-tip]$ make O=~/git/build/perf -C tools/perf install > make: Entering directory `/home/acme/git/linux-2.6-tip/tools/perf' > CC /home/acme/git/build/perf/builtin-record.o > builtin-record.c:24:23: error: lk/cpumap.h: No such file or directory > cc1: warnings being treated as errors > builtin-record.c: In function ‘__cmd_record’: > builtin-record.c:622: error: implicit declaration of function ‘read_cpu_map’ > builtin-record.c:632: error: ‘cpumap’ undeclared (first use in this function) > builtin-record.c:632: error: (Each undeclared identifier is reported only once > builtin-record.c:632: error: for each function it appears in.) > make: *** [/home/acme/git/build/perf/builtin-record.o] Error 1 > make: Leaving directory `/home/acme/git/linux-2.6-tip/tools/perf' > [acme@emilia linux-2.6-tip]$ > > diff --git a/tools/lib/Makefile b/tools/lib/Makefile > index 48f8e21..814673e 100644 > --- a/tools/lib/Makefile > +++ b/tools/lib/Makefile > @@ -5,6 +5,9 @@ LIB_H = > LIB_OBJS = > > LIB_H += lk/cpumap.h > +OUTPUT := $(OUTPUT)/lib/ > + > +$(shell sh -c 'mkdir -p $(OUTPUT)/lk' 2> /dev/null) > > LIB_OBJS += $(OUTPUT)lk/bitmap.o > LIB_OBJS += $(OUTPUT)lk/cpumap.o I'll fix that up, thanks for testing. -- 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 05/21] perf: rewire generic library stuff, p1 2010-07-01 16:17 ` [PATCH 05/21] perf: rewire generic library stuff, p1 Borislav Petkov @ 2010-07-01 17:14 ` Arnaldo Carvalho de Melo 2010-07-01 20:14 ` Borislav Petkov 0 siblings, 1 reply; 8+ messages in thread From: Arnaldo Carvalho de Melo @ 2010-07-01 17:14 UTC (permalink / raw) To: Borislav Petkov Cc: Steven Rostedt, Peter Zijlstra, Ingo Molnar, Frederic Weisbecker, LKML Em Thu, Jul 01, 2010 at 06:17:38PM +0200, Borislav Petkov escreveu: > From: Arnaldo Carvalho de Melo <acme@infradead.org> > Date: Thu, Jul 01, 2010 at 12:10:54PM -0400 > > Hi Arnaldo, > > > Em Thu, Jul 01, 2010 at 12:47:37PM -0300, Arnaldo Carvalho de Melo escreveu: > > > Em Thu, Jul 01, 2010 at 03:49:19PM +0200, Borislav Petkov escreveu: > > > > From: Borislav Petkov <borislav.petkov@amd.com> > > > > > > > > Carve out generic library stuff into tools/lib/lk/ and rewire it with > > > > 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. > > > > > > Testing this now, thanks, > > > > Needs the patch below for "make O=~/build/perf tools" to continue > > working. Needs some more polishing so as not to break the non O= case. > > > > After lunch will investigate why my usual way to build the tools isn't working > > anymore, some missing -I probably: > > > > [acme@emilia linux-2.6-tip]$ make O=~/git/build/perf -C tools/perf install > > make: Entering directory `/home/acme/git/linux-2.6-tip/tools/perf' > > CC /home/acme/git/build/perf/builtin-record.o > > builtin-record.c:24:23: error: lk/cpumap.h: No such file or directory > > cc1: warnings being treated as errors The patch below fixes it. But we have one other problem: [acme@emilia linux-2.6-tip]$ make O=~/git/build/perf -C tools/ make: Entering directory `/home/acme/git/linux-2.6-tip/tools' make[1]: Entering directory `/home/acme/git/linux-2.6-tip/tools/lib' make[1]: `lklib.a' is up to date. make[1]: Leaving directory `/home/acme/git/linux-2.6-tip/tools/lib' make[1]: Entering directory `/home/acme/git/linux-2.6-tip/tools/perf' GEN perf-archive make[1]: Leaving directory `/home/acme/git/linux-2.6-tip/tools/perf' make: Leaving directory `/home/acme/git/linux-2.6-tip/tools' [acme@emilia linux-2.6-tip]$ make O=~/git/build/perf -C tools/perf/ make: Entering directory `/home/acme/git/linux-2.6-tip/tools/perf' * new build flags or prefix CC /home/acme/git/build/perf/perf.o CC /home/acme/git/build/perf/builtin-annotate.o CC /home/acme/git/build/perf/builtin-bench.o The logic that detects "new build flags or prefix" gets confused when we alternate between tools/ and tools/perf/, checking that. - Arnaldo diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 200fc13..72ccd17 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -268,7 +268,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 += -Iutil/include -Iarch/$(ARCH)/include -I../lib/ BASIC_LDFLAGS = # Guard against environment variables ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 05/21] perf: rewire generic library stuff, p1 2010-07-01 17:14 ` Arnaldo Carvalho de Melo @ 2010-07-01 20:14 ` Borislav Petkov 2010-07-01 21:13 ` Arnaldo Carvalho de Melo 0 siblings, 1 reply; 8+ messages in thread From: Borislav Petkov @ 2010-07-01 20:14 UTC (permalink / raw) To: Arnaldo Carvalho de Melo Cc: Steven Rostedt, Peter Zijlstra, Ingo Molnar, Frederic Weisbecker, LKML From: Arnaldo Carvalho de Melo <acme@infradead.org> Date: Thu, Jul 01, 2010 at 01:14:49PM -0400 > > > Needs the patch below for "make O=~/build/perf tools" to continue > > > working. Needs some more polishing so as not to break the non O= case. > > > > > > After lunch will investigate why my usual way to build the tools isn't working > > > anymore, some missing -I probably: > > > > > > [acme@emilia linux-2.6-tip]$ make O=~/git/build/perf -C tools/perf install > > > make: Entering directory `/home/acme/git/linux-2.6-tip/tools/perf' > > > CC /home/acme/git/build/perf/builtin-record.o > > > builtin-record.c:24:23: error: lk/cpumap.h: No such file or directory > > > cc1: warnings being treated as errors > > The patch below fixes it. > > But we have one other problem: > > [acme@emilia linux-2.6-tip]$ make O=~/git/build/perf -C tools/ > make: Entering directory `/home/acme/git/linux-2.6-tip/tools' > make[1]: Entering directory `/home/acme/git/linux-2.6-tip/tools/lib' > make[1]: `lklib.a' is up to date. > make[1]: Leaving directory `/home/acme/git/linux-2.6-tip/tools/lib' > make[1]: Entering directory `/home/acme/git/linux-2.6-tip/tools/perf' > GEN perf-archive > make[1]: Leaving directory `/home/acme/git/linux-2.6-tip/tools/perf' > make: Leaving directory `/home/acme/git/linux-2.6-tip/tools' > [acme@emilia linux-2.6-tip]$ make O=~/git/build/perf -C tools/perf/ > make: Entering directory `/home/acme/git/linux-2.6-tip/tools/perf' > * new build flags or prefix > CC /home/acme/git/build/perf/perf.o > CC /home/acme/git/build/perf/builtin-annotate.o > CC /home/acme/git/build/perf/builtin-bench.o > > The logic that detects "new build flags or prefix" gets confused when we > alternate between tools/ and tools/perf/, checking that. This might need an up-to-date check for the lklib.a archive first and not do "new build flags or prefix" if it is. Yeah, this is a different library and the logic doesn't know about it. > - Arnaldo > > diff --git a/tools/perf/Makefile b/tools/perf/Makefile > index 200fc13..72ccd17 100644 > --- a/tools/perf/Makefile > +++ b/tools/perf/Makefile > @@ -268,7 +268,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 += -Iutil/include -Iarch/$(ARCH)/include -I../lib/ > BASIC_LDFLAGS = Right, the whole scheme with the include paths is kinda shaky. I have the -I$(CURDIR)/lib BASIC_CFLAGS in the top Makefile for the case where we're in tools/ but this doesn't help with the -C switch as you show above. Maybe we should add more logic later to make the include path guessing more robust no matter from which directory you execute make instead of polluting BASIC_CFLAGS with duplicated path entries ... Hmmm... -- 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 05/21] perf: rewire generic library stuff, p1 2010-07-01 20:14 ` Borislav Petkov @ 2010-07-01 21:13 ` Arnaldo Carvalho de Melo 2010-07-01 21:37 ` Borislav Petkov 0 siblings, 1 reply; 8+ messages in thread From: Arnaldo Carvalho de Melo @ 2010-07-01 21:13 UTC (permalink / raw) To: Borislav Petkov Cc: Steven Rostedt, Peter Zijlstra, Ingo Molnar, Frederic Weisbecker, LKML Em Thu, Jul 01, 2010 at 10:14:18PM +0200, Borislav Petkov escreveu: > From: Arnaldo Carvalho de Melo <acme@infradead.org> > Date: Thu, Jul 01, 2010 at 01:14:49PM -0400 > > But we have one other problem: > > [acme@emilia linux-2.6-tip]$ make O=~/git/build/perf -C tools/ > > make: Entering directory `/home/acme/git/linux-2.6-tip/tools' > > make[1]: Entering directory `/home/acme/git/linux-2.6-tip/tools/lib' > > make[1]: `lklib.a' is up to date. > > make[1]: Leaving directory `/home/acme/git/linux-2.6-tip/tools/lib' > > make[1]: Entering directory `/home/acme/git/linux-2.6-tip/tools/perf' > > GEN perf-archive > > make[1]: Leaving directory `/home/acme/git/linux-2.6-tip/tools/perf' > > make: Leaving directory `/home/acme/git/linux-2.6-tip/tools' > > [acme@emilia linux-2.6-tip]$ make O=~/git/build/perf -C tools/perf/ > > make: Entering directory `/home/acme/git/linux-2.6-tip/tools/perf' > > * new build flags or prefix > > CC /home/acme/git/build/perf/perf.o > > CC /home/acme/git/build/perf/builtin-annotate.o > > > > The logic that detects "new build flags or prefix" gets confused when we > > alternate between tools/ and tools/perf/, checking that. > > This might need an up-to-date check for the lklib.a archive first and > not do "new build flags or prefix" if it is. Yeah, this is a different > library and the logic doesn't know about it. I got sidetracked, but this is what is in $(O)/PERF-CFLAGS for make -C tools/ [acme@emilia linux-2.6-tip]$ cat ../build/perf/PERF-CFLAGS -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Wformat-y2k -Wshadow -Winit-self -Wpacked -Wredundant-decls -Wstack-protector -Wstrict-aliasing=3 -Wswitch-default -Wswitch-enum -Wno-system-headers -Wundef -Wvolatile-register-var -Wwrite-strings -Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wstrict-prototypes -Wdeclaration-after-statement -fstack-protector-all -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/home/acme/git/linux-2.6-tip/tools/lib -I/home/acme/git/linux-2.6-tip/tools/perf -I/home/acme/git/linux-2.6-tip/tools/perf/util/include -Iutil/include -Iarch/x86/include -I../lib/ -I/home/acme/git/build/perf/ -DLIBELF_NO_MMAP -I/usr/include/elfutils -DDWARF_SUPPORT -I/usr/include/slang -DSHA1_HEADER='<openssl/sha.h>' : /home/acme/bin:libexec/perf-core:share/perf-core/templates:/home/acme [acme@emilia linux-2.6-tip]$ And this is its contents if we use "make -C tools/perf/" -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 -fstack-protector-all -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Iutil/include -Iarch/x86/include -I../lib/ -I/home/acme/git/build/perf/ -DLIBELF_NO_MMAP -I/usr/include/elfutils -DDWARF_SUPPORT -I/usr/include/slang -DSHA1_HEADER='<openssl/sha.h>' : /home/acme/bin:libexec/perf-core:share/perf-core/templates:/home/acme Its just a matter of making both match :-) - Arnaldo ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 05/21] perf: rewire generic library stuff, p1 2010-07-01 21:13 ` Arnaldo Carvalho de Melo @ 2010-07-01 21:37 ` Borislav Petkov 0 siblings, 0 replies; 8+ messages in thread From: Borislav Petkov @ 2010-07-01 21:37 UTC (permalink / raw) To: Arnaldo Carvalho de Melo Cc: Steven Rostedt, Peter Zijlstra, Ingo Molnar, Frederic Weisbecker, LKML From: Arnaldo Carvalho de Melo <acme@infradead.org> Date: Thu, Jul 01, 2010 at 05:13:31PM -0400 > Em Thu, Jul 01, 2010 at 10:14:18PM +0200, Borislav Petkov escreveu: > > From: Arnaldo Carvalho de Melo <acme@infradead.org> > > Date: Thu, Jul 01, 2010 at 01:14:49PM -0400 > > > But we have one other problem: > > > > [acme@emilia linux-2.6-tip]$ make O=~/git/build/perf -C tools/ > > > make: Entering directory `/home/acme/git/linux-2.6-tip/tools' > > > make[1]: Entering directory `/home/acme/git/linux-2.6-tip/tools/lib' > > > make[1]: `lklib.a' is up to date. > > > make[1]: Leaving directory `/home/acme/git/linux-2.6-tip/tools/lib' > > > make[1]: Entering directory `/home/acme/git/linux-2.6-tip/tools/perf' > > > GEN perf-archive > > > make[1]: Leaving directory `/home/acme/git/linux-2.6-tip/tools/perf' > > > make: Leaving directory `/home/acme/git/linux-2.6-tip/tools' > > > [acme@emilia linux-2.6-tip]$ make O=~/git/build/perf -C tools/perf/ > > > make: Entering directory `/home/acme/git/linux-2.6-tip/tools/perf' > > > * new build flags or prefix > > > CC /home/acme/git/build/perf/perf.o > > > CC /home/acme/git/build/perf/builtin-annotate.o > > > > > > The logic that detects "new build flags or prefix" gets confused when we > > > alternate between tools/ and tools/perf/, checking that. > > > > This might need an up-to-date check for the lklib.a archive first and > > not do "new build flags or prefix" if it is. Yeah, this is a different > > library and the logic doesn't know about it. > > I got sidetracked, but this is what is in $(O)/PERF-CFLAGS for > make -C tools/ > > [acme@emilia linux-2.6-tip]$ cat ../build/perf/PERF-CFLAGS > -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Wformat-y2k -Wshadow -Winit-self -Wpacked -Wredundant-decls -Wstack-protector -Wstrict-aliasing=3 -Wswitch-default -Wswitch-enum -Wno-system-headers -Wundef -Wvolatile-register-var -Wwrite-strings -Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wstrict-prototypes -Wdeclaration-after-statement -fstack-protector-all -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/home/acme/git/linux-2.6-tip/tools/lib -I/home/acme/git/linux-2.6-tip/tools/perf -I/home/acme/git/linux-2.6-tip/tools/perf/util/include -Iutil/include -Iarch/x86/include -I../lib/ -I/home/acme/git/build/perf/ -DLIBELF_NO_MMAP -I/usr/include/elfutils -DDWARF_SUPPORT -I/usr/include/slang -DSHA1_HEADER='<openssl/sha.h>' : /home/acme/bin:libexec/perf-core:share/perf-core/templates:/home/acme > [acme@emilia linux-2.6-tip]$ > > And this is its contents if we use "make -C tools/perf/" > > -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 -fstack-protector-all -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Iutil/include -Iarch/x86/include -I../lib/ -I/home/acme/git/build/perf/ -DLIBELF_NO_MMAP -I/usr/include/elfutils -DDWARF_SUPPORT -I/usr/include/slang -DSHA1_HEADER='<openssl/sha.h>' : /home/acme/bin:libexec/perf-core:share/perf-core/templates:/home/acme > > Its just a matter of making both match :-) Oh yeah, I see the difference. The second one is missing all the -Wxxx settings and the BASIS_CFLAGS with all the include paths which get computed in the top Makefile and exported to the Makefiles in the subdirectories. Hmm, maybe we should reroute the "make -C tools/perf/" invocation to go up one dir and execute the top-Makefile after all... I'll look into it soon, I'm almost falling asleep now :) Good night. -- 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <1277992175-19821-4-git-send-email-bp@amd64.org>]
[parent not found: <1277992805.1917.142.camel@laptop>]
[parent not found: <20100701141352.GA17823@aftab>]
[parent not found: <20100701161133.GE10616@nowhere>]
[parent not found: <1278000765.1917.220.camel@laptop>]
[parent not found: <20100701161448.GF10616@nowhere>]
* Re: [PATCH 03/21] perf_events: Add a helper to search for an event in a context [not found] ` <20100701161448.GF10616@nowhere> @ 2010-07-01 16:24 ` Borislav Petkov 2010-07-01 16:27 ` Frederic Weisbecker 0 siblings, 1 reply; 8+ messages in thread From: Borislav Petkov @ 2010-07-01 16:24 UTC (permalink / raw) To: Frederic Weisbecker Cc: Peter Zijlstra, Arnaldo Carvalho de Melo, Steven Rostedt, Ingo Molnar, LKML From: Frederic Weisbecker <fweisbec@gmail.com> Date: Thu, Jul 01, 2010 at 12:14:50PM -0400 Hi Frederic, > On Thu, Jul 01, 2010 at 06:12:45PM +0200, Peter Zijlstra wrote: > > On Thu, 2010-07-01 at 18:11 +0200, Frederic Weisbecker wrote: > > > I suspect we need another syscall that can list all the persistent events > > > with a unique id and the attrs that follow. > > > > > > So you get a unique id for all of them and you can create an fd on top > > > of this id by using a PERF_FLAG_REQUEST_PERSISTENT and this id put in > > > attr.config. > > > > Isn't that what filesystems were invented for? > > > The problem is when you create a persistent event, you lose the fd. > So you need to retrieve it somehow. actually the idea is to decouple those from the fd alltogether and provide specific file_operations in debugfs and such, as Peter suggested. Which sounds much more sane to me especially since, at least in the MCE case, all the entities that register into that event need to see the same samples (and read the same buffers etc). And let's try not to read too much into those persistent events - it may just as well be that we need them only for MCEs and nothing else :) -- 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 03/21] perf_events: Add a helper to search for an event in a context 2010-07-01 16:24 ` [PATCH 03/21] perf_events: Add a helper to search for an event in a context Borislav Petkov @ 2010-07-01 16:27 ` Frederic Weisbecker 0 siblings, 0 replies; 8+ messages in thread From: Frederic Weisbecker @ 2010-07-01 16:27 UTC (permalink / raw) To: Borislav Petkov Cc: Peter Zijlstra, Arnaldo Carvalho de Melo, Steven Rostedt, Ingo Molnar, LKML On Thu, Jul 01, 2010 at 06:24:24PM +0200, Borislav Petkov wrote: > From: Frederic Weisbecker <fweisbec@gmail.com> > Date: Thu, Jul 01, 2010 at 12:14:50PM -0400 > > Hi Frederic, > > > On Thu, Jul 01, 2010 at 06:12:45PM +0200, Peter Zijlstra wrote: > > > On Thu, 2010-07-01 at 18:11 +0200, Frederic Weisbecker wrote: > > > > I suspect we need another syscall that can list all the persistent events > > > > with a unique id and the attrs that follow. > > > > > > > > So you get a unique id for all of them and you can create an fd on top > > > > of this id by using a PERF_FLAG_REQUEST_PERSISTENT and this id put in > > > > attr.config. > > > > > > Isn't that what filesystems were invented for? > > > > > > The problem is when you create a persistent event, you lose the fd. > > So you need to retrieve it somehow. > > actually the idea is to decouple those from the fd alltogether and > provide specific file_operations in debugfs and such, as Peter > suggested. Which sounds much more sane to me especially since, at least > in the MCE case, all the entities that register into that event need to > see the same samples (and read the same buffers etc). Sure the idea of putting that in fs is better. Note the idea of a new syscall was quite close: it would have listed unique ids of the persistent events, but not fds, you'd have yet to create those fds on top of the ids. > > And let's try not to read too much into those persistent events - it may > just as well be that we need them only for MCEs and nothing else :) Not really. It would be useful for boot tracing, amongst various other things like flight recorder tracing, etc... ^ permalink raw reply [flat|nested] 8+ messages in thread
* [RFC PATCH 00/21] RAS daemon prototype, v1 @ 2010-07-01 15:55 Borislav Petkov 2010-07-01 15:55 ` [PATCH 05/21] perf: rewire generic library stuff, p1 Borislav Petkov 0 siblings, 1 reply; 8+ messages in thread From: Borislav Petkov @ 2010-07-01 15:55 UTC (permalink / raw) To: linux-kernel From: Borislav Petkov <borislav.petkov@amd.com> (resubmitting since lkml wasn't on CC list) Hi guys, 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. ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 05/21] perf: rewire generic library stuff, p1 2010-07-01 15:55 [RFC PATCH 00/21] RAS daemon prototype, v1 Borislav Petkov @ 2010-07-01 15:55 ` Borislav Petkov 0 siblings, 0 replies; 8+ messages in thread From: Borislav Petkov @ 2010-07-01 15:55 UTC (permalink / raw) To: linux-kernel From: Borislav Petkov <borislav.petkov@amd.com> Carve out generic library stuff into tools/lib/lk/ and rewire it with 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. Signed-off-by: Borislav Petkov <borislav.petkov@amd.com> --- tools/Makefile | 58 ++++++++++++++++++++++ tools/Makefile.lib | 28 +++++++++++ tools/lib/Makefile | 38 ++++++++++++++ tools/lib/lk/bitmap.c | 21 ++++++++ tools/lib/lk/cpumap.c | 114 +++++++++++++++++++++++++++++++++++++++++++ tools/lib/lk/cpumap.h | 7 +++ tools/lib/lk/hweight.c | 31 ++++++++++++ tools/perf/Makefile | 41 ++-------------- tools/perf/bench/bench.h | 2 + tools/perf/builtin-record.c | 2 +- tools/perf/builtin-stat.c | 2 +- tools/perf/builtin-top.c | 2 +- tools/perf/util/bitmap.c | 21 -------- tools/perf/util/cache.h | 1 + tools/perf/util/cpumap.c | 114 ------------------------------------------- tools/perf/util/cpumap.h | 7 --- tools/perf/util/hweight.c | 31 ------------ 17 files changed, 308 insertions(+), 212 deletions(-) create mode 100644 tools/Makefile create mode 100644 tools/Makefile.lib create mode 100644 tools/lib/Makefile create mode 100644 tools/lib/lk/bitmap.c create mode 100644 tools/lib/lk/cpumap.c create mode 100644 tools/lib/lk/cpumap.h create mode 100644 tools/lib/lk/hweight.c delete mode 100644 tools/perf/util/bitmap.c delete mode 100644 tools/perf/util/cpumap.c delete mode 100644 tools/perf/util/cpumap.h delete mode 100644 tools/perf/util/hweight.c diff --git a/tools/Makefile b/tools/Makefile new file mode 100644 index 0000000..e645761 --- /dev/null +++ b/tools/Makefile @@ -0,0 +1,58 @@ +# CFLAGS and LDFLAGS are for the users to override from the command line. +# + +include 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 + +ifeq ("$(origin DEBUG)", "command line") + PERF_DEBUG = $(DEBUG) +endif +ifndef PERF_DEBUG + CFLAGS_OPTIMIZE = -O6 + export CFLAGS_OPTIMIZE +endif + +# +# lib includes for submake +BASIC_CFLAGS = -I$(CURDIR)/lib -I$(CURDIR)/perf -I$(CURDIR)/perf/util/include + +export BASIC_CFLAGS + +perf: lib .FORCE + $(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) + +lib: .FORCE + $(QUIET_SUBDIR0)lib/ $(QUIET_SUBDIR1) + +clean: + $(QUIET_SUBDIR0)lib/ $(QUIET_SUBDIR1) clean + $(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) clean + +.PHONY: clean .FORCE diff --git a/tools/Makefile.lib b/tools/Makefile.lib new file mode 100644 index 0000000..aac6be9 --- /dev/null +++ b/tools/Makefile.lib @@ -0,0 +1,28 @@ +QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir +QUIET_SUBDIR1 = + +ifneq ($(findstring $(MAKEFLAGS),w),w) +PRINT_DIR = --no-print-directory +else # "make -w" +NO_SUBDIR = : +endif + +ifneq ($(findstring $(MAKEFLAGS),s),s) +ifndef V + QUIET_CC = @echo ' ' CC $@; + QUIET_AR = @echo ' ' AR $@; + QUIET_LINK = @echo ' ' LINK $@; + QUIET_BUILT_IN = @echo ' ' BUILTIN $@; + QUIET_GEN = @echo ' ' GEN $@; + QUIET_SUBDIR0 = +@subdir= + QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ + $(MAKE) $(PRINT_DIR) -C $$subdir + export V + export QUIET_GEN + export QUIET_BUILT_IN +endif +endif + +ifeq ("$(origin O)", "command line") + OUTPUT := $(O)/ +endif diff --git a/tools/lib/Makefile b/tools/lib/Makefile new file mode 100644 index 0000000..48f8e21 --- /dev/null +++ b/tools/lib/Makefile @@ -0,0 +1,38 @@ +include ../Makefile.lib + +# Guard against environment variables +LIB_H = +LIB_OBJS = + +LIB_H += lk/cpumap.h + +LIB_OBJS += $(OUTPUT)lk/bitmap.o +LIB_OBJS += $(OUTPUT)lk/cpumap.o +LIB_OBJS += $(OUTPUT)lk/hweight.o + +LIBFILE = lklib.a + +RM = rm -f + +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) +STRIP ?= strip + +$(LIBFILE): $(LIB_OBJS) + $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $(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) + +.PHONY: clean diff --git a/tools/lib/lk/bitmap.c b/tools/lib/lk/bitmap.c new file mode 100644 index 0000000..5e230ac --- /dev/null +++ b/tools/lib/lk/bitmap.c @@ -0,0 +1,21 @@ +/* + * From lib/bitmap.c + * Helper functions for bitmap.h. + * + * This source code is licensed under the GNU General Public License, + * Version 2. See the file COPYING for more details. + */ +#include <linux/bitmap.h> + +int __bitmap_weight(const unsigned long *bitmap, int bits) +{ + int k, w = 0, lim = bits/BITS_PER_LONG; + + for (k = 0; k < lim; k++) + w += hweight_long(bitmap[k]); + + if (bits % BITS_PER_LONG) + w += hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits)); + + return w; +} diff --git a/tools/lib/lk/cpumap.c b/tools/lib/lk/cpumap.c new file mode 100644 index 0000000..71e376b --- /dev/null +++ b/tools/lib/lk/cpumap.c @@ -0,0 +1,114 @@ +#include <util/util.h> +#include <perf.h> +#include "cpumap.h" +#include <assert.h> +#include <stdio.h> + +int cpumap[MAX_NR_CPUS]; + +static int default_cpu_map(void) +{ + int nr_cpus, i; + + nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); + assert(nr_cpus <= MAX_NR_CPUS); + assert((int)nr_cpus >= 0); + + for (i = 0; i < nr_cpus; ++i) + cpumap[i] = i; + + return nr_cpus; +} + +static int read_all_cpu_map(void) +{ + FILE *onlnf; + int nr_cpus = 0; + int n, cpu, prev; + char sep; + + onlnf = fopen("/sys/devices/system/cpu/online", "r"); + if (!onlnf) + return default_cpu_map(); + + sep = 0; + prev = -1; + for (;;) { + n = fscanf(onlnf, "%u%c", &cpu, &sep); + if (n <= 0) + break; + if (prev >= 0) { + assert(nr_cpus + cpu - prev - 1 < MAX_NR_CPUS); + while (++prev < cpu) + cpumap[nr_cpus++] = prev; + } + assert (nr_cpus < MAX_NR_CPUS); + cpumap[nr_cpus++] = cpu; + if (n == 2 && sep == '-') + prev = cpu; + else + prev = -1; + if (n == 1 || sep == '\n') + break; + } + fclose(onlnf); + if (nr_cpus > 0) + return nr_cpus; + + return default_cpu_map(); +} + +int read_cpu_map(const char *cpu_list) +{ + unsigned long start_cpu, end_cpu = 0; + char *p = NULL; + int i, nr_cpus = 0; + + if (!cpu_list) + return read_all_cpu_map(); + + if (!isdigit(*cpu_list)) + goto invalid; + + while (isdigit(*cpu_list)) { + p = NULL; + start_cpu = strtoul(cpu_list, &p, 0); + if (start_cpu >= INT_MAX + || (*p != '\0' && *p != ',' && *p != '-')) + goto invalid; + + if (*p == '-') { + cpu_list = ++p; + p = NULL; + end_cpu = strtoul(cpu_list, &p, 0); + + if (end_cpu >= INT_MAX || (*p != '\0' && *p != ',')) + goto invalid; + + if (end_cpu < start_cpu) + goto invalid; + } else { + end_cpu = start_cpu; + } + + for (; start_cpu <= end_cpu; start_cpu++) { + /* check for duplicates */ + for (i = 0; i < nr_cpus; i++) + if (cpumap[i] == (int)start_cpu) + goto invalid; + + assert(nr_cpus < MAX_NR_CPUS); + cpumap[nr_cpus++] = (int)start_cpu; + } + if (*p) + ++p; + + cpu_list = p; + } + if (nr_cpus > 0) + return nr_cpus; + + return default_cpu_map(); +invalid: + return -1; +} diff --git a/tools/lib/lk/cpumap.h b/tools/lib/lk/cpumap.h new file mode 100644 index 0000000..1d7bd56 --- /dev/null +++ b/tools/lib/lk/cpumap.h @@ -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 */ diff --git a/tools/lib/lk/hweight.c b/tools/lib/lk/hweight.c new file mode 100644 index 0000000..5c1d0d0 --- /dev/null +++ b/tools/lib/lk/hweight.c @@ -0,0 +1,31 @@ +#include <linux/bitops.h> + +/** + * hweightN - returns the hamming weight of a N-bit word + * @x: the word to weigh + * + * The Hamming Weight of a number is the total number of bits set in it. + */ + +unsigned int hweight32(unsigned int w) +{ + unsigned int res = w - ((w >> 1) & 0x55555555); + res = (res & 0x33333333) + ((res >> 2) & 0x33333333); + res = (res + (res >> 4)) & 0x0F0F0F0F; + res = res + (res >> 8); + return (res + (res >> 16)) & 0x000000FF; +} + +unsigned long hweight64(__u64 w) +{ +#if BITS_PER_LONG == 32 + return hweight32((unsigned int)(w >> 32)) + hweight32((unsigned int)w); +#elif BITS_PER_LONG == 64 + __u64 res = w - ((w >> 1) & 0x5555555555555555ul); + res = (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul); + res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0Ful; + res = res + (res >> 8); + res = res + (res >> 16); + return (res + (res >> 32)) & 0x00000000000000FFul; +#endif +} diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 6aa2fe3..df815d6 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -1,6 +1,4 @@ -ifeq ("$(origin O)", "command line") - OUTPUT := $(O)/ -endif +include ../Makefile.lib # The default target of this Makefile is... all:: @@ -191,33 +189,6 @@ $(shell sh -c 'mkdir -p $(OUTPUT)arch/$(ARCH)/util/' 2> /dev/null) # CFLAGS and LDFLAGS are for the users to override from the command line. -# -# 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 - ifeq ("$(origin DEBUG)", "command line") PERF_DEBUG = $(DEBUG) endif @@ -297,7 +268,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 += -Iutil/include -Iarch/$(ARCH)/include BASIC_LDFLAGS = # Guard against environment variables @@ -413,7 +384,6 @@ 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 @@ -430,8 +400,6 @@ LIB_OBJS += $(OUTPUT)util/parse-options.o LIB_OBJS += $(OUTPUT)util/parse-events.o LIB_OBJS += $(OUTPUT)util/path.o LIB_OBJS += $(OUTPUT)util/rbtree.o -LIB_OBJS += $(OUTPUT)util/bitmap.o -LIB_OBJS += $(OUTPUT)util/hweight.o LIB_OBJS += $(OUTPUT)util/run-command.o LIB_OBJS += $(OUTPUT)util/quote.o LIB_OBJS += $(OUTPUT)util/strbuf.o @@ -460,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 @@ -490,7 +457,9 @@ BUILTIN_OBJS += $(OUTPUT)builtin-kvm.o BUILTIN_OBJS += $(OUTPUT)builtin-test.o BUILTIN_OBJS += $(OUTPUT)builtin-inject.o -PERFLIBS = $(LIB_FILE) +LKLIB = ../lib/lklib.a + +PERFLIBS = $(LIB_FILE) $(LKLIB) # # Platform specific tweaks diff --git a/tools/perf/bench/bench.h b/tools/perf/bench/bench.h index f7781c6..0c7ee07 100644 --- a/tools/perf/bench/bench.h +++ b/tools/perf/bench/bench.h @@ -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); diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 86b1c3b..499dc75 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -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> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index a6b4d44..4430d51 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -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> diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 1e8e92e..def254a 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -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" diff --git a/tools/perf/util/bitmap.c b/tools/perf/util/bitmap.c deleted file mode 100644 index 5e230ac..0000000 --- a/tools/perf/util/bitmap.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * From lib/bitmap.c - * Helper functions for bitmap.h. - * - * This source code is licensed under the GNU General Public License, - * Version 2. See the file COPYING for more details. - */ -#include <linux/bitmap.h> - -int __bitmap_weight(const unsigned long *bitmap, int bits) -{ - int k, w = 0, lim = bits/BITS_PER_LONG; - - for (k = 0; k < lim; k++) - w += hweight_long(bitmap[k]); - - if (bits % BITS_PER_LONG) - w += hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits)); - - return w; -} diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h index 27e9ebe..0444fc2 100644 --- a/tools/perf/util/cache.h +++ b/tools/perf/util/cache.h @@ -5,6 +5,7 @@ #include "util.h" #include "strbuf.h" #include "../perf.h" +#include <linux/compiler.h> #define CMD_EXEC_PATH "--exec-path" #define CMD_PERF_DIR "--perf-dir=" diff --git a/tools/perf/util/cpumap.c b/tools/perf/util/cpumap.c deleted file mode 100644 index 0f9b8d7..0000000 --- a/tools/perf/util/cpumap.c +++ /dev/null @@ -1,114 +0,0 @@ -#include "util.h" -#include "../perf.h" -#include "cpumap.h" -#include <assert.h> -#include <stdio.h> - -int cpumap[MAX_NR_CPUS]; - -static int default_cpu_map(void) -{ - int nr_cpus, i; - - nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); - assert(nr_cpus <= MAX_NR_CPUS); - assert((int)nr_cpus >= 0); - - for (i = 0; i < nr_cpus; ++i) - cpumap[i] = i; - - return nr_cpus; -} - -static int read_all_cpu_map(void) -{ - FILE *onlnf; - int nr_cpus = 0; - int n, cpu, prev; - char sep; - - onlnf = fopen("/sys/devices/system/cpu/online", "r"); - if (!onlnf) - return default_cpu_map(); - - sep = 0; - prev = -1; - for (;;) { - n = fscanf(onlnf, "%u%c", &cpu, &sep); - if (n <= 0) - break; - if (prev >= 0) { - assert(nr_cpus + cpu - prev - 1 < MAX_NR_CPUS); - while (++prev < cpu) - cpumap[nr_cpus++] = prev; - } - assert (nr_cpus < MAX_NR_CPUS); - cpumap[nr_cpus++] = cpu; - if (n == 2 && sep == '-') - prev = cpu; - else - prev = -1; - if (n == 1 || sep == '\n') - break; - } - fclose(onlnf); - if (nr_cpus > 0) - return nr_cpus; - - return default_cpu_map(); -} - -int read_cpu_map(const char *cpu_list) -{ - unsigned long start_cpu, end_cpu = 0; - char *p = NULL; - int i, nr_cpus = 0; - - if (!cpu_list) - return read_all_cpu_map(); - - if (!isdigit(*cpu_list)) - goto invalid; - - while (isdigit(*cpu_list)) { - p = NULL; - start_cpu = strtoul(cpu_list, &p, 0); - if (start_cpu >= INT_MAX - || (*p != '\0' && *p != ',' && *p != '-')) - goto invalid; - - if (*p == '-') { - cpu_list = ++p; - p = NULL; - end_cpu = strtoul(cpu_list, &p, 0); - - if (end_cpu >= INT_MAX || (*p != '\0' && *p != ',')) - goto invalid; - - if (end_cpu < start_cpu) - goto invalid; - } else { - end_cpu = start_cpu; - } - - for (; start_cpu <= end_cpu; start_cpu++) { - /* check for duplicates */ - for (i = 0; i < nr_cpus; i++) - if (cpumap[i] == (int)start_cpu) - goto invalid; - - assert(nr_cpus < MAX_NR_CPUS); - cpumap[nr_cpus++] = (int)start_cpu; - } - if (*p) - ++p; - - cpu_list = p; - } - if (nr_cpus > 0) - return nr_cpus; - - return default_cpu_map(); -invalid: - return -1; -} diff --git a/tools/perf/util/cpumap.h b/tools/perf/util/cpumap.h deleted file mode 100644 index 3e60f56..0000000 --- a/tools/perf/util/cpumap.h +++ /dev/null @@ -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 */ diff --git a/tools/perf/util/hweight.c b/tools/perf/util/hweight.c deleted file mode 100644 index 5c1d0d0..0000000 --- a/tools/perf/util/hweight.c +++ /dev/null @@ -1,31 +0,0 @@ -#include <linux/bitops.h> - -/** - * hweightN - returns the hamming weight of a N-bit word - * @x: the word to weigh - * - * The Hamming Weight of a number is the total number of bits set in it. - */ - -unsigned int hweight32(unsigned int w) -{ - unsigned int res = w - ((w >> 1) & 0x55555555); - res = (res & 0x33333333) + ((res >> 2) & 0x33333333); - res = (res + (res >> 4)) & 0x0F0F0F0F; - res = res + (res >> 8); - return (res + (res >> 16)) & 0x000000FF; -} - -unsigned long hweight64(__u64 w) -{ -#if BITS_PER_LONG == 32 - return hweight32((unsigned int)(w >> 32)) + hweight32((unsigned int)w); -#elif BITS_PER_LONG == 64 - __u64 res = w - ((w >> 1) & 0x5555555555555555ul); - res = (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul); - res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0Ful; - res = res + (res >> 8); - res = res + (res >> 16); - return (res + (res >> 32)) & 0x00000000000000FFul; -#endif -} -- 1.7.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-07-01 21:51 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1277992175-19821-1-git-send-email-bp@amd64.org>
[not found] ` <1277992175-19821-6-git-send-email-bp@amd64.org>
[not found] ` <20100701154737.GE8902@ghostprotocols.net>
[not found] ` <20100701161054.GF8902@ghostprotocols.net>
2010-07-01 16:17 ` [PATCH 05/21] perf: rewire generic library stuff, p1 Borislav Petkov
2010-07-01 17:14 ` Arnaldo Carvalho de Melo
2010-07-01 20:14 ` Borislav Petkov
2010-07-01 21:13 ` Arnaldo Carvalho de Melo
2010-07-01 21:37 ` Borislav Petkov
[not found] ` <1277992175-19821-4-git-send-email-bp@amd64.org>
[not found] ` <1277992805.1917.142.camel@laptop>
[not found] ` <20100701141352.GA17823@aftab>
[not found] ` <20100701161133.GE10616@nowhere>
[not found] ` <1278000765.1917.220.camel@laptop>
[not found] ` <20100701161448.GF10616@nowhere>
2010-07-01 16:24 ` [PATCH 03/21] perf_events: Add a helper to search for an event in a context Borislav Petkov
2010-07-01 16:27 ` Frederic Weisbecker
2010-07-01 15:55 [RFC PATCH 00/21] RAS daemon prototype, v1 Borislav Petkov
2010-07-01 15:55 ` [PATCH 05/21] perf: rewire generic library stuff, p1 Borislav Petkov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox