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]
Date:	Tue, 15 Jul 2014 14:33:01 +0300
From:	Adrian Hunter <adrian.hunter@...el.com>
To:	Arnaldo Carvalho de Melo <acme@...nel.org>
CC:	Peter Zijlstra <peterz@...radead.org>,
	linux-kernel@...r.kernel.org, David Ahern <dsahern@...il.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Jiri Olsa <jolsa@...hat.com>,
	Namhyung Kim <namhyung@...il.com>,
	Paul Mackerras <paulus@...ba.org>,
	Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH 02/41] perf tools: Fix map groups of threads with unknown
 pids

On 07/14/2014 11:18 PM, Arnaldo Carvalho de Melo wrote:
> Em Mon, Jul 14, 2014 at 01:02:26PM +0300, Adrian Hunter escreveu:
>> Events like sched_switch do not provide a pid (tgid)
>> which can result in threads with an unknown pid.  If
>> the pid is later discovered, join the map groups.
>> Note the thread's map groups should be empty because
>> they are populated by MMAP events which do provide the
>> pid and tid.
>>
>> Signed-off-by: Adrian Hunter <adrian.hunter@...el.com>
>> ---
>>  tools/perf/util/machine.c | 22 ++++++++++++++++------
>>  tools/perf/util/map.c     | 14 ++++++++++++++
>>  tools/perf/util/map.h     |  1 +
>>  tools/perf/util/thread.c  | 35 +++++++++++++++++++++++++++++++++++
>>  tools/perf/util/thread.h  |  1 +
>>  5 files changed, 67 insertions(+), 6 deletions(-)
>>
>> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
>> index 5b80877..0fa93c1 100644
>> --- a/tools/perf/util/machine.c
>> +++ b/tools/perf/util/machine.c
>> @@ -272,6 +272,17 @@ void machines__set_id_hdr_size(struct machines *machines, u16 id_hdr_size)
>>  	return;
>>  }
>>  
>> +static void machine__update_thread_pid(struct machine *machine,
>> +				       struct thread *th, pid_t pid)
>> +{
>> +	if (pid != th->pid_ && pid != -1 && th->pid_ == -1) {
>> +		th->pid_ = pid;
>> +		if (thread__join_map_groups(th, machine))
>> +			pr_err("Failed to join map groups for %d:%d\n",
>> +			       th->pid_, th->tid);
>> +	}
>> +}
>> +
> 
> I think you should combine the above function with
> thread__join_map_groups, and I think that the method belongs to the
> 'machine' class, see below for further comments on this...
> 
>> diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
>> index 7a32f44..ca94295 100644
>> --- a/tools/perf/util/thread.c
>> +++ b/tools/perf/util/thread.c
>> @@ -24,6 +24,41 @@ int thread__init_map_groups(struct thread *thread, struct machine *machine)
>>  	return thread->mg ? 0 : -1;
>>  }
>>  
>> +int thread__join_map_groups(struct thread *thread, struct machine *machine)
>> +{
>> +	struct thread *leader;
>> +	pid_t pid = thread->pid_;
>> +
>> +	if (pid == thread->tid)
>> +		return 0;
>> +
>> +	leader = machine__findnew_thread(machine, pid, pid);
>> +	if (!leader)
>> +		return -ENOMEM;
>> +
>> +	if (!leader->mg)
>> +		leader->mg = map_groups__new();
>> +
>> +	if (!leader->mg)
>> +		return -ENOMEM;
>> +
>> +	if (thread->mg) {
>> +		/*
>> +		 * Maps are created from MMAP events which provide the pid and
>> +		 * tid.  Consequently there never should be any maps on a thread
>> +		 * with an unknown pid.  Just print an error if there are.
>> +		 */
>> +		if (!map_groups__empty(thread->mg))
>> +			pr_err("Discarding thread maps for %d:%d\n",
>> +			       thread->pid_, thread->tid);
> 
> Because there is nothing in this function (thread__join_map_groups),
> checking if it is operating on a thread that has an unknown pid.
> 
> So, please consider merging this and its sole caller,
> machine__update_thread_pid, so that the test is in the same function as
> the assumption that it is operating on a thread with an unknown pid.

You have it in your tree now.  Do you want another patch
to do that?

--
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