All of lore.kernel.org
 help / color / mirror / Atom feed
From: nikhil.subscribed@gmail.com (Nikhil Utane)
To: kernelnewbies@lists.kernelnewbies.org
Subject: memblock_reserve or memblock_remove to reserve a page
Date: Wed, 14 Sep 2016 12:47:42 +0530	[thread overview]
Message-ID: <CAGNWmJV3WFkVAuRttr471fP9vvvTNpf-p5Y66a9yuD6zrK7ztA@mail.gmail.com> (raw)
In-Reply-To: <CAHkaATQ_HeNCZBsA_yd2+vuZ6MOFnQieM9+yud7tbkj5HORgzg@mail.gmail.com>

Thank You MH Chen for your response.

So does that mean with memblock_reserve(), a kernel module can call
phys_to_virt(), create a linear mapping and modify that memory?
Where as with memblock_remove(), a kernel module can call ioremap() and
then modify the memory?

What would explain that only in some runs the memory is modified and in
some runs it is not (for both the functions)? Shouldn't this
reserved/removed memory never be modified unless someone is directly trying
to write to that specific page?

-Regards
Nikhil

On Sun, Sep 11, 2016 at 6:08 AM, Min-Hua Chen <orca.chen@gmail.com> wrote:

> Hi Nikhil,
>
> memblock_reserve() adds a given memory to the "memblock.reserved" list, it
> ends up to mark the given range of pages as "reserved". It means the pages
> are reserved and will not be allocated to other users. The kernel still can
> see the pages, create linear mappings on them, even access them by linear
> mappings.
>
> memblock_remove() removes a given memory from the "memblock.memory" list,
> it ends to removed from kernel's memory management system. The memory will
> not have page structure, no linear mapping on them. It prevents the memory
> from CPU accessing by the linear address. To access the memory (by CPU),
> you must use ioremap() to create a mapping to them.
>
>
> MH Chen
>
> On Fri, Sep 9, 2016 at 5:29 PM, Nikhil Utane <nikhil.subscribed@gmail.com>
> wrote:
>
>> Hi,
>>
>> I want to reserve a physical memory page with a fixed PFN. I do not want
>> this page to be used by anyone else. I am calling memblock_reserve() to
>> supposedly reserve the page. I am writing some content into this page. What
>> I see is that during some runs the content of this page is modified (either
>> fully or sometimes partially). In few runs, I see it as intact. Is it
>> expected that even after calling memblock_reserve() the kernel can allocate
>> this physical page for any other purpose? How is memblock_remove()
>> different from memblock_reserve? I tried reading up but didn't see any
>> useful information. What I understood is memblock_remove will completely
>> remove from kernel's allocation mechanism. Should I then be using remove
>> instead of reserve?
>>
>> -Thanks
>> Nikhil
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org
>> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160914/55d7f0c9/attachment.html 

  reply	other threads:[~2016-09-14  7:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-09  1:31 memblock_reserve or memblock_remove to reserve a page Nikhil Utane
2016-09-09  9:29 ` Nikhil Utane
2016-09-11  0:38   ` Min-Hua Chen
2016-09-14  7:17     ` Nikhil Utane [this message]
2016-09-15  0:05       ` Min-Hua Chen
2016-09-15  8:23         ` Nikhil Utane
2016-09-15 23:22           ` Min-Hua Chen
2016-09-16 10:08             ` Nikhil Utane
2016-09-27 10:44 ` Arun Sudhilal
2016-09-28  9:11   ` Nikhil Utane
2016-09-28  9:42     ` Arun Sudhilal
2016-09-28 13:25       ` Nikhil Utane
2016-09-29  5:55         ` Nikhil Utane
2016-10-03 12:32         ` Arun Sudhilal
2016-10-03 12:45           ` Arun Sudhilal
2016-10-04  5:40             ` Nikhil Utane

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=CAGNWmJV3WFkVAuRttr471fP9vvvTNpf-p5Y66a9yuD6zrK7ztA@mail.gmail.com \
    --to=nikhil.subscribed@gmail.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /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.