RE: get_user_pages returns fewer pages than requested

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 26 oct 2007 18:44 Mulyadi Santosa [mailto:mulyadi.santosa@xxxxxxxxx]
wrote:
------------------------------------------------------------------------
------
Hi...

Allow me to share my thought here..
> As stated in LDD3 p.436 the function get_user_pages can return fewer 
> pages than requested (have already seen this during testing).
> Though I have not been able to find an explanation why it would do it,

> and how to act when it does.
>   
After checking the code, I think there are some reasons:
1. You're asking for pages more than the available free pages.
2. You exceed the current length of the VMA where the pages should
reside.
3. You exceed the maximum linear address of user space.

> The thing is that I also don't know what the 'user' should do if this 
> error occurs.
>
>   
Well, IMHO, user space code should bail out, or at least has backup plan
on what to do is the requested amount of memory can't be satisfied. 
AFAIK, -ENOMEM usually lead to program termination.

regards,

Mulyadi
------------------------------------------------------------------------
---------

Hi Mulyadi,

Thanks for your reply.
Few more questions though:

In 1. you stated that I might be asking more than the available free
pages; I'm currently testing on a RedHat enterpise WS4 x86_64 edition
(2.6.9-55) running on a HP xw9400 (Dual AMD Opteron with 4GB system
RAM). If I'm asking more than the available free pages, would that mean
I'm asking to lock (by means of get_user_pages) more than the still
available physical system RAM ?

I don't know how linux x86_64 handles the memory that is reserved for
the kernel.

With regards to 2. I don't know much about VMA's... But in my case I
don't have to handle any VMA's; I guess this is done internally.
This is what I currently do:
 - I get a virtual address to a buffer (+size) from user space
 - I get the pages list via get_user_pages
 - I than have dma_map_sg providing me the scatterlist for these pages,
which I will pass through to my hardware device
So during this I have no control over VMA's

In 3. exceeding the max linear address of user space would mean I try to
allocate a buffer that's bigger than 4GB ?

One more thing, it is quite hard to debug this issue, because it's hard
to reproduce it.
Would there be any way to log the state of the mem management if this
occurs ? Meaning, can I write an error handler that will log interesting
information about the mem managenment ?

Really appreciate your help,
Kind regards,
Tom


DISCLAIMER:
Unless indicated otherwise, the information contained in this message is privileged and confidential, and is intended only for the use of the addressee(s) named above and others who have been specifically authorized to receive it. If you are not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this message and/or attachments is strictly prohibited. The company accepts no liability for any damage caused by any virus transmitted by this email. Furthermore, the company does not warrant a proper and complete transmission of this information, nor does it accept liability for any delays. If you have received this message in error, please contact the sender and delete the message. Thank you.

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux