Re: [PATCH v7 1/3] trace: Make removal of ring buffer pages atomic

From: Steven Rostedt
Date: Tue May 08 2012 - 23:38:38 EST


On Thu, 2012-05-03 at 18:59 -0700, Vaibhav Nagarnaik wrote:

> + get_online_cpus();
> + /*
> + * Fire off all the required work handlers
> + * Look out for offline CPUs
> + */
> + for_each_buffer_cpu(buffer, cpu) {
> + cpu_buffer = buffer->buffers[cpu];
> + if (!cpu_buffer->nr_pages_to_update ||
> + !cpu_online(cpu))
> + continue;
> +
> + schedule_work_on(cpu, &cpu_buffer->update_pages_work);
> + }
> + /*
> + * This loop is for the CPUs that are not online.
> + * We can't schedule anything on them, but it's not necessary
> + * since we can change their buffer sizes without any race.
> + */
> + for_each_buffer_cpu(buffer, cpu) {
> + cpu_buffer = buffer->buffers[cpu];
> + if (!cpu_buffer->nr_pages_to_update ||
> + cpu_online(cpu))
> + continue;
> +
> + rb_update_pages(cpu_buffer);
> }

BTW, why the two loops and not just:

for_each_buffer_cpu(buffer, cpu) {
cpu_buffer = buffer->buffers[cpu];
if (!cpu_buffer->nr_pages_to_update)
continue;

if (cpu_online(cpu))
schedule_work_on(cpu, &cpu_buffer->update_pages_work);
else
rb_update_pages(cpu_buffer);
}

??


>
> /* wait for all the updates to complete */
> for_each_buffer_cpu(buffer, cpu) {
> cpu_buffer = buffer->buffers[cpu];
> - if (cpu_buffer->nr_pages_to_update) {
> - update_pages_handler(cpu_buffer);
> - }
> + if (!cpu_buffer->nr_pages_to_update||

!cpu_buffer->nr_pages_to_update ||

-- Steve

> + !cpu_online(cpu))
> + continue;
> +
> + wait_for_completion(&cpu_buffer->update_completion);
> + /* reset this value */
> + cpu_buffer->nr_pages_to_update = 0;
> }


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