Received: by 10.213.65.68 with SMTP id h4csp3355477imn; Mon, 9 Apr 2018 19:52:39 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+/+Is7d529lIE7Aan6uAKw9pHHqnNxb0h4BclUaQPXmivUy8AUXBWEggvMuYLTkp8KUX3R X-Received: by 10.167.128.81 with SMTP id y17mr1196878pfm.194.1523328759588; Mon, 09 Apr 2018 19:52:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523328759; cv=none; d=google.com; s=arc-20160816; b=uRt4iZBeJz2QqFKbdA8+ORm5rG6Q5U/nFDBAPmLG3Ra8ReX5LB2i/ptn0A+UJqfN/Q RsbeREP/A1zHSfTWPhkGgSbj0kYX2ZPq1GtHRnS15vY6HfGMJIlcweKmFdbFL78oP10O T2163R0LI75pfHpYFwXUlyOqshQKQcnXr/Y4dFK3F1djVYd8hiNTEnEJxNWTdNtyO1ye 6+SOYq9kEu6/hV75fa6t874Up82Te8F50GBgqSD3nNXxAzkrTiM7JEQ3rcvIRZvCqykq duzsntqvoDwRASwajZfyldj+Xuu6pA47dWCtNkmezeXoSrqkN33TFpaunWhkyJadc6HL lO3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=jQjqplmy4/zNff8ptgNSAAfBquB2VP1xyxxmVLuoUQI=; b=BGAqeVO10P+PqwdmmC54qdjnDUJX5W7sCQYTqmXMkR3FyncvcCLa782BAzzGyp7WSz F0hht5Okr3Qv6Tn4ZgIOg0kpb6y+JFkRQmQficPPgJRkwkuYm81ko8Fpvr5S2EEO8AwQ fIzxLYvyFwIxmYelwFUfuSyBYFXnxNz7ZQNhcgPFAR9WyYSS7zpzBvKE3+hQC926mABe 1XfFbQ/G+dd9kOhuERvtB53CgcFR3UciJib5ewu3YU7rDmiCQJ4NWeALh76OQinblACY 4k5a4TJAO9E7Q0WVESOuigsaQvSw6qqCX+OvKGHGb+wjF7T7BNdWpIlx4WuOD3a8/Xn0 osDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id be4-v6si1663112plb.201.2018.04.09.19.52.02; Mon, 09 Apr 2018 19:52:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752064AbeDJCt1 (ORCPT + 99 others); Mon, 9 Apr 2018 22:49:27 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:59584 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751886AbeDJCtZ (ORCPT ); Mon, 9 Apr 2018 22:49:25 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D1DD74068050; Tue, 10 Apr 2018 02:49:24 +0000 (UTC) Received: from localhost (ovpn-8-16.pek2.redhat.com [10.72.8.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9C3012166BAE; Tue, 10 Apr 2018 02:49:23 +0000 (UTC) Date: Tue, 10 Apr 2018 10:49:20 +0800 From: Baoquan He To: Dan Williams Cc: Linux Kernel Mailing List , Patrik Jakobsson , David Airlie , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Dmitry Torokhov , Rob Herring , Frank Rowand , Keith Busch , Jonathan Derrick , Lorenzo Pieralisi , Bjorn Helgaas , Thomas Gleixner , Brijesh Singh , =?iso-8859-1?B?Suly9G1l?= Glisse , Borislav Petkov , Tom Lendacky , Greg Kroah-Hartman , Yaowei Bai , Wei Yang , devel@linuxdriverproject.org, linux-input@vger.kernel.org, linux-nvdimm , Device Tree , linux-pci@vger.kernel.org Subject: Re: [PATCH v3 1/3] resource: Use list_head to link resource sibling Message-ID: <20180410024920.GL19345@localhost.localdomain> References: <20180408024724.16812-1-bhe@redhat.com> <20180408024724.16812-2-bhe@redhat.com> <20180409090853.GJ19345@localhost.localdomain> <20180410021043.GC25724@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 10 Apr 2018 02:49:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 10 Apr 2018 02:49:25 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'bhe@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/09/18 at 07:34pm, Dan Williams wrote: > On Mon, Apr 9, 2018 at 7:10 PM, Baoquan He wrote: > > On 04/09/18 at 08:38am, Dan Williams wrote: > >> On Mon, Apr 9, 2018 at 2:08 AM, Baoquan He wrote: > >> > The struct resource uses singly linked list to link siblings. It's not > >> > easy to do reverse iteration on sibling list. So replace it with list_head. > >> > > >> > And code refactoring makes codes in kernel/resource.c more readable than > >> > pointer operation. > >> > > >> > Besides, type of member variables of struct resource, sibling and child, are > >> > changed from 'struct resource *' to 'struct list_head'. Kernel size will > >> > increase because of those statically defined struct resource instances. > >> > > >> > Signed-off-by: Baoquan He > >> > --- > >> [..] > >> > diff --git a/kernel/resource.c b/kernel/resource.c > >> > index e270b5048988..473c624606f9 100644 > >> > --- a/kernel/resource.c > >> > +++ b/kernel/resource.c > >> > @@ -31,6 +31,8 @@ struct resource ioport_resource = { > >> > .start = 0, > >> > .end = IO_SPACE_LIMIT, > >> > .flags = IORESOURCE_IO, > >> > + .sibling = LIST_HEAD_INIT(ioport_resource.sibling), > >> > + .child = LIST_HEAD_INIT(ioport_resource.child), > >> > }; > >> > EXPORT_SYMBOL(ioport_resource); > >> > > >> > @@ -39,6 +41,8 @@ struct resource iomem_resource = { > >> > .start = 0, > >> > .end = -1, > >> > .flags = IORESOURCE_MEM, > >> > + .sibling = LIST_HEAD_INIT(iomem_resource.sibling), > >> > + .child = LIST_HEAD_INIT(iomem_resource.child), > >> > }; > >> > EXPORT_SYMBOL(iomem_resource); > >> > > >> > @@ -57,20 +61,32 @@ static DEFINE_RWLOCK(resource_lock); > >> > * by boot mem after the system is up. So for reusing the resource entry > >> > * we need to remember the resource. > >> > */ > >> > -static struct resource *bootmem_resource_free; > >> > +static struct list_head bootmem_resource_free = LIST_HEAD_INIT(bootmem_resource_free); > >> > static DEFINE_SPINLOCK(bootmem_resource_lock); > >> > > >> > +struct resource *sibling(struct resource *res) > >> > +{ > >> > + if (res->parent && !list_is_last(&res->sibling, &res->parent->child)) > >> > + return list_next_entry(res, sibling); > >> > + return NULL; > >> > +} > >> > + > >> > +struct resource *first_child(struct list_head *head) > >> > +{ > >> > + return list_first_entry_or_null(head, struct resource, sibling); > >> > +} > >> > + > >> > >> These names are too generic for new global symbols. A "resource_" > >> prefix is warranted. > > > > Thanks, sounds reasonable, will change them as resource_sibling() and > > resource_first_child(). Or res_sibling()/res_1st_child()? > > > > resource_sibling() and resource_first_child() OK, will change, thanks.