From: valdis.kletnieks@vt.edu (valdis.kletnieks at vt.edu) To: kernelnewbies@lists.kernelnewbies.org Subject: a question on mapping from PTE to swap entry Date: Thu, 15 Nov 2018 12:59:52 -0500 [thread overview] Message-ID: <33940.1542304792@turing-police.cc.vt.edu> (raw) In-Reply-To: <tencent_37D7F80DFDD9120EFC281E281A758CA6F909@qq.com> On Thu, 15 Nov 2018 23:53:56 +0800, "Larry" said: > I'm curious when multiple process has the same PTE which points to the samepage, > how can kernel differenciate which page from swap space should be swappedin? The PTE tells where in /dev/swap to find the page. If it's a shared page, the references all point at the same place, so "process 1's PAGE_A info" is the same as "process 2's PAGE_A" info. They may have different addresses in the two processes, but they're both referencing the same swap page. > Process 2 get scheduled, PAGE_A was from Process 1, so it should be swapped out Why? In general, there's no need to do so - and if it's shared, it's probably a hot page so it won't be chosen for swapout. (Remember - the kernel doesn't do swapin/swapout decisions in schedule(), it only takes action once Process 2 starts running and references a page that requires something be done. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 486 bytes Desc: not available URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20181115/dd74e597/attachment.sig>
WARNING: multiple messages have this Message-ID (diff)
From: valdis.kletnieks@vt.edu To: "Larry" <losemyheaven@foxmail.com> Cc: kernelnewbies <kernelnewbies@kernelnewbies.org> Subject: Re: a question on mapping from PTE to swap entry Date: Thu, 15 Nov 2018 12:59:52 -0500 [thread overview] Message-ID: <33940.1542304792@turing-police.cc.vt.edu> (raw) Message-ID: <20181115175952.qUntF-Mh5sGBEILD86o59wrH9gjSozDcAReBYdRcTrY@z> (raw) In-Reply-To: <tencent_37D7F80DFDD9120EFC281E281A758CA6F909@qq.com> [-- Attachment #1.1: Type: text/plain, Size: 899 bytes --] On Thu, 15 Nov 2018 23:53:56 +0800, "Larry" said: > I'm curious when multiple process has the same PTE which points to the samepage, > how can kernel differenciate which page from swap space should be swappedin? The PTE tells where in /dev/swap to find the page. If it's a shared page, the references all point at the same place, so "process 1's PAGE_A info" is the same as "process 2's PAGE_A" info. They may have different addresses in the two processes, but they're both referencing the same swap page. > Process 2 get scheduled, PAGE_A was from Process 1, so it should be swapped out Why? In general, there's no need to do so - and if it's shared, it's probably a hot page so it won't be chosen for swapout. (Remember - the kernel doesn't do swapin/swapout decisions in schedule(), it only takes action once Process 2 starts running and references a page that requires something be done. [-- Attachment #1.2: Type: application/pgp-signature, Size: 486 bytes --] [-- Attachment #2: Type: text/plain, Size: 170 bytes --] _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
next prev parent reply other threads:[~2018-11-15 17:59 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-11-15 15:53 a question on mapping from PTE to swap entry Larry 2018-11-15 15:53 ` Larry 2018-11-15 17:59 ` valdis.kletnieks at vt.edu [this message] 2018-11-15 17:59 ` valdis.kletnieks
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=33940.1542304792@turing-police.cc.vt.edu \ --to=valdis.kletnieks@vt.edu \ --cc=kernelnewbies@lists.kernelnewbies.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).