From patchwork Wed Jul 4 21:40:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 10507639 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 EFC89602BC for ; Wed, 4 Jul 2018 21:50:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5F9828CD3 for ; Wed, 4 Jul 2018 21:50:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9EA328DAA; Wed, 4 Jul 2018 21:50:51 +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 7FE6828CD3 for ; Wed, 4 Jul 2018 21:50:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C59AA6B0269; Wed, 4 Jul 2018 17:50:49 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C0A936B026A; Wed, 4 Jul 2018 17:50:49 -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 B2A576B026B; Wed, 4 Jul 2018 17:50:49 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f198.google.com (mail-pf0-f198.google.com [209.85.192.198]) by kanga.kvack.org (Postfix) with ESMTP id 6633C6B0269 for ; Wed, 4 Jul 2018 17:50:49 -0400 (EDT) Received: by mail-pf0-f198.google.com with SMTP id u18-v6so3457621pfh.21 for ; Wed, 04 Jul 2018 14:50:49 -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=pbT+9upaTRGvZYlTDShwJQPB8EV/Jj74Algzjk38UTDuNmiChOEGRIQhqQsmWd2Mp/ M4dbJr74CtFzZMKvXTN83IApyR1tqeHzcn8z05PSu+pSRmgXtBeLo4MALF0jeQblzSRs bG25cEOuQk0TjeJUu8gL1gsFoVDFRK/wzqVq/rC2OZzb5cBDKA8YTZaGi/BI0SosCka7 dvZ0u5hH4Ixr3EUMMEiVr8XjQlAsNUVDzWbjDy/4hR+pK9N2wiAYM9t/oFxOqTKYsWUP YBxcDyubMDSgOSQEV7ATTdKH9Da4+ilzsHkXucmlbCnEZ9HUtf/01Cd5MnHHFLFtkZNN jcjw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.43 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: APt69E2elDnwZHyMXRLqIhOKzH3rm91tUu7epbx33RaRb42iYHMTZjlZ JN8MZt8MPAMsCEsCe8klbXl1piGxL2w33Oe/NuMoFri7PgfjfajF3ETBO+JzTdOHhc0A0DsTSgk Z/wirbI0d3cTkM2ozjdPzW1odp//mmj/PK7t6iPy/g8KcaY8k/jiDz70UhQ3P22MwHA== X-Received: by 2002:a63:1015:: with SMTP id f21-v6mr2139362pgl.354.1530741049104; Wed, 04 Jul 2018 14:50:49 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf3GcIaygziTGBbWz+qhKF3/rRp/PNTtlmFRF234fj7g1cG5cL7Z+s2UzNukshw35SqApJA X-Received: by 2002:a63:1015:: with SMTP id f21-v6mr2139336pgl.354.1530741048090; Wed, 04 Jul 2018 14:50:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530741048; cv=none; d=google.com; s=arc-20160816; b=J/jD1OSA3T4PullSzowBP1sBdn3qymTKJvpE1phM84/xbW7pBoxdL6ttAO+TdMBTM0 EhKkYeKAOqQ2yxVWiz02yQks95GnpUNAMM9rZpkI2WFhj8L7Bp78JjVqzDAKbLWeKGUx w9o5ME7FQBkBjzsWI0HXYYvenriknO9PLDSmfjEOxD0ushE/B+02/4E5C0CxhFkZeYAn pwZINV9WFbk1bQ3medlkHh3nRJV/mMiUqUVDpwn5z2xPy/0pwsHH8oRyrt2o3nPBQCq5 8i4ueVsvbSvf0SNVxjHvPLnXiDHYlZNi2asR90eBcEZCbRATBTyiCVF+7/AL13FLTKaA UfbA== 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=gR004Z8kn0rln2LdK8+fcLaVbSMkhqIuvRuynqipd4GszeN/wlHTs/Bgsvc+TkPv6n gQkrkw4BV/bQ6e9TpYrus/EUkCDd7L3Bi3ztX4nl7wa/0yUpeaNhhywDbeWYGSNBXu25 0zlxg45/wvijk9VVGWdsDVCQz+wrHwOR5COyN2LwKas7Q7XCX81bgUI0N6xvdjpsHtwR g0cZmNIW0LmWoKEV5UYHTFEWdm8JG+0AYrlqzs4Hg7AljQ2xgWtAon+lUHgpSRovcrFB ON1RlrsfuHCbx0Il0RktELhbRYB6+S9a9z8cj8SGrfcZIvmWhuHBCg9YyaTqgFFscAPe Dgrg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=dan.j.williams@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga05.intel.com (mga05.intel.com. [192.55.52.43]) by mx.google.com with ESMTPS id 59-v6si4391678plp.496.2018.07.04.14.50.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Jul 2018 14:50:48 -0700 (PDT) Received-SPF: pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.43 as permitted sender) client-ip=192.55.52.43; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dan.j.williams@intel.com designates 192.55.52.43 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 fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jul 2018 14:50:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,309,1526367600"; d="scan'208";a="62320546" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by FMSMGA003.fm.intel.com with ESMTP; 04 Jul 2018 14:50:47 -0700 Subject: [PATCH v5 05/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, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, jack@suse.cz, ross.zwisler@linux.intel.com Date: Wed, 04 Jul 2018 14:40:49 -0700 Message-ID: <153074044986.27838.16910122305490506387.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <153074042316.27838.17319837331947007626.stgit@dwillia2-desk3.amr.corp.intel.com> References: <153074042316.27838.17319837331947007626.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; }