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, 01 Dec 2015 01:23:01 +0200
From:	Alexander Shishkin <alexander.shishkin@...ux.intel.com>
To:	Mathieu Poirier <mathieu.poirier@...aro.org>,
	gregkh@...uxfoundation.org
Cc:	zhang.chunyan@...aro.org, mike.leach@....com, tor@...com,
	al.grant@....com, pawel.moll@....com, fainelli@...adcom.com,
	linux-arm-kernel@...ts.infradead.org, linux-doc@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Mathieu Poirier <mathieu.poirier@...aro.org>
Subject: Re: [PATCH V5 21/26] coresight: etm-perf: new PMU driver for ETM tracers

Mathieu Poirier <mathieu.poirier@...aro.org> writes:

> +static void etm_event_destroy(struct perf_event *event) {}
> +
> +static int etm_event_init(struct perf_event *event)
> +{
> +	if (event->attr.type != etm_pmu.type)
> +		return -ENOENT;
> +
> +	if (event->cpu >= nr_cpu_ids)
> +		return -EINVAL;
> +
> +	event->destroy = etm_event_destroy;

You don't have to do this if it's a nop, event::destroy can be NULL.

> +
> +	return 0;
> +}


> +static void *alloc_event_data(int cpu)
> +{
> +	int lcpu, size;
> +	cpumask_t *mask;
> +	struct etm_cpu_data *cpu_data;
> +	struct etm_event_data *event_data;
> +
> +	/* First get memory for the session's data */
> +	event_data = kzalloc(sizeof(struct etm_event_data), GFP_KERNEL);
> +	 if (!event_data)

Looks like a whitespace mixup.

> +		return NULL;
> +
> +	/* Make sure nothing disappears under us */
> +	get_online_cpus();
> +	size = num_online_cpus();
> +
> +	mask = &event_data->mask;
> +	if (cpu != -1)
> +		cpumask_set_cpu(cpu, mask);
> +	else
> +		cpumask_copy(mask, cpu_online_mask);

It would be nice to have a comment somewhere here explaining that you
have to set up tracer on each cpu in case of per-thread counter and
why. We must have discussed this, but I forgot already.

Btw, do you want to also set 'size' to 1 for cpu != -1 case?

> +	put_online_cpus();
> +
> +	/* Allocate an array of cpu_data to work with */
> +	event_data->cpu_data = kcalloc(size,
> +				       sizeof(struct etm_cpu_data *),
> +				       GFP_KERNEL);
> +	if (!event_data->cpu_data)
> +		goto free_event_data;
> +
> +	/* Allocate a cpu_data for each CPU this event is dealing with */
> +	for_each_cpu(lcpu, mask) {
> +		cpu_data = kzalloc(sizeof(struct etm_cpu_data), GFP_KERNEL);
> +		if (!cpu_data)
> +			goto free_event_data;
> +
> +		event_data->cpu_data[lcpu] = cpu_data;
> +	}

Wouldn't it be easier to allocate the whole thing with one

event_data->cpu_data = kcalloc(size, sizeof(struct etm_cpu_data), GFP_KERNEL);

?

Regards,
--
Alex
--
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