From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751669AbdBMFO1 (ORCPT ); Mon, 13 Feb 2017 00:14:27 -0500 Received: from LGEAMRELO11.lge.com ([156.147.23.51]:45360 "EHLO lgeamrelo11.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751023AbdBMFO0 (ORCPT ); Mon, 13 Feb 2017 00:14:26 -0500 X-Original-SENDERIP: 156.147.1.126 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 10.177.222.33 X-Original-MAILFROM: byungchul.park@lge.com Date: Mon, 13 Feb 2017 14:14:03 +0900 From: Byungchul Park To: NeilBrown Cc: peterz@infradead.org, mingo@kernel.org, koverstreet@google.com, neilb@suse.de, nab@linux-iscsi.org, viro@zeniv.linux.org.uk, ying.huang@intel.com, oleg@redhat.com, asias@redhat.com, shli@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] llist: Don't reinvent the wheel but use existing llist API Message-ID: <20170213051403.GH16086@X58A-UD3R> References: <1486959013-26105-1-git-send-email-byungchul.park@lge.com> <87r3324rkn.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87r3324rkn.fsf@notabene.neil.brown.name> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 13, 2017 at 03:56:08PM +1100, NeilBrown wrote: > On Mon, Feb 13 2017, Byungchul Park wrote: > > > Although llist provides proper APIs, they are not used. Make them used. > > > > Signed-off-by: Byungchul Park > > --- > > drivers/md/bcache/closure.c | 15 ++------------- > > drivers/md/raid5.c | 4 +--- > > drivers/vhost/scsi.c | 9 ++------- > > fs/file_table.c | 12 +++++------- > > fs/namespace.c | 12 +++++------- > > include/linux/llist.h | 3 +++ > > kernel/irq_work.c | 6 +----- > > kernel/sched/core.c | 13 ++----------- > > mm/vmalloc.c | 8 +++----- > > 9 files changed, 24 insertions(+), 58 deletions(-) > > > ... > > > diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c > > index 36c13e4..c82243a 100644 > > --- a/drivers/md/raid5.c > > +++ b/drivers/md/raid5.c > > @@ -359,11 +359,9 @@ static int release_stripe_list(struct r5conf *conf, > > > > head = llist_del_all(&conf->released_stripes); > > head = llist_reverse_order(head); > > - while (head) { > > + llist_for_each_entry(sh, head, release_list) { > > int hash; > > > > - sh = llist_entry(head, struct stripe_head, release_list); > > - head = llist_next(head); > > /* sh could be readded after STRIPE_ON_RELEASE_LIST is cleard */ > > smp_mb(); > > clear_bit(STRIPE_ON_RELEASE_LIST, &sh->state); > > This one is wrong (I haven't checked the rest). > As soon a STRIPE_ON_RELEASE_LIST is cleared, the llist_node can be > reused, so we need to call llist_next *before* the rest of the code. > You have moved the call to afterwards. > > You could possibly change it to use llist_for_each_entry_safe() Yes right. I also found that I should have used the safe version. :( Thank you very much. > > NeilBrown