Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp211364imm; Fri, 13 Jul 2018 22:03:06 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdmij6u9JPDuryAUqbj3D4A4ACOksrXsTAaYYYxaAqpbT1+2DdBDQV90U2AvLDoAfpqabWQ X-Received: by 2002:a62:4808:: with SMTP id v8-v6mr9841509pfa.89.1531544585960; Fri, 13 Jul 2018 22:03:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531544585; cv=none; d=google.com; s=arc-20160816; b=vV+fQ+6DE0GijG8kqgbFlEEBDgmVYMiJ6aFHtMQ1kz5raUMLHLx9+HLK2tZaf2T7Wf Gt0zFnvJCoDPBgYbcNlvNhTEaBv5EpbNN1avR+LPz/U8Z5n+bcKKygMFavz9kxDOVYLs tN46qJeTAWXL/aUC8qbfARXmBh9b1ISO1dto87gyXyRqD7i+PMVGzKvvXI52HY5V3c2j CAHPs5/1443YzqU4vZ861XrZz3DoteNa4rzstbmN4dMXYzwMKB66kxGPBqu2ooa2lIgV 4GF6LZjDnyMzV2Y7Zz3y+4M6i4myqPoqYdNyayHQntOBCbzE/wYUllJNoRuOkE/HEXoY a1Kg== 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:references:in-reply-to:message-id:date:cc:to:from :subject:arc-authentication-results; bh=DIRHwUAPjdrvuCUXr+Qm01XOhUbCVXJzvYb4t7QVSHg=; b=M0A4pd5opStvuPouKTsN2s6e/JJCGUpeXm9YkKb5rwYHKYinjIXdv/W8s3prHz5Gte 1Hbv66HmwXslTefKYviSEN6Gv6ITtOtDtsyzMJp3Q/yyQcq1vNTchAkj07ZKApUiW5WN v9kzJPjQZSbc2Cif3S9SAb/Ya0Z2j7ubNai0NkfdDnQQ70N0EdkgSuL6P4y9HQMgbgD6 fYgWlvL/6uNZObenlNpk7WL61YX4+7POqIectZ3D3F7LEcmh1GLIlTFWuLkSLnRgpGNO R/L1FQgezDRzfPtEyT3X2aekBRFva9XijcP2RqLwDhMZHtf5ATgIIsacCAdNnxBW+xAv FFxw== 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 q13-v6si24698241pll.72.2018.07.13.22.02.51; Fri, 13 Jul 2018 22:03:05 -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 S1727855AbeGNFSV (ORCPT + 99 others); Sat, 14 Jul 2018 01:18:21 -0400 Received: from mga11.intel.com ([192.55.52.93]:40757 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725986AbeGNFSV (ORCPT ); Sat, 14 Jul 2018 01:18:21 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jul 2018 22:00:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,350,1526367600"; d="scan'208";a="72664103" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga001.jf.intel.com with ESMTP; 13 Jul 2018 22:00:04 -0700 Subject: [PATCH v6 07/13] mm, madvise_inject_error: Let memory_failure() optionally take a page reference From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Michal Hocko , Naoya Horiguchi , hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Fri, 13 Jul 2018 21:50:06 -0700 Message-ID: <153154380652.34503.2174920161570183766.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <153154376846.34503.15480221419473501643.stgit@dwillia2-desk3.amr.corp.intel.com> References: <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 The madvise_inject_error() routine uses get_user_pages() to lookup the pfn and other information for injected error, but it does not release that pin. The assumption is that failed pages should be taken out of circulation. However, for dax mappings it is not possible to take pages out of circulation since they are 1:1 physically mapped as filesystem blocks, or device-dax capacity. They also typically represent persistent memory which has an error clearing capability. In preparation for adding a special handler for dax mappings, shift the responsibility of taking the page reference to memory_failure(). I.e. drop the page reference and do not specify MF_COUNT_INCREASED to memory_failure(). Cc: Michal Hocko Cc: Naoya Horiguchi Signed-off-by: Dan Williams --- mm/madvise.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mm/madvise.c b/mm/madvise.c index 4d3c922ea1a1..972a9eaa898b 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -631,11 +631,13 @@ static int madvise_inject_error(int behavior, for (; start < end; start += PAGE_SIZE << order) { + unsigned long pfn; int ret; ret = get_user_pages_fast(start, 1, 0, &page); if (ret != 1) return ret; + pfn = page_to_pfn(page); /* * When soft offlining hugepages, after migrating the page @@ -651,17 +653,25 @@ static int madvise_inject_error(int behavior, if (behavior == MADV_SOFT_OFFLINE) { pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n", - page_to_pfn(page), start); + pfn, start); ret = soft_offline_page(page, MF_COUNT_INCREASED); if (ret) return ret; continue; } + pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n", - page_to_pfn(page), start); + pfn, start); - ret = memory_failure(page_to_pfn(page), MF_COUNT_INCREASED); + /* + * Drop the page reference taken by get_user_pages_fast(). In + * the absence of MF_COUNT_INCREASED the memory_failure() + * routine is responsible for pinning the page to prevent it + * from being released back to the page allocator. + */ + put_page(page); + ret = memory_failure(pfn, 0); if (ret) return ret; }