linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Kaiyang Zhao <zhao776@purdue.edu>, akpm@linux-foundation.org
Cc: linux-mm@kvack.org
Subject: Re: [PATCH] Shared page tables during fork
Date: Tue, 6 Jul 2021 16:01:52 -0700	[thread overview]
Message-ID: <d1fbc152-0328-72b1-cb9f-a21d57754166@intel.com> (raw)
In-Reply-To: <20210701134618.18376-1-zhao776@purdue.edu>

On 7/1/21 6:46 AM, Kaiyang Zhao wrote:
> The design is that instead of copying the entire paging tree during the
> fork invocation, we make the child and the parent process share the same
> set of last-level page tables, which will be reference counted. To preserve
> the copy-on-write semantics, we disable the write permission in PMD entries
> in fork, and copy PTE tables as needed in the page fault handler.

That's clever.  But, I'm not sure it's comprehensive.  How, for
instance, do you handle get_user_pages() users that don't actually write
to the mappings?  Or, memory reclaim where the kernel itself goes and
zaps page table entries without accessing the mapping itself that's
being zapped.

I would have expected a *lot* more pervasive changes to page table
walkers across the kernel.

Oh, and the code itself makes my eyes bleed.  You might want to spend a
bit of time to clean out the debug printk()s and make sure this gets
somewhere close to passing checkpatch.pl if you want to be taken more
seriously.  For example:

> +		if (pte_present(ptent)) {
> +			struct page *page;
> +
> +			if (pte_special(ptent)) { //known special pte: vvar VMA, which has just one page shared system-wide. Shouldn't matter
> +				continue;
> +			}
> +			page = vm_normal_page(NULL, addr, ptent); //kyz : vma is not important
> +			if (unlikely(!page))
> +				continue;
> +			rss[mm_counter(page)]--;
> +#ifdef CONFIG_DEBUG_VM
> +			//   printk("zap_one_pte_table: addr=%lx, end=%lx, (before) mapcount=%d, refcount=%d\n", addr, end, page_mapcount(page), page_ref_count(page));
> +#endif
> +			page_remove_rmap(page, false);
> +			put_page(page);
> +		}



  parent reply	other threads:[~2021-07-06 23:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-01 13:46 Kaiyang Zhao
2021-07-06 18:47 ` Souptick Joarder
2021-07-06 23:01 ` Dave Hansen [this message]
2021-07-07  7:00 ` Hillf Danton

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=d1fbc152-0328-72b1-cb9f-a21d57754166@intel.com \
    --to=dave.hansen@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=zhao776@purdue.edu \
    /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: link
Be 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