Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753893AbbERNxX (ORCPT ); Mon, 18 May 2015 09:53:23 -0400 Received: from mail-la0-f53.google.com ([209.85.215.53]:33188 "EHLO mail-la0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752382AbbERNxN (ORCPT ); Mon, 18 May 2015 09:53:13 -0400 MIME-Version: 1.0 In-Reply-To: <20150518120647.0c3cecd8@notabene.brown> References: <20150512224603.GA4531@linux.vnet.ibm.com> <1431470787-4702-1-git-send-email-paulmck@linux.vnet.ibm.com> <1431470787-4702-3-git-send-email-paulmck@linux.vnet.ibm.com> <20150512223853.55e0ed90@grimm.local.home> <20150513125839.371ef677@notabene.brown> <5557819E.1060001@gmail.com> <20150518120647.0c3cecd8@notabene.brown> Date: Mon, 18 May 2015 15:53:12 +0200 Message-ID: Subject: Re: [PATCH tip/core/rcu 3/4] md/bitmap: Fix list_entry_rcu usage From: Patrick Marlier To: NeilBrown Cc: Steven Rostedt , "Paul E. McKenney" , linux-kernel@vger.kernel.org, mingo@kernel.org, laijs@cn.fujitsu.com, dipankar@in.ibm.com, akpm@linux-foundation.org, Mathieu Desnoyers , Josh Triplett , tglx@linutronix.de, peterz@infradead.org, dhowells@redhat.com, Eric Dumazet , dvhart@linux.intel.com, =?UTF-8?B?RnLDqWTDqXJpYyBXZWlzYmVja2Vy?= , oleg@redhat.com, pranith kumar , wangyun@linux.vnet.ibm.com Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2746 Lines: 76 On Mon, May 18, 2015 at 4:06 AM, NeilBrown wrote: > On Sat, 16 May 2015 19:42:54 +0200 Patrick Marlier > wrote: >> On 05/13/2015 04:58 AM, NeilBrown wrote: >> > On Tue, 12 May 2015 22:38:53 -0400 Steven Rostedt wrote: >> >> On Tue, 12 May 2015 15:46:26 -0700 >> >> "Paul E. McKenney" wrote: >> >> What comes after this is: >> >> >> >> list_for_each_entry_continue_rcu(rdev, &mddev->disks, same_set) { >> >> if (rdev->raid_disk >= 0 && >> >> >> >> Now the original code had: >> >> >> >> rdev = list_entry_rcu(&mddev->disks, struct md_rdev, same_set); >> >> >> >> Where &mddev->disks would return the address of the disks field of >> >> mddev which is a list head. Then it would get the 'same_set' offset, >> >> which is 0, and rdev is pointing to a makeshift md_rdev struct. But it >> >> isn't used, as the list_for_each_entry_continue_rcu() has: >> >> >> >> #define list_for_each_entry_continue_rcu(pos, head, member) \ >> >> for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \ >> >> &pos->member != (head); \ >> >> pos = list_entry_rcu(pos->member.next, typeof(*pos), member)) >> >> >> >> Thus the first use of pos is pos->member.next or: >> >> >> >> mddev->disks.next >> >> >> >> But now you converted it to rdev = mddev->disks.next, which means the >> >> first use is: >> >> >> >> pos = mddev->disks.next->next >> >> >> >> I think you are skipping the first element here. >> >> >> struct mddev { >> ... >> struct list_head disks; >> ...} >> >> struct list_head { >> struct list_head *next, *prev; >> }; >> >> The tricky thing is that "list_entry_rcu" before and after the patch is >> reading the same thing. > > No it isn't. > Before the patch it is passed the address of the 'next' field. After the > patch it is passed the contents of the 'next' field. Here I meant "list_entry_rcu" (in include/linux/rculist.h) not the change to drivers/md/bitmap.c. >> However in your case, the change I proposed is probably wrong I trust >> you on this side. :) What's your proposal to fix it with the rculist patch? > > What needs fixing? I don't see anything broken. > > Maybe there is something in this "rculist patch" that I'm missing. Can you > point me at it? Do not apply the patch on drivers/md/bitmap.c but only on include/linux/rculist.h and you will see that the compilation fails. -- Pat -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/