From patchwork Fri Jun 8 23:50:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10455355 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 7AC886032D for ; Sat, 9 Jun 2018 00:00:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 751EB29603 for ; Sat, 9 Jun 2018 00:00:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71F6029508; Sat, 9 Jun 2018 00:00:58 +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 4CCAF2965C for ; Sat, 9 Jun 2018 00:00:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B9C96B0269; Fri, 8 Jun 2018 20:00:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 168246B026A; Fri, 8 Jun 2018 20:00:52 -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 00A9D6B026B; Fri, 8 Jun 2018 20:00:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f197.google.com (mail-pf0-f197.google.com [209.85.192.197]) by kanga.kvack.org (Postfix) with ESMTP id AD7A06B0269 for ; Fri, 8 Jun 2018 20:00:51 -0400 (EDT) Received: by mail-pf0-f197.google.com with SMTP id z9-v6so6914981pfe.23 for ; Fri, 08 Jun 2018 17:00:51 -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=rUMt66wYVn3oxbczTqbFKijLWWVGFRay8XH0S3p4LkHi5gzrhPiQGq74Im+z/Ldyf+ qFfYRULHPoJx3FERSTLdcY5i6DiSHo6U6DDEeZDoOQ3pC5Q7WyYcAetlwT+N956cV5/a Ha27Am4q8mZN7/6pF+95NSH+6HOzqEY6zEh39T3NKoPRWeNViCWX3wFyrd/BDKAVWkAO tEQul58tdSd2VP3lRbPYqnxmMSkh2hx7SLLn+WY0exzqvwxOiQYSAmqDxU/ReEqh2ipJ h3/JLUb5//FRTeLS944TkRP4Bdr3m8TvrtCn1qNedHsJwl3bW+zJdGsWcXhSxLtbTotE y83Q== 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: APt69E16SKLbqEKbSabguo+sDav6LUqavjK8uF+M/dVHOlnAvD24C7sW cGR4nkNoVJ0leav/OLbmUG/fjSU09jamsUv0S0ThKfbMgwHX/7D0TTBWATMntLBIC6o4/9LmuUm mwlOHkYAUvjkZUysxm/Xzdn2/V36sXtSuATc5aQEKVuJPP6wyTP+zi32XOXmD7MIfTg== X-Received: by 2002:a63:6185:: with SMTP id v127-v6mr6744429pgb.301.1528502451381; Fri, 08 Jun 2018 17:00:51 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIC1qIP4xUd3OSDlKHPgY46TZOXaEZFOHvWi4Xzr6+NSyF3aEFRx66xuAQvp8bRmXVK5DU1 X-Received: by 2002:a63:6185:: with SMTP id v127-v6mr6744384pgb.301.1528502450434; Fri, 08 Jun 2018 17:00:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528502450; cv=none; d=google.com; s=arc-20160816; b=VZ+/2V1chFbBnubaDBex+hzAftFd6pEnamZnDtdOwyXOvseSKUjqG0ryJdNztzKeZt 1hEaF+iUQZKOekwccLYCV+THJmHJr/5Bo0YczeEw6/J1Fbv5ru7hnZqL13P/vBGGt1z5 DKW9VRM9xvEqEh2siJWlGy6WYC2dGMF7BSZoOWJofxQFb/TnyBXBaUPQ1wgVo61t8h/1 n+asrtKVONwSTht3qXhyPr9JhbgkxRKrtGU+dGXVBPK1eBGCnJRdybfbB4iERzKEypHv fUzbiBacU4s0wJmTyiCSma8Qi6AYTm9h1P2LKHSrTGMDaL35hhshvODqY5V2WJMgJ8Ww qSgg== 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=Wndl6pIVAoc+mGm+DIS+mEwE4gVOWf+NLqXQjB/itylJMo+tUifpa3yQf/IoBzSCdO TVzVU9cIMJkI7dh1/GyPX+ikiK/L1c4kXUhWwYFXWsXWaRkUitl13RILrGpbOhEQT8RB yEiQgJB/ptJuE/yz+miVpzUcHiGmPVGEv5e/B60GBHHvmZTypYYuAUQV85RhClCGbcIg SXL9PJ5L2iBJxlU3rj8VUdXfPv6OH3bzg3H3t9Xfa9rqMBHxwCzpsFfpTt5uiEh4Usq/ IhzbeAwrRghOGoNp6PrEmmNbRzKunP/Dy12zZzCS/P6UsIh1UheitzX9SyInkKOIiYFj /i6g== 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 k7-v6si7383457pgc.401.2018.06.08.17.00.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Jun 2018 17:00:50 -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 fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jun 2018 17:00:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,492,1520924400"; d="scan'208";a="235934676" 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; 08 Jun 2018 17:00:49 -0700 Subject: [PATCH v4 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: Fri, 08 Jun 2018 16:50:52 -0700 Message-ID: <152850185265.38390.2828727053299635327.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <152850182079.38390.8280340535691965744.stgit@dwillia2-desk3.amr.corp.intel.com> References: <152850182079.38390.8280340535691965744.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; }