From: Oscar Salvador <osalvador@suse.de>
To: Jiaqi Yan <jiaqiyan@google.com>
Cc: shy828301@gmail.com, tongtiangen@huawei.com, tony.luck@intel.com,
naoya.horiguchi@nec.com, kirill.shutemov@linux.intel.com,
linmiaohe@huawei.com, juew@google.com, linux-mm@kvack.org
Subject: Re: [PATCH v3 1/2] mm: khugepaged: recover from poisoned anonymous memory
Date: Tue, 24 May 2022 12:48:22 +0200 [thread overview]
Message-ID: <Yoy39oPXZ0Lw6uJY@localhost.localdomain> (raw)
In-Reply-To: <20220524025352.1381911-2-jiaqiyan@google.com>
On Mon, May 23, 2022 at 07:53:51PM -0700, Jiaqi Yan wrote:
> Make __collapse_huge_page_copy return whether
> collapsing/copying anonymous pages succeeded,
> and make collapse_huge_page handle the return status.
>
> Break existing PTE scan loop into two for-loops.
> The first loop copies source pages into target huge page,
> and can fail gracefully when running into memory errors in
> source pages. Roll back the page table and page states
> when copying failed:
> 1) re-establish the PTEs-to-PMD connection.
> 2) release pages back to their LRU list.
If you spell out what the first loop does, just tell
what the second loop does as wel, it just gets easier.
> +static bool __collapse_huge_page_copy(pte_t *pte,
> + struct page *page,
> + pmd_t *pmd,
> + pmd_t rollback,
> + struct vm_area_struct *vma,
> + unsigned long address,
> + spinlock_t *pte_ptl,
> + struct list_head *compound_pagelist)
> {
> struct page *src_page, *tmp;
> pte_t *_pte;
> - for (_pte = pte; _pte < pte + HPAGE_PMD_NR;
> - _pte++, page++, address += PAGE_SIZE) {
> - pte_t pteval = *_pte;
> + pte_t pteval;
> + unsigned long _address;
> + spinlock_t *pmd_ptl;
> + bool copy_succeeded = true;
>
> - if (pte_none(pteval) || is_zero_pfn(pte_pfn(pteval))) {
> + /*
> + * Copying pages' contents is subject to memory poison at any iteration.
> + */
> + for (_pte = pte, _address = address;
> + _pte < pte + HPAGE_PMD_NR;
> + _pte++, page++, _address += PAGE_SIZE) {
> + pteval = *_pte;
> +
> + if (pte_none(pteval) || is_zero_pfn(pte_pfn(pteval)))
> clear_user_highpage(page, address);
> - add_mm_counter(vma->vm_mm, MM_ANONPAGES, 1);
> - if (is_zero_pfn(pte_pfn(pteval))) {
> - /*
> - * ptl mostly unnecessary.
> - */
> - spin_lock(ptl);
> - ptep_clear(vma->vm_mm, address, _pte);
> - spin_unlock(ptl);
> + else {
> + src_page = pte_page(pteval);
> + if (copy_highpage_mc(page, src_page)) {
> + copy_succeeded = false;
> + trace_mm_collapse_huge_page_copy(pte_page(*pte),
> + src_page, SCAN_COPY_MC);
You seem to assume that if there is an error, it will always happen on
the page we are copying from. What if the page we are copying to is the
fauly one? Can that happen? Can that be detected by copy_mc_to_kernel?
And if so, can that be differentiated?
--
Oscar Salvador
SUSE Labs
next prev parent reply other threads:[~2022-05-24 10:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-24 2:53 [PATCH v3 0/2] Memory poison recovery in khugepaged collapsing Jiaqi Yan
2022-05-24 2:53 ` [PATCH v3 1/2] mm: khugepaged: recover from poisoned anonymous memory Jiaqi Yan
2022-05-24 10:48 ` Oscar Salvador [this message]
2022-05-24 14:05 ` Jue Wang
2022-05-24 16:32 ` Jiaqi Yan
2022-05-24 18:41 ` Yang Shi
2022-05-27 0:05 ` Jiaqi Yan
2022-05-27 15:42 ` Yang Shi
2022-05-27 19:03 ` Jiaqi Yan
2022-05-24 2:53 ` [PATCH v3 2/2] mm: khugepaged: recover from poisoned file-backed memory Jiaqi Yan
2022-05-24 19:35 ` Yang Shi
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=Yoy39oPXZ0Lw6uJY@localhost.localdomain \
--to=osalvador@suse.de \
--cc=jiaqiyan@google.com \
--cc=juew@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linmiaohe@huawei.com \
--cc=linux-mm@kvack.org \
--cc=naoya.horiguchi@nec.com \
--cc=shy828301@gmail.com \
--cc=tongtiangen@huawei.com \
--cc=tony.luck@intel.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