Re: [PATCHv3, RESEND 5/8] khugepaged: Allow to collapse a page shared across fork
From: Kirill A. Shutemov
Date: Tue Apr 14 2020 - 17:35:37 EST
On Mon, Apr 13, 2020 at 01:48:22PM -0700, John Hubbard wrote:
[Thanks for all your suggestions and corrections]
> > + if (IS_ENABLED(CONFIG_DEBUG_VM) && expected_refcount > refcount) {
> > + pr_err("expected_refcount: %d, refcount: %d\n",
> > + expected_refcount, refcount);
> > + dump_page(page, "Unexpected refcount");
>
>
> I see two issues with the pr_err() and the dump_page() call:
>
> 1. You probably want to rate limit this, otherwise you'll have a big
> problem if lots of pages are pinned!
Nope. Only if kernel is buggy. See below.
> 2. Actually, I don't think you'd want to print anything at all here, even with
> rate limiting, because doing so presumes that "unexpected" means "wrong". And I
> think this patch doesn't expect to have GUP pins (or pin_user_pages() pins, ha),
> but that doesn't mean that they're wrong to have.
See condition. We only do it if refcount is *below* expected refcount. It
should never happen. Pinned page would have refcount above expected.
--
Kirill A. Shutemov