* How do you comprehend the saying that the kernel's memory is not pageable whereas get_free_page use a page-oriented technique?
@ 2020-06-20 6:18 孙世龙 sunshilong
2020-06-20 9:11 ` Valdis Klētnieks
0 siblings, 1 reply; 3+ messages in thread
From: 孙世龙 sunshilong @ 2020-06-20 6:18 UTC (permalink / raw)
To: Kernelnewbies
[-- Attachment #1.1: Type: text/plain, Size: 1314 bytes --]
As per the documentation( https://www.linuxjournal.com/article/6930 ),
which says[emphasis mine]:
Unfortunately for kernel developers, allocating memory in the kernel
is not as simple as allocating memory in userspace. A number of
factors contribute to the complication, among them:
The kernel is limited to about 1GB of virtual and physical memory.
**The kernel's memory is not pageable.**
As per the documentation(https://www.oreilly.com
<https://www.oreilly.com/library/view/linux-device-drivers/0596005903/ch08.html>
/library/view/linux-device-drivers/0596005903/ch08.html
<https://www.oreilly.com/library/view/linux-device-drivers/0596005903/ch08.html>
),
which says:
get_free_page and Friends
If a module needs to allocate big chunks of memory, it is usually
better to use a page-oriented technique.
I am confused after I have seen these two sayings.
I think they have the opposite meaning:
the former one clams that the kernel's memory is not pageable
whereas the latter one implicitly states there is a page-oriented
technique used by the kernel(i.e. function get_free_page
depends a page-oriented technique).
I have thought and thought about it for a long time, but I still don't
comprehend them.I would be grateful to have some help with this
question.
Thank you for your attention to this matter.
[-- Attachment #1.2: Type: text/html, Size: 1715 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How do you comprehend the saying that the kernel's memory is not pageable whereas get_free_page use a page-oriented technique?
2020-06-20 6:18 How do you comprehend the saying that the kernel's memory is not pageable whereas get_free_page use a page-oriented technique? 孙世龙 sunshilong
@ 2020-06-20 9:11 ` Valdis Klētnieks
2020-06-20 9:39 ` 孙世龙 sunshilong
0 siblings, 1 reply; 3+ messages in thread
From: Valdis Klētnieks @ 2020-06-20 9:11 UTC (permalink / raw)
To: 孙世龙 sunshilong; +Cc: Kernelnewbies
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1: Type: text/plain; charset=us-ascii, Size: 797 bytes --]
On Sat, 20 Jun 2020 14:18:21 +0800, 孙世龙 sunshilong said:
> Unfortunately for kernel developers, allocating memory in the kernel
> is not as simple as allocating memory in userspace. A number of
> factors contribute to the complication, among them:
> The kernel is limited to about 1GB of virtual and physical memory.
> **The kernel's memory is not pageable.**
> If a module needs to allocate big chunks of memory, it is usually
> better to use a page-oriented technique.
Due to memory fragmentation, if a module needs (say) 2M of
memory for an I/O buffer, it's more likely to be able to allocate
512 4K pages scattered through the 1GB of memory than it
is to get 1 contiguous chunk of memory.
The fact it's not pageable doesn't mean that pages aren't relevant
as the unit of allocation.
[-- Attachment #1.2: Type: application/pgp-signature, Size: 832 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How do you comprehend the saying that the kernel's memory is not pageable whereas get_free_page use a page-oriented technique?
2020-06-20 9:11 ` Valdis Klētnieks
@ 2020-06-20 9:39 ` 孙世龙 sunshilong
0 siblings, 0 replies; 3+ messages in thread
From: 孙世龙 sunshilong @ 2020-06-20 9:39 UTC (permalink / raw)
To: Valdis Klētnieks; +Cc: Kernelnewbies
[-- Attachment #1.1: Type: text/plain, Size: 2296 bytes --]
>> Unfortunately for kernel developers, allocating memory in the kernel
>> is not as simple as allocating memory in userspace. A number of
>> factors contribute to the complication, among them:
>> The kernel is limited to about 1GB of virtual and physical memory.
>> **The kernel's memory is not pageable.**
>
>> If a module needs to allocate big chunks of memory, it is usually
>> better to use a page-oriented technique.
>
>Due to memory fragmentation, if a module needs (say) 2M of
>memory for an I/O buffer, it's more likely to be able to allocate
>512 4K pages scattered through the 1GB of memory than it
>is to get 1 contiguous chunk of memory.
>
>The fact it's not pageable doesn't mean that pages aren't relevant
>as the unit of allocation.
Thank you for your help.
For the saying that the kernel's memory is not pageable, I think the
word "pageable" should be understood in this way:
Linux keeps the whole kernel in physical memory at all the times and no
such memory would be temporarily moved to swap even if it is not currently
in use.
Am I right?
If my understanding is right, one more question raises, what about the
memory related to the user processes, e.g. process control block?
Can it be swapped out?
Thank you for your attention to this matter.
Look forward to hearing from you.
Valdis Klētnieks <valdis.kletnieks@vt.edu> 于2020年6月20日周六 下午5:11写道:
> On Sat, 20 Jun 2020 14:18:21 +0800, 孙世龙 sunshilong said:
>
> > Unfortunately for kernel developers, allocating memory in the kernel
> > is not as simple as allocating memory in userspace. A number of
> > factors contribute to the complication, among them:
> > The kernel is limited to about 1GB of virtual and physical memory.
> > **The kernel's memory is not pageable.**
>
> > If a module needs to allocate big chunks of memory, it is usually
> > better to use a page-oriented technique.
>
> Due to memory fragmentation, if a module needs (say) 2M of
> memory for an I/O buffer, it's more likely to be able to allocate
> 512 4K pages scattered through the 1GB of memory than it
> is to get 1 contiguous chunk of memory.
>
> The fact it's not pageable doesn't mean that pages aren't relevant
> as the unit of allocation.
>
[-- Attachment #1.2: Type: text/html, Size: 2857 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-20 9:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-20 6:18 How do you comprehend the saying that the kernel's memory is not pageable whereas get_free_page use a page-oriented technique? 孙世龙 sunshilong
2020-06-20 9:11 ` Valdis Klētnieks
2020-06-20 9:39 ` 孙世龙 sunshilong
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.