Received: by 10.213.65.68 with SMTP id h4csp3347124imn; Mon, 9 Apr 2018 19:40:25 -0700 (PDT) X-Google-Smtp-Source: AIpwx49vXIwuvlHHaBPh2CbF5Fo1N5dXfOJB1S3QJ7bAnW9+SbI0eszWFMgDRn+TSnyLewTrTS1B X-Received: by 2002:a17:902:820d:: with SMTP id x13-v6mr4149540pln.225.1523328025223; Mon, 09 Apr 2018 19:40:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523328025; cv=none; d=google.com; s=arc-20160816; b=J3i+qSX+tO8SEj+HVryJevYN4ehiJxZ8X/mpnFBl4PaZRBtU+JqeNguFtf1caBKDKn 6snPMqWzAFjwLZSFWp7VkMfCCMtW+6e8XE2c9dZOqnc3evjdZCrsWBMFRexl95NApdoM ptf9SeUJDJMEtnpvFVJqdn5ihJ9AcrbjOvauEH8nGWf1r6OY636t6fZgCa0vHBnoLUOh dJALB0UfFTIOivux53FQA7NLdqiWSiGt/XWoCtYgho5oEsP9oNct5dLN95nLtvGEw70I ohQJxyIa7jArf3aXM/wTy+n95+yYFdehPnCGaHgAvn150S05DTIZmzf7R5UBDKjm3sA7 tFvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=/vcgXPNOr1RYtjTav72a1/kg1Ks3d239ro3500J2Ex8=; b=bGBAQqOmbph0NFRCZ5U1ceSgAXYAY0QJSvFlMP5IkDovoMrLK193QqdHlF3oaScb75 1qAcZ9LYT1IusJ3+BXifSU/e1yoMjFPyB4nuPHobgOCIexdOe/b6AW9/N4E+7tR+LXoi 7JTbD9xWIe7WNVDAC299pGe6ERFHQ27qsRzj+gvgo+RhsVxhWaiBfBfSeQjxGpe5UGP9 08UFFAWebQzQeV6k1za0OUFSLH5pVPP7+OHKRTEPsMRYTbIJ9DnohgMrqa1Lkkrb2zIS nt82gUWim795nJQz6nR1Viq0uJcFerEIK/6XNQ0iEMvjiUJZcU+lbJgcY7DU0EqlQybi IDmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=RPgpmh0R; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t18si1230746pfh.60.2018.04.09.19.39.47; Mon, 09 Apr 2018 19:40:25 -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; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=RPgpmh0R; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752181AbeDJCeP (ORCPT + 99 others); Mon, 9 Apr 2018 22:34:15 -0400 Received: from mail-ot0-f193.google.com ([74.125.82.193]:46277 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752107AbeDJCeK (ORCPT ); Mon, 9 Apr 2018 22:34:10 -0400 Received: by mail-ot0-f193.google.com with SMTP id v64-v6so11036938otb.13 for ; Mon, 09 Apr 2018 19:34:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=/vcgXPNOr1RYtjTav72a1/kg1Ks3d239ro3500J2Ex8=; b=RPgpmh0RMXfnnhudDzhndS5QkwTtr1rmhn931pTf2AcKGSfetNNKLxIHF22ikoVe4M 88//4nAiMItJjk1RlfDf4TmLODj8ZIyBbA9TmWrn+q2pPXtdNeSBucMA0238UoNCu+B5 mcppkJqInUeecsBrWzFGO4tmgc76w9xIFMqfceA0bE0tg2de0cdQEEIzxbNB7QnVqXtm U3KhRvqDBkYmOHJ2KfhimEY6HkX5EsFgvjSOeOLSFa998CzcSqAYRilWuRYFaHMA2ST+ /z9GlQwZsHITAHzipdrBID3uFR0L9vrnCYO8y0ZaawQsXB9QuB27hXVhbfGbfiCzNFL+ vQvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=/vcgXPNOr1RYtjTav72a1/kg1Ks3d239ro3500J2Ex8=; b=BTWL2NOvxI6Pqr/zjE47wmx47fgXcptqmzHyvw9DHvTgBoUbckfEQNUv0I9y2znwUj xi2LXUxuHoXXpjjild2cR/LlJ1CxAg4qMlO6mTDZl2oybU7Vvo0lE9H0/8BuZ5mkrzdu hXVG4d7zSMWknb9TMfkSjD8lSSQpM0CV1WQc2OF9kl89vwPRMNtuzbIQuK9nd1yNnlWc efZDtqfQJGg6exOHwc1XFZi5ngofikPGuY3Ip2BCUXX9jKIxJIIIyK5Nj+fGOA04mR36 ZUAXvzptz2usr+jJmPd+Qmrk/x9vH9Dv8k14gRPuc+JPod3i7vhECNqCCNy1SDhXCWBy Zomw== X-Gm-Message-State: ALQs6tD9wrQOxDZLqa8HqfnrcEAztOh7z18u5yCusa00ir+XjyIcQQZg KO+f0ZhSQlkTK/iGjg/yd5J9kveZoJjlIXY9AQznSA== X-Received: by 2002:a9d:2129:: with SMTP id i38-v6mr26476926otb.210.1523327649952; Mon, 09 Apr 2018 19:34:09 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:2435:0:0:0:0:0 with HTTP; Mon, 9 Apr 2018 19:34:09 -0700 (PDT) In-Reply-To: <20180410021043.GC25724@localhost.localdomain> References: <20180408024724.16812-1-bhe@redhat.com> <20180408024724.16812-2-bhe@redhat.com> <20180409090853.GJ19345@localhost.localdomain> <20180410021043.GC25724@localhost.localdomain> From: Dan Williams Date: Mon, 9 Apr 2018 19:34:09 -0700 Message-ID: Subject: Re: [PATCH v3 1/3] resource: Use list_head to link resource sibling To: Baoquan He 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 , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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()