Date: Thu, 3 Oct 2019 11:33:11 +0300 From: Konstantin Belousov <kostikbel@gmail.com> To: Yoshihiro Ota <ota@j.email.ne.jp> Cc: freebsd-hackers@freebsd.org Subject: Re: Can multiple vm_pages refer to a same swap device page? Message-ID: <20191003083311.GH44691@kib.kiev.ua> In-Reply-To: <20191002163141.1b88c3417e561c37624643b9@j.email.ne.jp> References: <20191002163141.1b88c3417e561c37624643b9@j.email.ne.jp>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Oct 02, 2019 at 04:31:41PM -0400, Yoshihiro Ota wrote: > Hi forks, > > Given a process can allocate lot of memory even cosuming swap space, then fork a child process, and both parent and child processes stay live while doing differen things, I expect a system needs to track how many processes are refering to same swap pages. > No, it does not. > How does FreeBSD keep track of multiple processes refering to same swap pages? > Is it by multiple vm_page objects pointing to same swap device pages with daddr_t? > > I've been looking around swap_pager.h, vm_page, vm_object, struct swblk, and struct swdevt but I don't find reference count for swap device pages. > > Am I missing something? Yes, the mechanism for CoW sharing the same read-only page is called shadowing and it is a form of the content inheritance, where we insert a new default (later swap) object on top of existing object on forking. The sentence above perhaps sounds too cryptic, I recommend you to look at the 'Design and Implementation' book by McKusick and this old article by Dillon https://www.freebsd.org/doc/en_US.ISO8859-1/articles/vm-design/index.html The part about vm objects is still relevant and should answer your question.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20191003083311.GH44691>