linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
To: Toshi Kani <toshi.kani@hp.com>
Cc: akpm@linux-foundation.org, linuxram@us.ibm.com,
	rientjes@google.com, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org
Subject: Re: [Bug fix PATCH v4] Reusing a resource structure allocated by bootmem
Date: Tue, 23 Apr 2013 09:19:09 +0900	[thread overview]
Message-ID: <5175D37D.2070100@jp.fujitsu.com> (raw)
In-Reply-To: <1366381837.3824.71.camel@misato.fc.hp.com>

2013/04/19 23:30, Toshi Kani wrote:
> On Fri, 2013-04-19 at 17:09 +0900, Yasuaki Ishimatsu wrote:
>> Hi Toshi,
>>
>> 2013/04/19 8:33, Yasuaki Ishimatsu wrote:
>>> Hi Toshi,
>>>
>>> 2013/04/18 23:23, Toshi Kani wrote:
>>>> On Thu, 2013-04-18 at 17:36 +0900, Yasuaki Ishimatsu wrote:
>>>>> When hot removing memory presented at boot time, following messages are shown:
>>>>    :
>>>>> diff --git a/kernel/resource.c b/kernel/resource.c
>>>>> index 4aef886..637e8d2 100644
>>>>> --- a/kernel/resource.c
>>>>> +++ b/kernel/resource.c
>>>>> @@ -21,6 +21,7 @@
>>>>>    #include <linux/seq_file.h>
>>>>>    #include <linux/device.h>
>>>>>    #include <linux/pfn.h>
>>>>> +#include <linux/mm.h>
>>>>>    #include <asm/io.h>
>>>>>
>>>>>
>>>>> @@ -50,6 +51,16 @@ struct resource_constraint {
>>>>>
>>>>>    static DEFINE_RWLOCK(resource_lock);
>>>>>
>>>>> +/*
>>>>> + * For memory hotplug, there is no way to free resource entries allocated
>>>>> + * by boot mem after the system is up. So for reusing the resource entry
>>>>> + * we need to remember the resource.
>>>>> + */
>>>>> +struct resource bootmem_resource = {
>>>>> +    .sibling = NULL,
>>>>> +};
>>>>
>>>
>>
>>>> This should be a pointer of struct resource and declared as static, such
>>>> as:
>>>>
>>>> static struct resource *bootmem_resource_free;
>>>
>>> O.K. I'll update it.
>>
>> Oh, I missed "should be pointer of struct resource" part.
>> Please teach me your detailed idea. If this is defined as pointer,
>> how do we initialize this and manage bootmem resources?
>>
>> I'm thinking it but have no idea.
>

> Sure.  It's quite simple.  Since only bootmem_resource.sibling is used,
> it can be replaced with a pointer, such as bootmem_resource_free.  This
> avoids allocating a struct resource table as this code is supposed to
> save memory.
>
> So, first, declare the pointer below, which is initialized to NULL as
> BSS (checkpatch.pl complains if you set it to NULL explicitly).
>
>    static struct resource *bootmem_resource_free;
>
> Then, in free_resource(), this pointer replaces bootmem_resource.sibling
> as follows.
>
>    res->sibling = bootmem_resource_free;
>    bootmem_resource_free = res;
>
> Similarly, in get_resource().
>
>    if (bootmem_resource_free) {
>        res = bootmem_resource_free;
>        bootmem_resource_free = res->sibling;
>    }

Thank you for your detail explanation. I clearly understood your idea.
I'll update your comment and post a updated patch.

Thanks,
Yasuaki Ishimatsu

>
>
> Thanks,
> -Toshi
>


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      reply	other threads:[~2013-04-23  0:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-18  8:36 [Bug fix PATCH v4] Reusing a resource structure allocated by bootmem Yasuaki Ishimatsu
2013-04-18 13:42 ` Johannes Weiner
2013-04-18 23:21   ` Yasuaki Ishimatsu
2013-04-18 14:23 ` Toshi Kani
2013-04-18 23:33   ` Yasuaki Ishimatsu
2013-04-18 23:28     ` Toshi Kani
2013-04-18 23:43       ` Yasuaki Ishimatsu
2013-04-19  8:09     ` Yasuaki Ishimatsu
2013-04-19 14:30       ` Toshi Kani
2013-04-23  0:19         ` Yasuaki Ishimatsu [this message]

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=5175D37D.2070100@jp.fujitsu.com \
    --to=isimatu.yasuaki@jp.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxram@us.ibm.com \
    --cc=rientjes@google.com \
    --cc=toshi.kani@hp.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).