Received: by 10.213.65.68 with SMTP id h4csp2797442imn; Mon, 9 Apr 2018 09:10:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx49GmI766VowcmjgplZ8ejdBNXQz1FvLsgvDZ9usRG8+Uk8ruQdrd6BdLazKVyfro6533Jcy X-Received: by 10.167.132.132 with SMTP id u4mr11847872pfn.17.1523290221833; Mon, 09 Apr 2018 09:10:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523290221; cv=none; d=google.com; s=arc-20160816; b=Ul7aguc/33ePl+DD811IwsE3c4G/wdIk4ZJ1477dFlSgLkMIQ3vDohdkRixnYtGiAt IdODZgVbmAcVVWa4wo+QEsXNkU2ScHrMxfRxhfIR8djtNsD41IV22FyGD/WlHP0HXcYe hrsXp3lVW0juy2tWJlx81vnhNxXrbgBeRSe3XgsxcTVNja7opHhYtsIFzYoyvi/O+4KA fRgyp3+jevjGryhwjGB9sVQOfJZnr7uwYO88mTVLAn+v46lQGdehvRnFMD9Z67qOFvpW KsTRtCAF3rK5eRfNvrEoq6RcEofl/DNpGOEx3XQ2Qg7+HxKwyzekgDYvwQ2+FL2UsTAW 51Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=kFfKibOQdYOJ+7K1iZml0zCfOvHJuqCHB/xxvDLfbYY=; b=XIs0OJLjsNd4eB+gx7khLZNJDiUMJWzK/Thz+jW3EOTyQ6uG8wPYw5cOy8ZXkpKG0y qRlRUosHQYs0H33p1EFNtGACvIsUaOkYZ2cYbs3/AufhXnl4ugc/ABGd4wR0L9EEGBiU Ldw5zuRiShvcBGhQST0SG3+M9tayo14k147VuAPfwg2z1dH7fomxLYBU2bcCZXQVL3p6 ZqDIUOg7rek9OFRecLIC4MTobbgnF4HCcywL/JSzDtYm6WfYQZisD9eHYR5DRFjer4iV qTnjk/H4Tu0UbLYRkMSNkJq9xrXN2doJlaSN3jsgLQy/G/JTKqXtHyefN/XGkFyOxwV6 71Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TRgzcmb8; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 92-v6si539441plw.229.2018.04.09.09.09.44; Mon, 09 Apr 2018 09:10:21 -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=@linaro.org header.s=google header.b=TRgzcmb8; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753332AbeDIQF0 (ORCPT + 99 others); Mon, 9 Apr 2018 12:05:26 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:42616 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752799AbeDIQFX (ORCPT ); Mon, 9 Apr 2018 12:05:23 -0400 Received: by mail-qk0-f194.google.com with SMTP id b198so9866146qkg.9 for ; Mon, 09 Apr 2018 09:05:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=kFfKibOQdYOJ+7K1iZml0zCfOvHJuqCHB/xxvDLfbYY=; b=TRgzcmb8apvfwk2g0EgXs4lQinNqC4YxmDHqwVFI4z1icolfXPlYzyzIfPc5zaleFJ +KabT+xs1xcYC1rul2/s/CpNkil7ggmi9gvwhZMKb7vxAAmkEnzCzUVa50QiqQvNMHhP jGBLi6dHzpGkghge4sEFgP3o4yFhxE2STU0aA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=kFfKibOQdYOJ+7K1iZml0zCfOvHJuqCHB/xxvDLfbYY=; b=swwAqBiNTazmo+DL1W2n4AVNl8dN+PAfDZScEc0O1VMXxeIMnhgd3lbFv4+IEtznoz cy32M6IL8StTU192/ZCgzKkNevOSCHH5ueWohuWttwC2iYRkMq5IBOtxSPB6J4Z+uGSn G6speQGghF6OFQ4V8sS5Wf/bz9z/mSlZrkmOS7/XQISCiNj/6uEoPQHy7ccuoTDBPFFC 1jEDGGRiaeQx9hDRrXaoCsko8aHmWzhZEEgGJhvEpxgNvtoqHcKhk1CfGzXS6gGU/yuj gUyYhNd2wcgBHBfH5EIXuHIsgE23Hi8ybe8iVmhhZPOAj3Sf0S1zgcuU5ngCfLtjVXJ/ K9Lg== X-Gm-Message-State: ALQs6tDmpPPgspvHNCIKHLcCNLnbZ72domRjN3o3lgMEhRmI3ejgA/Md SzGwYztgMIwrDxoseAjMUJI3fA== X-Received: by 10.55.54.212 with SMTP id d203mr51280744qka.200.1523289922938; Mon, 09 Apr 2018 09:05:22 -0700 (PDT) Received: from xanadu.home (modemcable228.104-82-70.mc.videotron.ca. [70.82.104.228]) by smtp.gmail.com with ESMTPSA id q100sm522160qkh.43.2018.04.09.09.05.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Apr 2018 09:05:22 -0700 (PDT) Date: Mon, 9 Apr 2018 12:05:20 -0400 (EDT) From: Nicolas Pitre To: Rob Herring cc: Baoquan He , "linux-kernel@vger.kernel.org" , Patrik Jakobsson , David Airlie , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Dmitry Torokhov , Dan Williams , Frank Rowand , Keith Busch , Jonathan Derrick , Lorenzo Pieralisi , Bjorn Helgaas , Thomas Gleixner , Brijesh Singh , =?ISO-8859-15?Q?J=E9r=F4me_Glisse?= , Borislav Petkov , Tom Lendacky , Greg Kroah-Hartman , Yaowei Bai , Wei Yang , devel@linuxdriverproject.org, linux-input@vger.kernel.org, linux-nvdimm@lists.01.org, devicetree@vger.kernel.org, linux-pci@vger.kernel.org Subject: Re: [PATCH v3 1/3] resource: Use list_head to link resource sibling In-Reply-To: Message-ID: References: <20180408024724.16812-1-bhe@redhat.com> <20180408024724.16812-2-bhe@redhat.com> <20180409090853.GJ19345@localhost.localdomain> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 9 Apr 2018, Rob Herring wrote: > +Nico who has been working on tinification of the kernel. > > On Mon, Apr 9, 2018 at 4: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. > > Why is reverse iteration needed? > > > And code refactoring makes codes in kernel/resource.c more readable than > > pointer operation. > > resource_for_each_* helpers could solve that without the size increase. > > > 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. > > The DT struct device_node also has the same tree structure with > parent, child, sibling pointers and converting to list_head had been > on the todo list for a while. ACPI also has some tree walking > functions (drivers/acpi/acpica/pstree.c). Perhaps there should be a > common tree struct and helpers defined either on top of list_head or a > new struct if that saves some size. > > > > > Signed-off-by: Baoquan He > > --- > > v2->v3: > > Make sibling() and first_child() global so that they can be called > > out of kernel/resource.c to simplify code. > > These should probably be inline functions. Or exported if not. > > > > > Fix several code bugs found by kbuild test robot. > > > > Got report from lkp that kernel size increased. It's on purpose since > > the type change of sibling and child inside struct resource{}. For > > each struct resource variable, it will cost another 16 bytes on x86 64. > > The size increase should be mentioned in the commit log. More > generally, the size increase is 2 pointers. Tiny kernels have much fewer resources anyway, and usually run on platforms with 32-bit pointers, so this probably won't matter much in the end. This is if reverse iteration is actually needed as you say though. Unless I'm mistaken, resource iteration doesn't happen that often, and not in critical paths either. Making the code clearer while keeping the same structure size could be considered with the help of llist.h instead. Nicolas