From patchwork Mon Jun 4 23:12:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10447461 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 BE532600CA for ; Mon, 4 Jun 2018 23:22:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B063F29222 for ; Mon, 4 Jun 2018 23:22:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A368529227; Mon, 4 Jun 2018 23:22:12 +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 4246029222 for ; Mon, 4 Jun 2018 23:22:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 20FE86B0269; Mon, 4 Jun 2018 19:22:11 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1E5FA6B026A; Mon, 4 Jun 2018 19:22:11 -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 0893B6B026B; Mon, 4 Jun 2018 19:22:11 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f69.google.com (mail-pl0-f69.google.com [209.85.160.69]) by kanga.kvack.org (Postfix) with ESMTP id BD2656B0269 for ; Mon, 4 Jun 2018 19:22:10 -0400 (EDT) Received: by mail-pl0-f69.google.com with SMTP id g6-v6so236694plq.9 for ; Mon, 04 Jun 2018 16:22:10 -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=AIoqcT7MPPgDKkGhpmA7d8VNBlO0r7d4emqlGnevChPBOt8h57p49huMw8KvH6My/m nWB3COLDW3GmHbPh7vbGVPzbxWTzsFMejjhy0zp8qMXumv+Ywiyff7OuBqyEbu5NVCvx /VJq0P6JnH4NrpywqIa6daaT9nyszr9oI7kc6RQPCGy//+Pmka6APG7DxptoLuJECj1I lc8h45VDiHxwM/zy9X5Dq8kTbE5s/EwVBzjtuwvw5LMxYRdFreATR5qohfDaxPCl7+AC fR/hQmbwIoiKkX+mmJCzuz3QeT1N7822sXNskT9jZL40aM+20lGxhVM2zrakC8aF9mOI eEFQ== 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: ALKqPwfGttRXJxT5FgPJkhmKUji6xEFEu722tNbF2Wl9FbMmMLuJCxs6 Ehr4bH1nFU3u+8K0Iry/v89E18YlCnmE4g0M5eBKBUgxbcKtRhuXkum4u1Yl29tnkytGexxMWKT CfuqY3p7Qe8x5DBZJ07SAUgv2J7ovIa6XxBNNLrRRmlaNOM6fhM2kNKqhchLS9VCiIQ== X-Received: by 2002:a17:902:8307:: with SMTP id bd7-v6mr23643694plb.234.1528154530464; Mon, 04 Jun 2018 16:22:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLrgBE7t1BJPmLy3uE6+N5C3B+y5RN9uujqF8K4ZAXkCvBL9xVHSfWfr+duT+gYB7UwQxbs X-Received: by 2002:a17:902:8307:: with SMTP id bd7-v6mr23643660plb.234.1528154529721; Mon, 04 Jun 2018 16:22:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528154529; cv=none; d=google.com; s=arc-20160816; b=g/X4WHiMtLPXVXxAZJylR2/5QyNzNU+tNUX6Mk1nJfojJYh498wOtqzBft8YLYfsyb batbWrn+kKJBc6yxauCiff8Dd/yuwodxkvHTluyzuvltk3yiDD72Iynnby+Euz2bww0F x0a/okYAJhrkotW6KaUHKsbAP3fY9Ud2X/q+tc6xeahn+JeozE4l1vrA1AQuiEYr6sDU qjyPOQCqEon9GtBns2tlxJrGqhpaChLYZYBpgRAntPU3z7La9GLxEvaOOfCU3Be1SKIs ZatZz4u2++wnklZY0yxqHQb+pD5oZfBKu3242KTXdsTCofIBjHuPy1cUVG9cVFPlG4HE NtqA== 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=msCV0/F1HEjPLWAs0hnCbCP6wdqbkExF7qWqRrXHe5yV3d04131hBNDzzmV9XEcm4k PB28dsgMtjiupLmhggGMbevUiuv1oOXDZ0Xlj4fEi1DvQNyphDrW54O7ldPAt031rFdv uQp2Et5gT3hyOvsc6oq7iRP25Bs16/T7T3rR4G2V0JEqpMyEfjm3ZOFqL57Dk/hAe8rp a9+grKk1miTz+eZD+RbLiXAfCrsm+2dmyzk3qRTzhhqW7pD3m/8bWnATKk2QUtJEupIE al4hxW/rGjPnriWpCUUelNcvcmslQQMOXC5uSaE9FJnYOFU0cMiC25EmC8uAFOErdcTF hu1w== 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 z62-v6si22625328pfk.197.2018.06.04.16.22.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 16:22:09 -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 orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jun 2018 16:22:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,477,1520924400"; d="scan'208";a="61773393" 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; 04 Jun 2018 16:22:08 -0700 Subject: [PATCH v3 06/12] 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: Mon, 04 Jun 2018 16:12:12 -0700 Message-ID: <152815393199.39010.5209788235715575901.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <152815389835.39010.13253559944508110923.stgit@dwillia2-desk3.amr.corp.intel.com> References: <152815389835.39010.13253559944508110923.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; }