Received: by 10.192.165.156 with SMTP id m28csp228050imm; Tue, 10 Apr 2018 20:25:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx48VSboPqvH1UrhxUZtqrxJQnuf9GpJxGzkIdWUK5I77LlJ9RiQ/ImgTiMv/D6j00hGa2NdL X-Received: by 2002:a17:902:2803:: with SMTP id e3-v6mr3102741plb.156.1523417157878; Tue, 10 Apr 2018 20:25:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523417157; cv=none; d=google.com; s=arc-20160816; b=knK7TNV8BgEdZHHlJlHodJkzSNbwZfIsN/Nr969ZXHz7Q0oNo4LFiSmH3EMA88xmMG lThzxWb58m30eckLCIi6jPW8Yn4mNc41mM2+WCLOxL21yFzZ5c3AG0lHrVj1vbnpFe3G R97H7+SKXWUqzeOdySEHIla9X9LR6IxiK43F4dLQVA23j7uNPK3AR6lt34gZEKLwk7JS noILana1UjgoXl7WfwR/zbITL6ci/g63ioPRDkorZqGXGqlvMMVmFE2AXO7RtZ1YECGB Lzi4ntxZkSuq93MxlgpXxxDdo4vp2N4gc4E7fEi7jJ22UyeSLn8kiKr1YWOkFL9qNlb2 7TFw== 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:reply-to:message-id :subject:cc:to:from:date:dkim-signature:arc-authentication-results; bh=l7/cu8mUK59YuBjY6vg5vJfjc1bdWwQCLrYEaEyETXU=; b=LdX+B3LekwUuICtxwEngSSUAiQMgAoRWHc7eoyGeSXSSuccnbfTNdIy+8MEhm5zb7U mLsiF/PDTj84XrGnaorewzl+Sv54MOpoF/jbjFC6+oACEkSFP5NRl0+17VR14gvOaOTb gsDqvU7HPE3ooKR+lNsa8Nx85h05d62ArZKHwKpL7jgT3nr8ZjNz7wXyjP4eSsoLukT/ pG4E+l4pKdRIkGzQ1FihcBz+BAxUKCqihvNs16OvXldDBUYgooYj8hpPcxI8v2M6n2UW ZawGVxXWXb0MaKyiP69ahm8SPXbS9/oPNyoANGjydaxjvVpeVNI0Jb6OaI6Q6E2DaO1f Pxjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DY5mGoXm; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 134si114668pgd.709.2018.04.10.20.25.18; Tue, 10 Apr 2018 20:25:57 -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=@gmail.com header.s=20161025 header.b=DY5mGoXm; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752693AbeDKDWb (ORCPT + 99 others); Tue, 10 Apr 2018 23:22:31 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:35249 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752366AbeDKDW2 (ORCPT ); Tue, 10 Apr 2018 23:22:28 -0400 Received: by mail-pf0-f195.google.com with SMTP id u86so273109pfd.2; Tue, 10 Apr 2018 20:22:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:reply-to:references:mime-version :content-disposition:in-reply-to:user-agent; bh=l7/cu8mUK59YuBjY6vg5vJfjc1bdWwQCLrYEaEyETXU=; b=DY5mGoXmJ7MckA+v8VJdLccYOsnP1/SBY5x99xcYuXgJ2805NKqcCLWZ2f0VyOLWHL oHQCVQs3AHUA3Ts130PCesj4oQw9nM+Y9Vf8FhIZQWccPPG5U1H5W96hAE55hZD/HYK/ JhF0+9sPuxLINJhLasL5HPh4273ntFO4PiIwk/CrTlvjKeENiHX/PF223bL8z4PyWVFw tTxiOgK0OmOj/oewpuy/8JD2DRNXvQOItU2JSZyn/mwZe9uemdgn9by2T5r7Ll4R5mDU PzFaD0b9pzLQvtWq5NxF3S/smJwPLThtsQ+Bivb+y3ltO2aBjP5Y0d9ZnqAdszx95/F9 L4Fw== 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:message-id:reply-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=l7/cu8mUK59YuBjY6vg5vJfjc1bdWwQCLrYEaEyETXU=; b=KU2gIjJaPKOFsCJYoMID3buxTcQJdQTW/awqBKL6lESn/F5XwN5yWRlgMhtrnJt5Qt E/SB2fqKGNQjei8gpkhjSyWyGa4n1hLWkSF/3yGpJmNqlK/ie5/Jk0Is+TX5zR2vEXcN G7QV6zPGi73rbH+dtzi7zsGBgVUg5kXqT4IETwRgAA9lrvHwtFil1zNN8D0PtDjTM2RA DvisLADxg6d6/ke1onCYYEnBQrYEkQ2p5yjKMu0SckeSL3la+XdeOB8NdZtTMleN5Doa bKCduohuizD7mRxgx5F7HrOIOq5aY+VfROo9IdmGyrFd0yif4KkiaUxSxd5SxmLYQcsn bfrw== X-Gm-Message-State: ALQs6tAo4GwUsz1VQrU9NwFnI+lP09nQcpqJy6RCbUjvVZFex14lg+l/ coaa1UtED9I4930WaoxGWZk= X-Received: by 10.99.152.68 with SMTP id l4mr2087253pgo.75.1523416947849; Tue, 10 Apr 2018 20:22:27 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id c186sm284830pfb.40.2018.04.10.20.22.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Apr 2018 20:22:27 -0700 (PDT) Date: Wed, 11 Apr 2018 11:22:20 +0800 From: Wei Yang To: Baoquan He Cc: Rob Herring , Nicolas Pitre , "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-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@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 Message-ID: <20180411032220.GA49071@WeideMacBook-Pro.local> Reply-To: Wei Yang References: <20180408024724.16812-1-bhe@redhat.com> <20180408024724.16812-2-bhe@redhat.com> <20180409090853.GJ19345@localhost.localdomain> <20180410134416.GM19345@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180410134416.GM19345@localhost.localdomain> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 10, 2018 at 09:44:16PM +0800, Baoquan He wrote: >Hi Rob, > >Thanks a lot for looking into this and involve Nico to this thread! > >On 04/09/18 at 09:49am, 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? > >This is the explanation I made when Andrew helped to review the v1 post: >https://lkml.org/lkml/2018/3/23/78 > >Because we have been using kexec-tools utility to search available >System RAM space for loading kernel/initrd/purgatory from top to down. >That is done in user space by searching /proc/iomem. While later added >kexec_file interface, the searching code happened in kernel, and it >only search System RAM region bottom up, then take an area in that found >RAM region from top to down. We need unify these two interfaces on >behaviour since they are the same on essense from the users' point of >view, though implementation is different. As you know, the singly linked >list implementation of the current resource's sibling linking, makes the >searching from top to down very hard to satisfy people. > >Below is the v1 post, we make an temporary array to copy iomem_resource's >first level of children, then iterate the array reversedly. Andrew >suggested me to try list_head after reviewing. In fact we can optimize >that patch to only copy resource pointer into array, still the way is >ugly. >https://lkml.org/lkml/2018/3/21/952 > >Then Wei pasted a patch he had made as below. He didn't mention if he >also has requirement on reversed iteration of resource. That is an O(n*n) >way, from personal feelings, hard to say if it's bettern than v1 post. >https://lkml.org/lkml/2018/3/24/157 I don't have requirement on reverse iteration of resource structure. My approach is almost the same as current walk_system_ram_res(). Since each resource keeps parent, we could get previous resource by search on res->parent->child. The complexity of a whole iteration is O(N * W / 2), where N is the number of resources in the tree and W is the average number of siblings of each resource. And this approach doesn't need to change current structure. > >That's why I would like to have a try of the list_head linking. > -- Wei Yang Help you, Help me