lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120825114746.GA28832@somewhere.redhat.com>
Date:	Sat, 25 Aug 2012 13:47:49 +0200
From:	Frederic Weisbecker <fweisbec@...il.com>
To:	Andrew Vagin <avagin@...nvz.org>
Cc:	linux-kernel@...r.kernel.org,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Paul Mackerras <paulus@...ba.org>,
	Ingo Molnar <mingo@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...stprotocols.net>
Subject: Re: [PATCH 3/4] perf: teach perf inject to merge sched_stat_* and
 sched_switch events (v2)

On Tue, Aug 07, 2012 at 04:56:04PM +0400, Andrew Vagin wrote:
> +struct event_entry {
> +	struct list_head node;
> +	u32		 pid;
> +	union perf_event event[0];
> +};
> +
> +static LIST_HEAD(samples);
> +
> +static int perf_event__sched_stat(struct perf_tool *tool,
> +				      union perf_event *event,
> +				      struct perf_sample *sample,
> +				      struct perf_evsel *evsel,
> +				      struct machine *machine)
> +{
> +	const char *evname = NULL;
> +	uint32_t size;
> +	struct event_entry *ent;
> +	union perf_event *event_sw = NULL;
> +	struct perf_sample sample_sw;
> +	int sched_process_exit;
> +
> +	size = event->header.size;
> +
> +	evname = evsel->tp_format->name;
> +
> +	sched_process_exit = !strcmp(evname, "sched_process_exit");
> +
> +	if (!strcmp(evname, "sched_switch") ||  sched_process_exit) {
> +		list_for_each_entry(ent, &samples, node)
> +			if (sample->pid == ent->pid)

I suspect what you're rather interested in is the sample tid.

> +				break;
> +
> +		if (&ent->node != &samples) {
> +			list_del(&ent->node);
> +			free(ent);
> +		}
> +
> +		if (sched_process_exit)
> +			return 0;
> +
> +		ent = malloc(size + sizeof(struct event_entry));
> +		if (ent == NULL)
> +			die("malloc");
> +		ent->pid = sample->pid;

Ditto.

> +		memcpy(&ent->event, event, size);
> +		list_add(&ent->node, &samples);
> +		return 0;
> +
> +	} else if (!strncmp(evname, "sched_stat_", 11)) {
> +		u32 pid;
> +
> +		pid = raw_field_value(evsel->tp_format,
> +					"pid", sample->raw_data);

There you parse the pid from the trace content. That's fine because
it's actually the tid that is saved on the trace event. But this one
is not pid-namespace safe (it saves current->pid directly) while
sample->tid is pid-namespace safe (it uses task_pid_nr_ns).

So I suggest you to use sample->tid instead, plus that's going to be
consistant with what you did above.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ