From: Hugh Dickins <hughd@google.com>
To: Yang Shi <shy828301@gmail.com>
Cc: Hugh Dickins <hughd@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Ralph Campbell <rcampbell@nvidia.com>, Zi Yan <ziy@nvidia.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Linux MM <linux-mm@kvack.org>
Subject: Re: [PATCH mmotm] mm/thp: refix __split_huge_pmd_locked() for migration PMD
Date: Thu, 3 Mar 2022 14:45:26 -0800 (PST) [thread overview]
Message-ID: <72bcebad-b1e3-efd-ab72-9a86c76f70c1@google.com> (raw)
In-Reply-To: <CAHbLzkppwEBSkd2QFAHkRfQPsLqzRqPegbNUg_bnY62ai2Emyg@mail.gmail.com>
On Thu, 3 Mar 2022, Yang Shi wrote:
> On Wed, Mar 2, 2022 at 5:43 PM Hugh Dickins <hughd@google.com> wrote:
> >
> > Migration entries do not contribute to a page's reference count: move
> > __split_huge_pmd_locked()'s page_ref_add() into pmd_migration's else
> > block (along with the page_count() check - a page is quite likely to
> > to have reference count frozen to 0 when a migration entry is found).
> >
> > This will fix a very rare anonymous memory leak, after a split_huge_pmd()
> > raced with an anon split_huge_page() or an anon THP migrate_pages(): since
> > the wrongly raised refcount stopped the page (perhaps small, perhaps huge,
> > depending on when the race hit) from ever being freed. At first I thought
> > there were worse risks, from prematurely unfreezing a frozen page: but now
> > think that would only affect page cache pages, which do not come this way
> > (except for anonymous pages in swap cache, perhaps).
>
> Thanks for catching this. I agree there may be anon memory leak due to
> bumped refcount. But I don't think it could affect page cache page
> since that code (bumping refcount) is never called for page cache page
> IIUC.
Yes, that's what I meant by unfreezing "would only affect page cache pages,
which do not come this way". But then remembered that anonymous pages in
swap cache also have non-NULL page_mapping(), and involve freezing in the
same way that page cache pages do. Now, offhand I forget the status of
hugepage swap, so maybe that's impossible, hence "perhaps". Easier to
fix than to think through all the ramifications of not fixing, as usual.
>
> The patch looks good to me. Reviewed-by: Yang Shi <shy828301@gmail.com>
Thanks,
Hugh
prev parent reply other threads:[~2022-03-03 22:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-03 1:43 Hugh Dickins
2022-03-03 19:51 ` Yang Shi
2022-03-03 22:45 ` Hugh Dickins [this message]
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=72bcebad-b1e3-efd-ab72-9a86c76f70c1@google.com \
--to=hughd@google.com \
--cc=akpm@linux-foundation.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rcampbell@nvidia.com \
--cc=shy828301@gmail.com \
--cc=ziy@nvidia.com \
/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