History

Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: tracing: t_start: reset FTRACE_ITER_HASH in case of seek/pread perf symbols: Fix multiple initialization of symbol system perf: Fix CPU hotplug perf, trace: Fix module leak tracing/kprobe: Fix handling of C-unlike argument names tracing/kprobes: Fix handling of argument names perf probe: Fix handling of arguments names perf probe: Fix return probe support tracing/kprobe: Fix a memory leak in error case tracing: Do not allow llseek to set_ftrace_filter

Linus Torvalds committed 16 years ago

Commit f2955b42 parents 3d96406 9efdda38 files · +73 −36Browse files

Unified · Split

8 files
  1. kernel/perf_event.c +3 −3
  2. kernel/trace/ftrace.c +3 −1
  3. kernel/trace/trace_event_perf.c +3 −0
  4. kernel/trace/trace_kprobe.c +25 −18
  5. tools/perf/util/probe-event.c +1 −0
  6. tools/perf/util/probe-finder.c +29 −13
  7. tools/perf/util/symbol.c +7 −0
  8. tools/perf/util/symbol.h +2 −1
kernel/perf_event.c+3−3
@@ -5761,15 +5761,15 @@ perf_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) · 5760 unmodified lines
57615761 {
57625762 unsigned int cpu = (long)hcpu;
57635763
5764− switch (action) {
5764+ switch (action & ~CPU_TASKS_FROZEN) {
57655765
57665766 case CPU_UP_PREPARE:
5767− case CPU_UP_PREPARE_FROZEN:
5767+ case CPU_DOWN_FAILED:
57685768 perf_event_init_cpu(cpu);
57695769 break;
57705770
5771+ case CPU_UP_CANCELED:
57715772 case CPU_DOWN_PREPARE:
5772− case CPU_DOWN_PREPARE_FROZEN:
57735773 perf_event_exit_cpu(cpu);
57745774 break;
57755775
kernel/trace/ftrace.c+3−1
@@ -1510,6 +1510,8 @@ static void *t_start(struct seq_file *m, loff_t *pos) · 1509 unmodified lines
15101510 if (*pos > 0)
15111511 return t_hash_start(m, pos);
15121512 iter->flags |= FTRACE_ITER_PRINTALL;
1513+ /* reset in case of seek/pread */
1514+ iter->flags &= ~FTRACE_ITER_HASH;
15131515 return iter;
15141516 }
15151517
@@ -2416,7 +2418,7 @@ static const struct file_operations ftrace_filter_fops = { · 900 unmodified lines
24162418 .open = ftrace_filter_open,
24172419 .read = seq_read,
24182420 .write = ftrace_filter_write,
2419− .llseek = ftrace_regex_lseek,
2421+ .llseek = no_llseek,
24202422 .release = ftrace_filter_release,
24212423 };
24222424
kernel/trace/trace_event_perf.c+3−0
@@ -91,6 +91,8 @@ int perf_trace_init(struct perf_event *p_event) · 90 unmodified lines
9191 tp_event->class && tp_event->class->reg &&
9292 try_module_get(tp_event->mod)) {
9393 ret = perf_trace_event_init(tp_event, p_event);
94+ if (ret)
95+ module_put(tp_event->mod);
9496 break;
9597 }
9698 }
@@ -146,6 +148,7 @@ void perf_trace_destroy(struct perf_event *p_event) · 49 unmodified lines
146148 }
147149 }
148150 out:
151+ module_put(tp_event->mod);
149152 mutex_unlock(&event_mutex);
150153 }
151154
kernel/trace/trace_kprobe.c+25−18
@@ -514,8 +514,8 @@ static int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs); · 513 unmodified lines
514514 static int kretprobe_dispatcher(struct kretprobe_instance *ri,
515515 struct pt_regs *regs);
516516
517−/* Check the name is good for event/group */
518−static int check_event_name(const char *name)
517+/* Check the name is good for event/group/fields */
518+static int is_good_name(const char *name)
519519 {
520520 if (!isalpha(*name) && *name != '_')
521521 return 0;
@@ -557,7 +557,7 @@ static struct trace_probe *alloc_trace_probe(const char *group, · 35 unmodified lines
557557 else
558558 tp->rp.kp.pre_handler = kprobe_dispatcher;
559559
560− if (!event || !check_event_name(event)) {
560+ if (!event || !is_good_name(event)) {
561561 ret = -EINVAL;
562562 goto error;
563563 }
@@ -567,7 +567,7 @@ static struct trace_probe *alloc_trace_probe(const char *group, · 3 unmodified lines
567567 if (!tp->call.name)
568568 goto error;
569569
570− if (!group || !check_event_name(group)) {
570+ if (!group || !is_good_name(group)) {
571571 ret = -EINVAL;
572572 goto error;
573573 }
@@ -883,7 +883,7 @@ static int create_trace_probe(int argc, char **argv) · 309 unmodified lines
883883 int i, ret = 0;
884884 int is_return = 0, is_delete = 0;
885885 char *symbol = NULL, *event = NULL, *group = NULL;
886− char *arg, *tmp;
886+ char *arg;
887887 unsigned long offset = 0;
888888 void *addr = NULL;
889889 char buf[MAX_EVENT_NAME_LEN];
@@ -992,26 +992,36 @@ static int create_trace_probe(int argc, char **argv) · 102 unmodified lines
992992 /* parse arguments */
993993 ret = 0;
994994 for (i = 0; i < argc && i < MAX_TRACE_ARGS; i++) {
995+ /* Increment count for freeing args in error case */
996+ tp->nr_args++;
997+
995998 /* Parse argument name */
996999 arg = strchr(argv[i], '=');
997− if (arg)
1000+ if (arg) {
9981001 *arg++ = '\0';
999− else
1002+ tp->args[i].name = kstrdup(argv[i], GFP_KERNEL);
1003+ } else {
10001004 arg = argv[i];
1005+ /* If argument name is omitted, set "argN" */
1006+ snprintf(buf, MAX_EVENT_NAME_LEN, "arg%d", i + 1);
1007+ tp->args[i].name = kstrdup(buf, GFP_KERNEL);
1008+ }
10011009
1002− tp->args[i].name = kstrdup(argv[i], GFP_KERNEL);
10031010 if (!tp->args[i].name) {
1004− pr_info("Failed to allocate argument%d name '%s'.\n",
1005− i, argv[i]);
1011+ pr_info("Failed to allocate argument[%d] name.\n", i);
10061012 ret = -ENOMEM;
10071013 goto error;
10081014 }
1009− tmp = strchr(tp->args[i].name, ':');
1010− if (tmp)
1011− *tmp = '_'; /* convert : to _ */
1015+
1016+ if (!is_good_name(tp->args[i].name)) {
1017+ pr_info("Invalid argument[%d] name: %s\n",
1018+ i, tp->args[i].name);
1019+ ret = -EINVAL;
1020+ goto error;
1021+ }
10121022
10131023 if (conflict_field_name(tp->args[i].name, tp->args, i)) {
1014− pr_info("Argument%d name '%s' conflicts with "
1024+ pr_info("Argument[%d] name '%s' conflicts with "
10151025 "another field.\n", i, argv[i]);
10161026 ret = -EINVAL;
10171027 goto error;
@@ -1020,12 +1030,9 @@ static int create_trace_probe(int argc, char **argv) · 2 unmodified lines
10201030 /* Parse fetch argument */
10211031 ret = parse_probe_arg(arg, tp, &tp->args[i], is_return);
10221032 if (ret) {
1023− pr_info("Parse error at argument%d. (%d)\n", i, ret);
1024− kfree(tp->args[i].name);
1033+ pr_info("Parse error at argument[%d]. (%d)\n", i, ret);
10251034 goto error;
10261035 }
1027−
1028− tp->nr_args++;
10291036 }
10301037
10311038 ret = register_trace_probe(tp);
tools/perf/util/probe-event.c+1−0
@@ -1539,6 +1539,7 @@ static int convert_to_probe_trace_events(struct perf_probe_event *pev, · 1538 unmodified lines
15391539 goto error;
15401540 }
15411541 tev->point.offset = pev->point.offset;
1542+ tev->point.retprobe = pev->point.retprobe;
15421543 tev->nargs = pev->nargs;
15431544 if (tev->nargs) {
15441545 tev->args = zalloc(sizeof(struct probe_trace_arg)
tools/perf/util/probe-finder.c+29−13
@@ -686,6 +686,25 @@ static int find_variable(Dwarf_Die *sp_die, struct probe_finder *pf) · 685 unmodified lines
686686 char buf[32], *ptr;
687687 int ret, nscopes;
688688
689+ if (!is_c_varname(pf->pvar->var)) {
690+ /* Copy raw parameters */
691+ pf->tvar->value = strdup(pf->pvar->var);
692+ if (pf->tvar->value == NULL)
693+ return -ENOMEM;
694+ if (pf->pvar->type) {
695+ pf->tvar->type = strdup(pf->pvar->type);
696+ if (pf->tvar->type == NULL)
697+ return -ENOMEM;
698+ }
699+ if (pf->pvar->name) {
700+ pf->tvar->name = strdup(pf->pvar->name);
701+ if (pf->tvar->name == NULL)
702+ return -ENOMEM;
703+ } else
704+ pf->tvar->name = NULL;
705+ return 0;
706+ }
707+
689708 if (pf->pvar->name)
690709 pf->tvar->name = strdup(pf->pvar->name);
691710 else {
@@ -700,19 +719,6 @@ static int find_variable(Dwarf_Die *sp_die, struct probe_finder *pf) · 8 unmodified lines
700719 if (pf->tvar->name == NULL)
701720 return -ENOMEM;
702721
703− if (!is_c_varname(pf->pvar->var)) {
704− /* Copy raw parameters */
705− pf->tvar->value = strdup(pf->pvar->var);
706− if (pf->tvar->value == NULL)
707− return -ENOMEM;
708− if (pf->pvar->type) {
709− pf->tvar->type = strdup(pf->pvar->type);
710− if (pf->tvar->type == NULL)
711− return -ENOMEM;
712− }
713− return 0;
714− }
715−
716722 pr_debug("Searching '%s' variable in context.\n",
717723 pf->pvar->var);
718724 /* Search child die for local variables and parameters. */
@@ -783,6 +789,16 @@ static int convert_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf) · 64 unmodified lines
783789 /* This function has no name. */
784790 tev->point.offset = (unsigned long)pf->addr;
785791
792+ /* Return probe must be on the head of a subprogram */
793+ if (pf->pev->point.retprobe) {
794+ if (tev->point.offset != 0) {
795+ pr_warning("Return probe must be on the head of"
796+ " a real function\n");
797+ return -EINVAL;
798+ }
799+ tev->point.retprobe = true;
800+ }
801+
786802 pr_debug("Probe point found: %s+%lu\n", tev->point.symbol,
787803 tev->point.offset);
788804
tools/perf/util/symbol.c+7−0
@@ -2268,6 +2268,9 @@ static int setup_list(struct strlist **list, const char *list_str, · 2267 unmodified lines
22682268
22692269 int symbol__init(void)
22702270 {
2271+ if (symbol_conf.initialized)
2272+ return 0;
2273+
22712274 elf_version(EV_CURRENT);
22722275 if (symbol_conf.sort_by_name)
22732276 symbol_conf.priv_size += (sizeof(struct symbol_name_rb_node) -
@@ -2293,6 +2296,7 @@ int symbol__init(void) · 19 unmodified lines
22932296 symbol_conf.sym_list_str, "symbol") < 0)
22942297 goto out_free_comm_list;
22952298
2299+ symbol_conf.initialized = true;
22962300 return 0;
22972301
22982302 out_free_dso_list:
@@ -2304,11 +2308,14 @@ out_free_comm_list: · 5 unmodified lines
23042308
23052309 void symbol__exit(void)
23062310 {
2311+ if (!symbol_conf.initialized)
2312+ return;
23072313 strlist__delete(symbol_conf.sym_list);
23082314 strlist__delete(symbol_conf.dso_list);
23092315 strlist__delete(symbol_conf.comm_list);
23102316 vmlinux_path__exit();
23112317 symbol_conf.sym_list = symbol_conf.dso_list = symbol_conf.comm_list = NULL;
2318+ symbol_conf.initialized = false;
23122319 }
23132320
23142321 int machines__create_kernel_maps(struct rb_root *self, pid_t pid)
tools/perf/util/symbol.h+2−1
@@ -69,7 +69,8 @@ struct symbol_conf { · 68 unmodified lines
6969 show_nr_samples,
7070 use_callchain,
7171 exclude_other,
72− show_cpu_utilization;
72+ show_cpu_utilization,
73+ initialized;
7374 const char *vmlinux_name,
7475 *source_prefix,
7576 *field_sep;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t