Skip to content

Commit

Permalink
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/…
Browse files Browse the repository at this point in the history
…linux/kernel/git/tip/tip

Pull perf fixes from Ingo Molnar:
 "A handful of tooling fixes"

* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  perf stat: Wait for the correct child
  perf tools: Support running perf binaries with a dash in their name
  perf config: Check not only section->from_system_config but also item's
  perf ui progress: Fix progress update
  perf ui progress: Make sure we always define step value
  perf tools: Open perf.data with O_CLOEXEC flag
  tools lib api: Fix make DEBUG=1 build
  perf tests: Fix compile when libunwind's unwind.h is available
  tools include linux: Guard against redefinition of some macros
  • Loading branch information
torvalds committed Sep 13, 2017
2 parents ec846ec + b130a69 commit 46c1e79
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 14 deletions.
9 changes: 6 additions & 3 deletions tools/include/linux/compiler-gcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))

#define noinline __attribute__((noinline))

#ifndef __packed
#define __packed __attribute__((packed))

#endif
#ifndef __noreturn
#define __noreturn __attribute__((noreturn))

#endif
#ifndef __aligned
#define __aligned(x) __attribute__((aligned(x)))
#endif
#define __printf(a, b) __attribute__((format(printf, a, b)))
#define __scanf(a, b) __attribute__((format(scanf, a, b)))
8 changes: 7 additions & 1 deletion tools/lib/api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ MAKEFLAGS += --no-print-directory
LIBFILE = $(OUTPUT)libapi.a

CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS)
CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC
CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -U_FORTIFY_SOURCE -fPIC

ifeq ($(DEBUG),0)
ifeq ($(CC_NO_CLANG), 0)
CFLAGS += -O3
else
CFLAGS += -O6
endif
endif

ifeq ($(DEBUG),0)
CFLAGS += -D_FORTIFY_SOURCE
endif

# Treat warnings as errors unless directed not to
ifneq ($(WERROR),0)
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static int set_config(struct perf_config_set *set, const char *file_name,
fprintf(fp, "[%s]\n", section->name);

perf_config_items__for_each_entry(&section->items, item) {
if (!use_system_config && section->from_system_config)
if (!use_system_config && item->from_system_config)
continue;
if (item->value)
fprintf(fp, "\t%s = %s\n",
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ static int __run_perf_stat(int argc, const char **argv)
process_interval();
}
}
wait(&status);
waitpid(child_pid, &status, 0);

if (workload_exec_errno) {
const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg));
Expand Down
14 changes: 10 additions & 4 deletions tools/perf/perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,15 +467,21 @@ int main(int argc, const char **argv)
* - cannot execute it externally (since it would just do
* the same thing over again)
*
* So we just directly call the internal command handler, and
* die if that one cannot handle it.
* So we just directly call the internal command handler. If that one
* fails to handle this, then maybe we just run a renamed perf binary
* that contains a dash in its name. To handle this scenario, we just
* fall through and ignore the "xxxx" part of the command string.
*/
if (strstarts(cmd, "perf-")) {
cmd += 5;
argv[0] = cmd;
handle_internal_command(argc, argv);
fprintf(stderr, "cannot handle %s internally", cmd);
goto out;
/*
* If the command is handled, the above function does not
* return undo changes and fall through in such a case.
*/
cmd -= 5;
argv[0] = cmd;
}
if (strstarts(cmd, "trace")) {
#ifdef HAVE_LIBAUDIT_SUPPORT
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/tests/dwarf-unwind.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "debug.h"
#include "machine.h"
#include "event.h"
#include "unwind.h"
#include "../util/unwind.h"
#include "perf_regs.h"
#include "map.h"
#include "thread.h"
Expand Down
9 changes: 7 additions & 2 deletions tools/perf/ui/progress.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <linux/kernel.h>
#include "../cache.h"
#include "progress.h"

Expand All @@ -14,18 +15,22 @@ struct ui_progress_ops *ui_progress__ops = &null_progress__ops;

void ui_progress__update(struct ui_progress *p, u64 adv)
{
u64 last = p->curr;

p->curr += adv;

if (p->curr >= p->next) {
p->next += p->step;
u64 nr = DIV_ROUND_UP(p->curr - last, p->step);

p->next += nr * p->step;
ui_progress__ops->update(p);
}
}

void ui_progress__init(struct ui_progress *p, u64 total, const char *title)
{
p->curr = 0;
p->next = p->step = total / 16;
p->next = p->step = total / 16 ?: 1;
p->total = total;
p->title = title;

Expand Down
13 changes: 12 additions & 1 deletion tools/perf/util/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
#include "util.h"
#include "debug.h"

#ifndef O_CLOEXEC
#ifdef __sparc__
#define O_CLOEXEC 0x400000
#elif defined(__alpha__) || defined(__hppa__)
#define O_CLOEXEC 010000000
#else
#define O_CLOEXEC 02000000
#endif
#endif

static bool check_pipe(struct perf_data_file *file)
{
struct stat st;
Expand Down Expand Up @@ -96,7 +106,8 @@ static int open_file_write(struct perf_data_file *file)
if (check_backup(file))
return -1;

fd = open(file->path, O_CREAT|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR);
fd = open(file->path, O_CREAT|O_RDWR|O_TRUNC|O_CLOEXEC,
S_IRUSR|S_IWUSR);

if (fd < 0)
pr_err("failed to open %s : %s\n", file->path,
Expand Down

0 comments on commit 46c1e79

Please sign in to comment.