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, 31 Mar 2015 08:32:37 -0600
From:	David Ahern <dsahern@...il.com>
To:	Yunlong Song <yunlong.song@...wei.com>, a.p.zijlstra@...llo.nl,
	paulus@...ba.org, mingo@...hat.com, acme@...nel.org
CC:	linux-kernel@...r.kernel.org, wangnan0@...wei.com
Subject: Re: [PATCH 3/9] perf sched replay: Alloc the memory of pid_to_task
 dynamically to adapt to the unexpected change of pid_max

On 3/31/15 7:46 AM, Yunlong Song wrote:
> diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> index c466104..20d887b 100644
> --- a/tools/perf/builtin-sched.c
> +++ b/tools/perf/builtin-sched.c
> @@ -23,6 +23,7 @@
>   #include <semaphore.h>
>   #include <pthread.h>
>   #include <math.h>
> +#include <api/fs/fs.h>
>
>   #define PR_SET_NAME		15               /* Set process name */
>   #define MAX_CPUS		4096
> @@ -124,7 +125,7 @@ struct perf_sched {
>   	struct perf_tool tool;
>   	const char	 *sort_order;
>   	unsigned long	 nr_tasks;
> -	struct task_desc *pid_to_task[MAX_PID];
> +	struct task_desc **pid_to_task;
>   	struct task_desc **tasks;
>   	const struct trace_sched_handler *tp_handler;
>   	pthread_mutex_t	 start_work_mutex;
> @@ -326,8 +327,14 @@ static struct task_desc *register_pid(struct perf_sched *sched,
>   				      unsigned long pid, const char *comm)
>   {
>   	struct task_desc *task;
> +	static int pid_max;
>
> -	BUG_ON(pid >= MAX_PID);
> +	if (sched->pid_to_task == NULL) {
> +		if (sysctl__read_int("kernel/pid_max", &pid_max) < 0)
> +			pid_max = MAX_PID;
> +		BUG_ON((sched->pid_to_task = calloc(pid_max, sizeof(struct task_desc *))) == NULL);
> +	}
> +	BUG_ON(pid >= (unsigned long)pid_max);
>

so why the previous patch bumping the MAX_PID count if you move to 
dynamic here? And shouldn't MAX_PID get dropped here as well?

So attached is what i put together last week; just have not had time to 
send it out.

View attachment "0003-perf-sched-Remove-max-pid-assumption-from-perf-sched.patch" of type "text/plain" (3771 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ