Skip to content

Commit

Permalink
turbostat: Don't put unprocessed uapi headers in the include path
Browse files Browse the repository at this point in the history
turbostat's Makefile puts arch/x86/include/uapi/ in the include path, so
that it can include <asm/msr.h> from it.  It isn't in general safe to
include even uapi headers directly from the kernel tree without
processing them through scripts/headers_install.sh, but asm/msr.h
happens to work.

However, that include path can break with some versions of system
headers, by overriding some system headers with the unprocessed versions
directly from the kernel source.  For instance:

In file included from /build/x86-generic/usr/include/bits/sigcontext.h:28:0,
                 from /build/x86-generic/usr/include/signal.h:339,
                 from /build/x86-generic/usr/include/sys/wait.h:31,
                 from turbostat.c:27:
../../../../arch/x86/include/uapi/asm/sigcontext.h:4:28: fatal error: linux/compiler.h: No such file or directory

This occurs because the system bits/sigcontext.h on that build system
includes <asm/sigcontext.h>, and asm/sigcontext.h in the kernel source
includes <linux/compiler.h>, which scripts/headers_install.sh would have
filtered out.

Since turbostat really only wants a single header, just include that one
header rather than putting an entire directory of kernel headers on the
include path.

In the process, switch from msr.h to msr-index.h, since turbostat just
wants the MSR numbers.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Cc: stable@vger.kernel.org
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Josh Triplett authored and Len Brown committed Jan 19, 2014
1 parent 7e22e91 commit b731f31
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tools/power/x86/turbostat/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DESTDIR :=

turbostat : turbostat.c
CFLAGS += -Wall
CFLAGS += -I../../../../arch/x86/include/uapi/
CFLAGS += -DMSRHEADER='"../../../../arch/x86/include/uapi/asm/msr-index.h"'

%: %.c
@mkdir -p $(BUILD_OUTPUT)
Expand Down
2 changes: 1 addition & 1 deletion tools/power/x86/turbostat/turbostat.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/

#define _GNU_SOURCE
#include <asm/msr.h>
#include MSRHEADER
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
Expand Down

0 comments on commit b731f31

Please sign in to comment.