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] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.00.0905261510080.26705@gandalf.stny.rr.com>
Date:	Tue, 26 May 2009 15:14:30 -0400 (EDT)
From:	Steven Rostedt <rostedt@...dmis.org>
To:	Xiao Guangrong <xiaoguangrong@...fujitsu.com>
cc:	mingo@...e.hu, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] ring_buffer: use list_replace() in
 rb_get_reader_page()


On Mon, 25 May 2009, Xiao Guangrong wrote:

> Use list_replace() to splice list in rb_get_reader_page()

This code is very sensitive to change. But I think you actually uncovered 
a potential bug. There was a reason that I did not use list_replace, and 
it is because we need memory barriers here. And that is the bug you 
uncovered. We don't have memory barriers.

Ah, it's not a bug (yet). When we make this lockless we will need to add 
memory barriers here. Once reader->list.prev->next points to 
cpu_buffer->reader_page->list, the cpu_buffer->reader_page->list had 
better have both next and prev visible.

If we add this code now, we will just have to remove it when it goes 
lockless.

-- Steve



> 
> [ Impact: cleanup ]
> 
> Signed-off-by: Xiao Guangrong <xiaoguangrong@...fujitsu.com>
> ---
>  kernel/trace/ring_buffer.c |   12 ++----------
>  1 files changed, 2 insertions(+), 10 deletions(-)
> 
> diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> index f558b37..f88bfcc 100644
> --- a/kernel/trace/ring_buffer.c
> +++ b/kernel/trace/ring_buffer.c
> @@ -2179,22 +2179,14 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
>  	if (cpu_buffer->commit_page == cpu_buffer->reader_page)
>  		goto out;
>  
> -	/*
> -	 * Splice the empty reader page into the list around the head.
> -	 * Reset the reader page to size zero.
> -	 */
> -
> +	/* Reset the reader page to size zero */
>  	reader = cpu_buffer->head_page;
> -	cpu_buffer->reader_page->list.next = reader->list.next;
> -	cpu_buffer->reader_page->list.prev = reader->list.prev;
> -
>  	local_set(&cpu_buffer->reader_page->write, 0);
>  	local_set(&cpu_buffer->reader_page->entries, 0);
>  	local_set(&cpu_buffer->reader_page->page->commit, 0);
>  
>  	/* Make the reader page now replace the head */
> -	reader->list.prev->next = &cpu_buffer->reader_page->list;
> -	reader->list.next->prev = &cpu_buffer->reader_page->list;
> +	list_replace(&reader->list, &cpu_buffer->reader_page->list);
>  
>  	/*
>  	 * If the tail is on the reader, then we must set the head
> -- 
> 1.6.1.2
> 
> 
> 
--
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