How many page table the linux kernel maintains?











up vote
0
down vote

favorite













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









New contributor




ptr_user7813604 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 2




    “... a data structure, called a page table, that ...” is correct: “that” refers to “a data structure”.
    – Stephen Kitt
    2 days ago










  • @StephenKitt: That makes sense, thank you!
    – ptr_user7813604
    2 days ago















up vote
0
down vote

favorite













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









New contributor




ptr_user7813604 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 2




    “... a data structure, called a page table, that ...” is correct: “that” refers to “a data structure”.
    – Stephen Kitt
    2 days ago










  • @StephenKitt: That makes sense, thank you!
    – ptr_user7813604
    2 days ago













up vote
0
down vote

favorite









up vote
0
down vote

favorite












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









New contributor




ptr_user7813604 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












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









New contributor




ptr_user7813604 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




ptr_user7813604 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago





















New contributor




ptr_user7813604 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









ptr_user7813604

1186




1186




New contributor




ptr_user7813604 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





ptr_user7813604 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






ptr_user7813604 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 2




    “... a data structure, called a page table, that ...” is correct: “that” refers to “a data structure”.
    – Stephen Kitt
    2 days ago










  • @StephenKitt: That makes sense, thank you!
    – ptr_user7813604
    2 days ago














  • 2




    “... a data structure, called a page table, that ...” is correct: “that” refers to “a data structure”.
    – Stephen Kitt
    2 days ago










  • @StephenKitt: That makes sense, thank you!
    – ptr_user7813604
    2 days ago








2




2




“... a data structure, called a page table, that ...” is correct: “that” refers to “a data structure”.
– Stephen Kitt
2 days ago




“... a data structure, called a page table, that ...” is correct: “that” refers to “a data structure”.
– Stephen Kitt
2 days ago












@StephenKitt: That makes sense, thank you!
– ptr_user7813604
2 days ago




@StephenKitt: That makes sense, thank you!
– ptr_user7813604
2 days ago










1 Answer
1






active

oldest

votes

















up vote
1
down vote













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
    2 days ago












  • I've updated the answer to hopefully clarify things better. Sorry that it was a bit confusing.
    – Austin Hemmelgarn
    2 days ago






  • 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
    2 days ago













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',
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
});


}
});






ptr_user7813604 is a new contributor. Be nice, and check out our Code of Conduct.










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








up vote
1
down vote













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
    2 days ago












  • I've updated the answer to hopefully clarify things better. Sorry that it was a bit confusing.
    – Austin Hemmelgarn
    2 days ago






  • 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
    2 days ago

















up vote
1
down vote













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
    2 days ago












  • I've updated the answer to hopefully clarify things better. Sorry that it was a bit confusing.
    – Austin Hemmelgarn
    2 days ago






  • 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
    2 days ago















up vote
1
down vote










up vote
1
down vote









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 2 days ago

























answered 2 days ago









Austin Hemmelgarn

5,89811016




5,89811016












  • 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
    2 days ago












  • I've updated the answer to hopefully clarify things better. Sorry that it was a bit confusing.
    – Austin Hemmelgarn
    2 days ago






  • 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
    2 days ago




















  • 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
    2 days ago












  • I've updated the answer to hopefully clarify things better. Sorry that it was a bit confusing.
    – Austin Hemmelgarn
    2 days ago






  • 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
    2 days ago


















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
2 days ago






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
2 days ago














I've updated the answer to hopefully clarify things better. Sorry that it was a bit confusing.
– Austin Hemmelgarn
2 days ago




I've updated the answer to hopefully clarify things better. Sorry that it was a bit confusing.
– Austin Hemmelgarn
2 days ago




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
2 days ago






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
2 days ago












ptr_user7813604 is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















ptr_user7813604 is a new contributor. Be nice, and check out our Code of Conduct.













ptr_user7813604 is a new contributor. Be nice, and check out our Code of Conduct.












ptr_user7813604 is a new contributor. Be nice, and check out our Code of Conduct.
















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

サソリ

広島県道265号伴広島線

Setup Asymptote in Texstudio