All of lore.kernel.org
 help / color / mirror / Atom feed
From: Baoquan He <bhe@redhat.com>
To: Borislav Petkov <bp@suse.de>
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	robh+dt@kernel.org, dan.j.williams@intel.com,
	nicolas.pitre@linaro.org, josh@joshtriplett.org,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Brijesh Singh" <brijesh.singh@amd.com>,
	"Jérôme Glisse" <jglisse@redhat.com>,
	"Tom Lendacky" <thomas.lendacky@amd.com>,
	"Wei Yang" <richard.weiyang@gmail.com>
Subject: Re: [PATCH v3 2/3] resource: add walk_system_ram_res_rev()
Date: Thu, 26 Apr 2018 16:56:49 +0800	[thread overview]
Message-ID: <20180426085649.GC18395@localhost.localdomain> (raw)
In-Reply-To: <20180419100745.GC3896@pd.tnic>

Sorry to all reviewers, I had a redhat urgent issue, this patchset
discussing is delayed.

On 04/19/18 at 12:07pm, Borislav Petkov wrote:
> On Thu, Apr 19, 2018 at 08:18:47AM +0800, Baoquan He wrote:
> > This function, being a variant of walk_system_ram_res() introduced in
> > commit 8c86e70acead ("resource: provide new functions to walk through
> > resources"), walks through a list of all the resources of System RAM
> > in reversed order, i.e., from higher to lower.
> > 
> > It will be used in kexec_file code.
> 
> Of course, what is missing is the big *WHY* you need this to happen this
> way...

Sorry for that, I just ran scripts/get_maintainer.pl to get expert's
name and added them into each patch. The reason this change is made is
in patch 3/3. Test robot reported a code bug on the latest kernel, will
repost and CC everyone in all patches.


Rob Herring asked the same question in v2, I explained to him. The
discussion can be found here:
https://lkml.org/lkml/2018/4/10/484

> 
> >  /*
> > + * This function, being a variant of walk_system_ram_res(), calls the @func
> > + * callback against all memory ranges of type System RAM which are marked as
> > + * IORESOURCE_SYSTEM_RAM and IORESOUCE_BUSY in reversed order, i.e., from
> > + * higher to lower.
> > + */
> > +int walk_system_ram_res_rev(u64 start, u64 end, void *arg,
> > +				int (*func)(struct resource *, void *))
> > +{
> > +	unsigned long flags;
> > +	struct resource *res;
> > +	int ret = -1;
> > +
> > +	flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
> > +
> > +	read_lock(&resource_lock);
> > +	list_for_each_entry_reverse(res, &iomem_resource.child, sibling) {
> 
> ... and the other thing that I'm not clear on is why are you
> slapping this function just like that instead of extending
> __walk_iomem_res_desc() to do reverse direction too?

Yes, I planned to do as you said when started to write code. After investigation,
I changed to use the way of this patch. Because __walk_iomem_res_desc()
provides two interfaces by calling find_next_iomem_res(). If
'first_level_children_only' is true, it only iterates system RAM
resource; if 'first_level_children_only' is false, it does depth first
iteration in iomem_resource. The 1st interface is only used by
walk_system_ram_res() and walk_mem_res(). While the 2nd interface need
call find_next_iomem_res() which resorts to next_resource().
next_resource() will check 'sibling_only' to decide if iterate
iomem_resource's children, or walk over all resources of iomem_resource
with depth first. For walk_system_ram_res_rev(), we only need to iterate
iomem_resource's children, and seems no one has requirement to
iterate all iomem_resource's children and grand children
revresedly. For simplifying code implementation, I just did as in this
patch, surely, if any suggestion or scenario given about the reversed
iteration of all resources, I can change to add below functions, and
based on them to implement walk_system_ram_res_rev().

walk_system_ram_res_rev
	->__walk_iomem_res_desc_rev
		->find_next_iomem_res_rev
			->next_resource_rev

Thanks
Baoquan


> 
> SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
> -- 

  reply	other threads:[~2018-04-26  8:57 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-19  0:18 [PATCH v3 0/3] resource: Use list_head to link sibling resource Baoquan He
2018-04-19  0:18 ` [PATCH v3 1/3] " Baoquan He
2018-04-19  0:18   ` Baoquan He
2018-04-19  0:18   ` Baoquan He
2018-04-19  0:18   ` Baoquan He
2018-04-26  1:18   ` Wei Yang
2018-04-26  1:18     ` Wei Yang
2018-04-26  1:18     ` Wei Yang
2018-04-26  1:18     ` Wei Yang
2018-05-07  1:14     ` Baoquan He
2018-05-07  1:14       ` Baoquan He
2018-05-07  1:14       ` Baoquan He
2018-05-07  1:14       ` Baoquan He
2018-05-08 11:48       ` Wei Yang
2018-05-08 11:48         ` Wei Yang
2018-05-08 11:48         ` Wei Yang
2018-05-08 11:48         ` Wei Yang
2018-05-08 12:11         ` Baoquan He
2018-05-08 12:11           ` Baoquan He
2018-05-08 12:11           ` Baoquan He
2018-05-08 23:41           ` Wei Yang
2018-05-08 23:41             ` Wei Yang
2018-05-08 23:41             ` Wei Yang
2018-05-08 23:41             ` Wei Yang
2018-04-26  3:01   ` kbuild test robot
2018-04-26  3:01     ` kbuild test robot
2018-04-26  3:01     ` kbuild test robot
2018-05-06  6:31     ` Baoquan He
2018-05-06  6:31       ` Baoquan He
2018-05-06  6:31       ` Baoquan He
2018-05-06  6:31       ` Baoquan He
2018-04-26  3:23   ` kbuild test robot
2018-04-26  3:23     ` kbuild test robot
2018-04-26  3:23     ` kbuild test robot
2018-05-06  6:30     ` Baoquan He
2018-05-06  6:30       ` Baoquan He
2018-05-06  6:30       ` Baoquan He
2018-05-06  6:30       ` Baoquan He
2018-04-19  0:18 ` [PATCH v3 2/3] resource: add walk_system_ram_res_rev() Baoquan He
2018-04-19 10:07   ` Borislav Petkov
2018-04-26  8:56     ` Baoquan He [this message]
2018-04-26 11:09       ` Borislav Petkov
2018-04-26 13:22         ` Baoquan He
2018-05-04 10:16           ` Borislav Petkov
2018-05-06  6:19             ` Baoquan He
2018-04-19  0:18 ` [PATCH v3 3/3] kexec_file: Load kernel at top of system RAM if required Baoquan He
2018-04-19  0:18   ` Baoquan He

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180426085649.GC18395@localhost.localdomain \
    --to=bhe@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@suse.de \
    --cc=brijesh.singh@amd.com \
    --cc=dan.j.williams@intel.com \
    --cc=jglisse@redhat.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.pitre@linaro.org \
    --cc=richard.weiyang@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.