On Tue, Apr 10, 2018 at 09:44:16PM +0800, Baoquan He wrote:
>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 <b...@redhat.com> 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:
>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
>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.
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
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
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.
Help you, Help me