How many page table the linux kernel maintains?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












0















the kernel maintains a data structure, called a page table, that contains a mapping of
a processes' virtual page addresses to real page addresses in memory.




I read a book with the sentence above, I don't know why it's a processes'? So the kernel

has a single page table which contains mappings for many processes, i.e. kernel didn't store those page tables for all processes separately, but in a single page table?



The book is How Linux Works by Brian Ward, 2nd, page 182, line 4.




It seems like the book has some grammar errors:




  1. table, that should be table that: no error. (thanks for the comment!)


  2. a mapping of a processes' should be a mapping of a process's









share|improve this question



















  • 2




    “... a data structure, called a page table, that ...” is correct: “that” refers to “a data structure”.
    – Stephen Kitt
    Dec 11 at 20:57










  • @StephenKitt: That makes sense, thank you!
    – ptr_user7813604
    Dec 11 at 21:11















0















the kernel maintains a data structure, called a page table, that contains a mapping of
a processes' virtual page addresses to real page addresses in memory.




I read a book with the sentence above, I don't know why it's a processes'? So the kernel

has a single page table which contains mappings for many processes, i.e. kernel didn't store those page tables for all processes separately, but in a single page table?



The book is How Linux Works by Brian Ward, 2nd, page 182, line 4.




It seems like the book has some grammar errors:




  1. table, that should be table that: no error. (thanks for the comment!)


  2. a mapping of a processes' should be a mapping of a process's









share|improve this question



















  • 2




    “... a data structure, called a page table, that ...” is correct: “that” refers to “a data structure”.
    – Stephen Kitt
    Dec 11 at 20:57










  • @StephenKitt: That makes sense, thank you!
    – ptr_user7813604
    Dec 11 at 21:11













0












0








0








the kernel maintains a data structure, called a page table, that contains a mapping of
a processes' virtual page addresses to real page addresses in memory.




I read a book with the sentence above, I don't know why it's a processes'? So the kernel

has a single page table which contains mappings for many processes, i.e. kernel didn't store those page tables for all processes separately, but in a single page table?



The book is How Linux Works by Brian Ward, 2nd, page 182, line 4.




It seems like the book has some grammar errors:




  1. table, that should be table that: no error. (thanks for the comment!)


  2. a mapping of a processes' should be a mapping of a process's









share|improve this question
















the kernel maintains a data structure, called a page table, that contains a mapping of
a processes' virtual page addresses to real page addresses in memory.




I read a book with the sentence above, I don't know why it's a processes'? So the kernel

has a single page table which contains mappings for many processes, i.e. kernel didn't store those page tables for all processes separately, but in a single page table?



The book is How Linux Works by Brian Ward, 2nd, page 182, line 4.




It seems like the book has some grammar errors:




  1. table, that should be table that: no error. (thanks for the comment!)


  2. a mapping of a processes' should be a mapping of a process's






linux linux-kernel






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 11 at 21:12

























asked Dec 11 at 19:39









ptr_user7813604

1186




1186







  • 2




    “... a data structure, called a page table, that ...” is correct: “that” refers to “a data structure”.
    – Stephen Kitt
    Dec 11 at 20:57










  • @StephenKitt: That makes sense, thank you!
    – ptr_user7813604
    Dec 11 at 21:11












  • 2




    “... a data structure, called a page table, that ...” is correct: “that” refers to “a data structure”.
    – Stephen Kitt
    Dec 11 at 20:57










  • @StephenKitt: That makes sense, thank you!
    – ptr_user7813604
    Dec 11 at 21:11







2




2




“... a data structure, called a page table, that ...” is correct: “that” refers to “a data structure”.
– Stephen Kitt
Dec 11 at 20:57




“... a data structure, called a page table, that ...” is correct: “that” refers to “a data structure”.
– Stephen Kitt
Dec 11 at 20:57












@StephenKitt: That makes sense, thank you!
– ptr_user7813604
Dec 11 at 21:11




@StephenKitt: That makes sense, thank you!
– ptr_user7813604
Dec 11 at 21:11










1 Answer
1






active

oldest

votes


















1














It's a bit more complicated than that.



First off, there is only one true page table for any given processor core at a time. This is because it's the hardware that does the actual mapping of virtual addresses to physical addresses (more specifically, the MMU), and the kernel only ever gets involved when the contents of the page table have to change.



In addition, the kernel stores it's own information about the state of the virtual memory mappings for each execution context (process, thread, or kernel thread) separately. These are stored independently of each other and separate from the page tables used by the hardware for address mapping. Whenever the execution context changes (for example, a process makes a system call or an interrupt handler gets woken up to service an interrupt), part of the process of switching the execution context involves flushing the old entries from the hardware page table, and then loading it with the new entries. Depending on the two contexts, this may involve only repopulating a very small number of entries (for example, switching threads of the same userspace process), or it might require reloading the entire table (for example, switching from a user process to an interrupt handler).






share|improve this answer






















  • I don't quite understand your Independent of that, ... and from the hardware page table, could you elaborate more? (especially the both from each other.)
    – ptr_user7813604
    Dec 11 at 20:15











  • I've updated the answer to hopefully clarify things better. Sorry that it was a bit confusing.
    – Austin Hemmelgarn
    Dec 11 at 20:22






  • 1




    In the last sentence, reloading the entire table used to be rare (or at least, it could have been made rare, since the kernel mapping didn’t change), and switching from a user process to the kernel didn’t involve touching the page table; all that changed with KAISER/KPTI.
    – Stephen Kitt
    Dec 11 at 20:56











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f487435%2fhow-many-page-table-the-linux-kernel-maintains%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














It's a bit more complicated than that.



First off, there is only one true page table for any given processor core at a time. This is because it's the hardware that does the actual mapping of virtual addresses to physical addresses (more specifically, the MMU), and the kernel only ever gets involved when the contents of the page table have to change.



In addition, the kernel stores it's own information about the state of the virtual memory mappings for each execution context (process, thread, or kernel thread) separately. These are stored independently of each other and separate from the page tables used by the hardware for address mapping. Whenever the execution context changes (for example, a process makes a system call or an interrupt handler gets woken up to service an interrupt), part of the process of switching the execution context involves flushing the old entries from the hardware page table, and then loading it with the new entries. Depending on the two contexts, this may involve only repopulating a very small number of entries (for example, switching threads of the same userspace process), or it might require reloading the entire table (for example, switching from a user process to an interrupt handler).






share|improve this answer






















  • I don't quite understand your Independent of that, ... and from the hardware page table, could you elaborate more? (especially the both from each other.)
    – ptr_user7813604
    Dec 11 at 20:15











  • I've updated the answer to hopefully clarify things better. Sorry that it was a bit confusing.
    – Austin Hemmelgarn
    Dec 11 at 20:22






  • 1




    In the last sentence, reloading the entire table used to be rare (or at least, it could have been made rare, since the kernel mapping didn’t change), and switching from a user process to the kernel didn’t involve touching the page table; all that changed with KAISER/KPTI.
    – Stephen Kitt
    Dec 11 at 20:56
















1














It's a bit more complicated than that.



First off, there is only one true page table for any given processor core at a time. This is because it's the hardware that does the actual mapping of virtual addresses to physical addresses (more specifically, the MMU), and the kernel only ever gets involved when the contents of the page table have to change.



In addition, the kernel stores it's own information about the state of the virtual memory mappings for each execution context (process, thread, or kernel thread) separately. These are stored independently of each other and separate from the page tables used by the hardware for address mapping. Whenever the execution context changes (for example, a process makes a system call or an interrupt handler gets woken up to service an interrupt), part of the process of switching the execution context involves flushing the old entries from the hardware page table, and then loading it with the new entries. Depending on the two contexts, this may involve only repopulating a very small number of entries (for example, switching threads of the same userspace process), or it might require reloading the entire table (for example, switching from a user process to an interrupt handler).






share|improve this answer






















  • I don't quite understand your Independent of that, ... and from the hardware page table, could you elaborate more? (especially the both from each other.)
    – ptr_user7813604
    Dec 11 at 20:15











  • I've updated the answer to hopefully clarify things better. Sorry that it was a bit confusing.
    – Austin Hemmelgarn
    Dec 11 at 20:22






  • 1




    In the last sentence, reloading the entire table used to be rare (or at least, it could have been made rare, since the kernel mapping didn’t change), and switching from a user process to the kernel didn’t involve touching the page table; all that changed with KAISER/KPTI.
    – Stephen Kitt
    Dec 11 at 20:56














1












1








1






It's a bit more complicated than that.



First off, there is only one true page table for any given processor core at a time. This is because it's the hardware that does the actual mapping of virtual addresses to physical addresses (more specifically, the MMU), and the kernel only ever gets involved when the contents of the page table have to change.



In addition, the kernel stores it's own information about the state of the virtual memory mappings for each execution context (process, thread, or kernel thread) separately. These are stored independently of each other and separate from the page tables used by the hardware for address mapping. Whenever the execution context changes (for example, a process makes a system call or an interrupt handler gets woken up to service an interrupt), part of the process of switching the execution context involves flushing the old entries from the hardware page table, and then loading it with the new entries. Depending on the two contexts, this may involve only repopulating a very small number of entries (for example, switching threads of the same userspace process), or it might require reloading the entire table (for example, switching from a user process to an interrupt handler).






share|improve this answer














It's a bit more complicated than that.



First off, there is only one true page table for any given processor core at a time. This is because it's the hardware that does the actual mapping of virtual addresses to physical addresses (more specifically, the MMU), and the kernel only ever gets involved when the contents of the page table have to change.



In addition, the kernel stores it's own information about the state of the virtual memory mappings for each execution context (process, thread, or kernel thread) separately. These are stored independently of each other and separate from the page tables used by the hardware for address mapping. Whenever the execution context changes (for example, a process makes a system call or an interrupt handler gets woken up to service an interrupt), part of the process of switching the execution context involves flushing the old entries from the hardware page table, and then loading it with the new entries. Depending on the two contexts, this may involve only repopulating a very small number of entries (for example, switching threads of the same userspace process), or it might require reloading the entire table (for example, switching from a user process to an interrupt handler).







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 11 at 20:19

























answered Dec 11 at 20:04









Austin Hemmelgarn

5,96111016




5,96111016











  • I don't quite understand your Independent of that, ... and from the hardware page table, could you elaborate more? (especially the both from each other.)
    – ptr_user7813604
    Dec 11 at 20:15











  • I've updated the answer to hopefully clarify things better. Sorry that it was a bit confusing.
    – Austin Hemmelgarn
    Dec 11 at 20:22






  • 1




    In the last sentence, reloading the entire table used to be rare (or at least, it could have been made rare, since the kernel mapping didn’t change), and switching from a user process to the kernel didn’t involve touching the page table; all that changed with KAISER/KPTI.
    – Stephen Kitt
    Dec 11 at 20:56

















  • I don't quite understand your Independent of that, ... and from the hardware page table, could you elaborate more? (especially the both from each other.)
    – ptr_user7813604
    Dec 11 at 20:15











  • I've updated the answer to hopefully clarify things better. Sorry that it was a bit confusing.
    – Austin Hemmelgarn
    Dec 11 at 20:22






  • 1




    In the last sentence, reloading the entire table used to be rare (or at least, it could have been made rare, since the kernel mapping didn’t change), and switching from a user process to the kernel didn’t involve touching the page table; all that changed with KAISER/KPTI.
    – Stephen Kitt
    Dec 11 at 20:56
















I don't quite understand your Independent of that, ... and from the hardware page table, could you elaborate more? (especially the both from each other.)
– ptr_user7813604
Dec 11 at 20:15





I don't quite understand your Independent of that, ... and from the hardware page table, could you elaborate more? (especially the both from each other.)
– ptr_user7813604
Dec 11 at 20:15













I've updated the answer to hopefully clarify things better. Sorry that it was a bit confusing.
– Austin Hemmelgarn
Dec 11 at 20:22




I've updated the answer to hopefully clarify things better. Sorry that it was a bit confusing.
– Austin Hemmelgarn
Dec 11 at 20:22




1




1




In the last sentence, reloading the entire table used to be rare (or at least, it could have been made rare, since the kernel mapping didn’t change), and switching from a user process to the kernel didn’t involve touching the page table; all that changed with KAISER/KPTI.
– Stephen Kitt
Dec 11 at 20:56





In the last sentence, reloading the entire table used to be rare (or at least, it could have been made rare, since the kernel mapping didn’t change), and switching from a user process to the kernel didn’t involve touching the page table; all that changed with KAISER/KPTI.
– Stephen Kitt
Dec 11 at 20:56


















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f487435%2fhow-many-page-table-the-linux-kernel-maintains%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?