Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp210333imm; Fri, 13 Jul 2018 22:01:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpenTzyDeuHjzTTl44XMx4zUCsVy2GiNFbTi+UnAPHJ+wjdhoH9tVz95J01ZXpd8qswv2onX X-Received: by 2002:a17:902:381:: with SMTP id d1-v6mr8941318pld.309.1531544487593; Fri, 13 Jul 2018 22:01:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531544487; cv=none; d=google.com; s=arc-20160816; b=Lq9WqALMUddGyDTqTrKrz7zdNaTGJhWdjSwV19+vxnclqO6+iyDpZU/DvZu28QmQLG a5bboGhIPU0IlfeuZ7ha8+TtSd1FckCyrQZiY9EHSE5mACoMbU85I2/AEAR/J0b6fIGN CiVntPPvPgtiWNEpQPHvZDB4Rj2mnkBetRUKGFT06ApKUM3//gzLNA9t0WMilUoqbouR n+31NB0WmAjAtxjzmOjHh/kYIgW3sIsMWgWsT7mmxr/uh4mk2YXZHLTtr6PXA2wYPcU8 yt4dZwENDxiTPqyuZ/wtmKPwLuBKm/a/dlCbw9U0q4r+pGLZ/yqzJDyvC85pay+sW99Z Na2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:message-id:date:cc:to:from:subject :arc-authentication-results; bh=qEHvTC015vapXj7sAEtX1zHH4zlBrdvqniYlAXuPzGk=; b=xfqV/gMnrQoMarSZNwA2t1W5RVRYCAE5exG2FdtDR9mAsc5MkBE7cr58jEA2uLOds7 UlU8WXdWkKRlEo76p5LVZJD2PF8XvlymO/K1UfSe3KJW63ypz5hWiQ1OBcJpLU+r5Frt pUHYQEtIU25nIlSRlKIVpUHuIRtulGNacsVfoeynCbGO5QIoifSqIwFcHRiJKHsRg00r QYXwBDu0LjHzh/gvXZsBJbct2f8jkMhSLT/BE8+lOblK55Etov1uD80Xs+AoBUQ2QlWG f6KauOEueAZ5RarJEDc5kQKaSq4rNzl98+ygCeTFAJUwOr0kyul1OOg7XpC/J+EQSCpv TBrw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6-v6si24187400pgt.352.2018.07.13.22.01.13; Fri, 13 Jul 2018 22:01:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726275AbeGNFRH (ORCPT + 99 others); Sat, 14 Jul 2018 01:17:07 -0400 Received: from mga17.intel.com ([192.55.52.151]:58760 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725933AbeGNFRG (ORCPT ); Sat, 14 Jul 2018 01:17:06 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jul 2018 21:59:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,350,1526367600"; d="scan'208";a="245634555" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga006.fm.intel.com with ESMTP; 13 Jul 2018 21:59:26 -0700 Subject: [PATCH v6 00/13] mm: Teach memory_failure() about ZONE_DEVICE pages From: Dan Williams To: linux-nvdimm@lists.01.org Cc: linux-edac@vger.kernel.org, Tony Luck , Borislav Petkov , stable@vger.kernel.org, Jan Kara , "H. Peter Anvin" , x86@kernel.org, Thomas Gleixner , Christoph Hellwig , Ross Zwisler , Ingo Molnar , Michal Hocko , Matthew Wilcox , Naoya Horiguchi , =?utf-8?b?SsOpcsO0bWU=?= Glisse , Andrew Morton , Souptick Joarder , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Fri, 13 Jul 2018 21:49:29 -0700 Message-ID: <153154376846.34503.15480221419473501643.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Changes since v5 [1]: * Move put_page() before memory_failure() in madvise_inject_error() (Naoya) * The previous change uncovered a latent bug / broken assumption in __put_devmap_managed_page(). We need to preserve page->mapping for dax pages when they go idle. * Rename mapping_size() to dev_pagemap_mapping_size() (Naoya) * Catch and fail attempts to soft-offline dax pages (Naoya) * Collect Naoya's ack on "mm, memory_failure: Collect mapping size in collect_procs()" [1]: https://lists.01.org/pipermail/linux-nvdimm/2018-July/016682.html --- As it stands, memory_failure() gets thoroughly confused by dev_pagemap backed mappings. The recovery code has specific enabling for several possible page states and needs new enabling to handle poison in dax mappings. In order to support reliable reverse mapping of user space addresses: 1/ Add new locking in the memory_failure() rmap path to prevent races that would typically be handled by the page lock. 2/ Since dev_pagemap pages are hidden from the page allocator and the "compound page" accounting machinery, add a mechanism to determine the size of the mapping that encompasses a given poisoned pfn. 3/ Given pmem errors can be repaired, change the speculatively accessed poison protection, mce_unmap_kpfn(), to be reversible and otherwise allow ongoing access from the kernel. A side effect of this enabling is that MADV_HWPOISON becomes usable for dax mappings, however the primary motivation is to allow the system to survive userspace consumption of hardware-poison via dax. Specifically the current behavior is: mce: Uncorrected hardware memory error in user-access at af34214200 {1}[Hardware Error]: It has been corrected by h/w and requires no further action mce: [Hardware Error]: Machine check events logged {1}[Hardware Error]: event severity: corrected Memory failure: 0xaf34214: reserved kernel page still referenced by 1 users [..] Memory failure: 0xaf34214: recovery action for reserved kernel page: Failed mce: Memory error not recovered ...and with these changes: Injecting memory failure for pfn 0x20cb00 at process virtual address 0x7f763dd00000 Memory failure: 0x20cb00: Killing dax-pmd:5421 due to hardware memory corruption Memory failure: 0x20cb00: recovery action for dax page: Recovered Given all the cross dependencies I propose taking this through nvdimm.git with acks from Naoya, x86/core, x86/RAS, and of course dax folks. --- Dan Williams (13): device-dax: Convert to vmf_insert_mixed and vm_fault_t device-dax: Enable page_mapping() device-dax: Set page->index filesystem-dax: Set page->index mm, madvise_inject_error: Disable MADV_SOFT_OFFLINE for ZONE_DEVICE pages mm, dev_pagemap: Do not clear ->mapping on final put mm, madvise_inject_error: Let memory_failure() optionally take a page reference mm, memory_failure: Collect mapping size in collect_procs() filesystem-dax: Introduce dax_lock_mapping_entry() mm, memory_failure: Teach memory_failure() about dev_pagemap pages x86/mm/pat: Prepare {reserve,free}_memtype() for "decoy" addresses x86/memory_failure: Introduce {set,clear}_mce_nospec() libnvdimm, pmem: Restore page attributes when clearing errors arch/x86/include/asm/set_memory.h | 42 ++++++ arch/x86/kernel/cpu/mcheck/mce-internal.h | 15 -- arch/x86/kernel/cpu/mcheck/mce.c | 38 ----- arch/x86/mm/pat.c | 16 ++ drivers/dax/device.c | 75 +++++++--- drivers/nvdimm/pmem.c | 26 ++++ drivers/nvdimm/pmem.h | 13 ++ fs/dax.c | 125 ++++++++++++++++- include/linux/dax.h | 13 ++ include/linux/huge_mm.h | 5 - include/linux/mm.h | 1 include/linux/set_memory.h | 14 ++ kernel/memremap.c | 1 mm/hmm.c | 2 mm/huge_memory.c | 4 - mm/madvise.c | 16 ++ mm/memory-failure.c | 210 +++++++++++++++++++++++------ 17 files changed, 481 insertions(+), 135 deletions(-)