From patchwork Sun Jun 3 05:23:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10445183 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8470F602BC for ; Sun, 3 Jun 2018 05:33:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 773A027E63 for ; Sun, 3 Jun 2018 05:33:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B6BF289DF; Sun, 3 Jun 2018 05:33:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 145FF27E63 for ; Sun, 3 Jun 2018 05:33:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D175A6B026A; Sun, 3 Jun 2018 01:33:14 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CA00A6B026B; Sun, 3 Jun 2018 01:33:14 -0400 (EDT) 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 B40EA6B026C; Sun, 3 Jun 2018 01:33:14 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id 704206B026A for ; Sun, 3 Jun 2018 01:33:14 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id c187-v6so16886494pfa.20 for ; Sat, 02 Jun 2018 22:33:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:subject:from :to:cc:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=NZXQMsP0IZWzg3615623L5IQtN7lJygiLojYfuGLbD0=; b=j6bK0Z7ycAM8mP/6JBrFWGtM8mysOr+oAbYQxU5KCBk6jNxeyb2dxjfLiT/rqGmq8a QONbzhvUkt5McKETs0s8MXVxdY7vlOuQM/1IW9aD3WwdEGaAWs9FB1qR+EqQrOnA4npP p1pePhdv7/5D3Pnz3FaIi3k82urIIp1i35T4LZG+Df3+dfebK3TRtB9u8oZ2q/fsnBnz VX9EAhGX0lmm/6cslrT8wqe2BuetYyVwiT/tJ1d3mr1wwt4dr2+MAzSL37NLlUuM3Y0b n8l/iFLHK3q18cIGaeSomPQetyfJx8xhoeijYWk0CqQnDZpZsblWYcXr4bSKn7eBXq9W YvQw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.151 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: ALKqPweyIftrTwuWx7dF/6eZLTyt9BQfAXfijWhIVxMqHqlYA/9CYXK/ I6Xxyacntpjptz338x24VrcciexTEZ448cRqNLfc2/EfSU1swFc4aibC+XKLsbnuzTUzpC5oafa wEynjGBCCMZyGVXw/4DQUSmqmDyJ5NPk4ePs+947Wu/GQ4CPST4QeiDONElNTqxjjjA== X-Received: by 2002:a17:902:9344:: with SMTP id g4-v6mr17330828plp.10.1528003994155; Sat, 02 Jun 2018 22:33:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKgeBY7tcUPnilA3aARADPTFfLyCFn2L92HZjlsM3m4cUPTgvdzbwjVRE/nTcnISSP6/oP/ X-Received: by 2002:a17:902:9344:: with SMTP id g4-v6mr17330811plp.10.1528003993440; Sat, 02 Jun 2018 22:33:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528003993; cv=none; d=google.com; s=arc-20160816; b=S7tapUJFnXWARTD2idQXWlx8KLblzdpvhe+4CMW1NYhit/lxCpHf5qQjSIec1N3BTi 2fAVwsH2Va5MRVTTBFMeIiXGDLDcf40/nOKlqVvv2CA30v7U5NXxvHyzrwnHHJkfTydg 9J03xmHyUdxNdJSLlBeG983D5xRBkYZ/IOl5LUpkSVdW63wLoZs8sPikF2RuyFoLcMi7 SHxsEn7XWeGbK8ZZAF32dtFLulgDfcb8H4AmuNmMndC21k4zhU5DKZ1rMPb5cv16+l3e Nh9Neht0phNrYE+plqGbxzWQ3c9cEeMuCSDU8+zA/j+h8m3CbJosnzgMhL4FojASc7jH 5ogA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject :arc-authentication-results; bh=NZXQMsP0IZWzg3615623L5IQtN7lJygiLojYfuGLbD0=; b=piz1FfgznZDXJvudS7q+FO+twEti/eb1bIlwWl8yOx0G53YtK8v6frhAXgVve+x0Av C2qv484lQZDWbrD9yYCpVaXPxClwEZVozhmqlhw0dRsJpggAH9CWHtplL/CMDfH5EBFh W7nMjdDlLeR3hkLkxpwzSObGvau1gjOmUApDe9EqDfUmw4ucUNDMS4mlZ/RRG6bEPKW6 GUfDlkb/TFXkruQmlVKErBzq4xvZsYGRT5UOPjltvFjOTGtWeVlxGrrGczYxMkjfTeBE w6Ilo+uJKMWr4S3XrXaoOGiGctKG6uTEsDpVclbQ/BuYFaMrmQNpa1XAUTJIxTOviqqZ i5ZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.151 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga17.intel.com (mga17.intel.com. [192.55.52.151]) by mx.google.com with ESMTPS id l33-v6si42218286pld.440.2018.06.02.22.33.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Jun 2018 22:33:13 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.151 as permitted sender) client-ip=192.55.52.151; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.151 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jun 2018 22:33:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,472,1520924400"; d="scan'208";a="63860844" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga002.jf.intel.com with ESMTP; 02 Jun 2018 22:33:12 -0700 Subject: [PATCH v2 06/11] 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-mm@kvack.org, linux-fsdevel@vger.kernel.org, jack@suse.cz Date: Sat, 02 Jun 2018 22:23:15 -0700 Message-ID: <152800339570.17112.258235652775596016.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <152800336321.17112.3300876636370683279.stgit@dwillia2-desk3.amr.corp.intel.com> References: <152800336321.17112.3300876636370683279.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP 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 | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/mm/madvise.c b/mm/madvise.c index 4d3c922ea1a1..b731933dddae 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,27 @@ 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(pfn, 0); + + /* + * 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(page_to_pfn(page), MF_COUNT_INCREASED); if (ret) return ret; }