From patchwork Thu Jan 2 03:04:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 11315267 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F15D21395 for ; Thu, 2 Jan 2020 03:04:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C7CCF21655 for ; Thu, 2 Jan 2020 03:04:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C7CCF21655 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CF9818E0005; Wed, 1 Jan 2020 22:04:29 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CA9988E0003; Wed, 1 Jan 2020 22:04:29 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BBF318E0005; Wed, 1 Jan 2020 22:04:29 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0149.hostedemail.com [216.40.44.149]) by kanga.kvack.org (Postfix) with ESMTP id A596B8E0003 for ; Wed, 1 Jan 2020 22:04:29 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 5D7642DFC for ; Thu, 2 Jan 2020 03:04:29 +0000 (UTC) X-FDA: 76331201058.08.beast33_271d7ee2f2859 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,richardw.yang@linux.intel.com,:akpm@linux-foundation.org:kirill.shutemov@linux.intel.com::linux-kernel@vger.kernel.org:richard.weiyang@gmail.com:richardw.yang@linux.intel.com,RULES_HIT:30003:30051:30054:30090,0,RBL:192.55.52.43:@linux.intel.com:.lbl8.mailshell.net-62.18.0.100 64.95.201.95,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: beast33_271d7ee2f2859 X-Filterd-Recvd-Size: 3387 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Thu, 2 Jan 2020 03:04:28 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Jan 2020 19:04:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,385,1571727600"; d="scan'208";a="252112736" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga002.fm.intel.com with ESMTP; 01 Jan 2020 19:04:23 -0800 From: Wei Yang To: akpm@linux-foundation.org, kirill.shutemov@linux.intel.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, richard.weiyang@gmail.com, Wei Yang Subject: [RFC PATCH] mm/rmap.c: finer hwpoison granularity for PTE-mapped THP Date: Thu, 2 Jan 2020 11:04:21 +0800 Message-Id: <20200102030421.30799-1-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Currently we behave differently between PMD-mapped THP and PTE-mapped THP on memory_failure. User detected difference: For PTE-mapped THP, the whole 2M range will trigger MCE after memory_failure(), while only 4K range for PMD-mapped THP will. Direct reason: All the 512 PTE entry will be marked as hwpoison entry for a PTE-mapped THP while only one PTE will be marked for a PMD-mapped THP. Root reason: The root cause is PTE-mapped page doesn't need to split pmd which skip the SPLIT_FREEZE process. This makes try_to_unmap_one() do its job when the THP is not splited. And since page is HWPOISON, all the entries in THP is marked as hwpoison entry. While for the PMD-mapped THP, SPLIT_FREEZE will save migration entry to pte and this skip try_to_unmap_one() before THP splited. And then only the affected 4k page is marked as hwpoison entry. This patch tries to provide a finer granularity for PTE-mapped THP by only mark the affected subpage as hwpoison entry when THP is not split. Signed-off-by: Wei Yang --- This complicates the picture a little, while I don't find a better way to improve. Also I may miss some case or not handle this properly. Look forward your comments. --- mm/rmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/rmap.c b/mm/rmap.c index b3e381919835..90229917dd64 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1554,10 +1554,11 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma, set_huge_swap_pte_at(mm, address, pvmw.pte, pteval, vma_mmu_pagesize(vma)); - } else { + } else if (!PageAnon(page) || page == subpage) { dec_mm_counter(mm, mm_counter(page)); set_pte_at(mm, address, pvmw.pte, pteval); - } + } else + goto freeze; } else if (pte_unused(pteval) && !userfaultfd_armed(vma)) { /* @@ -1579,6 +1580,7 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma, swp_entry_t entry; pte_t swp_pte; +freeze: if (arch_unmap_one(mm, vma, address, pteval) < 0) { set_pte_at(mm, address, pvmw.pte, pteval); ret = false;