From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753093AbbJZSCf (ORCPT ); Mon, 26 Oct 2015 14:02:35 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:35997 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752500AbbJZSCd (ORCPT ); Mon, 26 Oct 2015 14:02:33 -0400 Date: Mon, 26 Oct 2015 19:02:27 +0100 From: Ingo Molnar To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, dvhart@linux.intel.com, fweisbec@gmail.com, oleg@redhat.com, bobby.prani@gmail.com, Patrick Marlier , Linus Torvalds Subject: Re: [PATCH tip/core/rcu 11/13] rculist: Make list_entry_rcu() use lockless_dereference() Message-ID: <20151026180226.GA9276@gmail.com> References: <20151006161305.GA9799@linux.vnet.ibm.com> <1444148028-11551-1-git-send-email-paulmck@linux.vnet.ibm.com> <1444148028-11551-11-git-send-email-paulmck@linux.vnet.ibm.com> <20151026084506.GA28423@gmail.com> <20151026145552.GG5105@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151026145552.GG5105@linux.vnet.ibm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Paul E. McKenney wrote: > > It's this new usage in fs/fs-writeback.c: > > > > static void bdi_split_work_to_wbs(struct backing_dev_info *bdi, > > struct wb_writeback_work *base_work, > > bool skip_if_busy) > > { > > struct bdi_writeback *last_wb = NULL; > > struct bdi_writeback *wb = list_entry_rcu(&bdi->wb_list, > > I believe that the above should instead be: > > struct bdi_writeback *wb = list_entry_rcu(bdi->wb_list.next, > > After all, RCU read-side list primitives need to fetch pointers in order to > traverse those pointers in an RCU-safe manner. The patch below clears this up > for me, does it also work for you? Are you sure about that? I considered this solution too, but the code goes like this: static void bdi_split_work_to_wbs(struct backing_dev_info *bdi, struct wb_writeback_work *base_work, bool skip_if_busy) { struct bdi_writeback *last_wb = NULL; struct bdi_writeback *wb = list_entry_rcu(&bdi->wb_list, struct bdi_writeback, bdi_node); might_sleep(); restart: rcu_read_lock(); list_for_each_entry_continue_rcu(wb, &bdi->wb_list, bdi_node) { and list_for_each_entry_continue_rcu() will start the iteration with the next entry. So if you initialize the head with .next, then we'll start with .next->next, i.e. we skip the first entry. That seems to change behavior and break the logic. Another solution I considered is to use bd->wb_list.next->prev, but that, beyond being ugly, causes actual extra runtime overhead - for something that seems academical. Thanks, Ingo