Page 1 of 1

Policy for Locking Pages in Memory

Posted: Thu Dec 20, 2012 7:26 am
by Whitebird
Hello everyone!

I have some questions regarding the policy for locking pages in memory.

1) Should I assign to each process a constant maximum number pages that it can pin in memory or should it be done dynamically?
2) If the number of pinned pages should change dynamically for each process, how can I control that?


Thank you,

White

Re: Policy for Locking Pages in Memory

Posted: Thu Dec 20, 2012 8:06 am
by bluemoon
It depends on your design.

By the way, an OS may limit the maximum memory can be allocated per user (or per process); and allocate them dynamically (on demand).
Whitebird wrote:2) If the number of pinned pages should change dynamically for each process, how can I control that?
You know when a page is allocated (syscall or page fault), and you can do some kind of bookkeeping.

Re: Policy for Locking Pages in Memory

Posted: Thu Dec 20, 2012 9:50 am
by Whitebird
Thanks for answering me bluemoon.

I was aware that an OS should dynamically change the number of frames allocated per processor per-user by load control, probably using PFF as reference. But, I'm not sure if I can apply that for page locking.

For the moment, I assign to each process a constant number of pages that it can pin in memory. What do you think about this approach?

Cheers,

White

Re: Policy for Locking Pages in Memory

Posted: Thu Dec 20, 2012 10:10 am
by bluemoon
It's a matter of policy.

However, IMO, the ability to control / pin some memory (and avoid it being swapped) may impact the system, and should not be abused.
Furthermore, normal application should / would have no idea on the overall system workload and stress, so they could not help in any case by providing hints on memory usage - they usually make it worst.

That leave the only useful case for drivers, that require special treatment on memory (eg. non-swappable buffers, or things that impact performance if swapped); in such cases you may as well provide special API for such allocation.