Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1243461imm; Wed, 4 Jul 2018 14:53:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpecHVBycRZrt8pdF1rvVhzb4+jEfyxesaXkDr3tL1+zNx4bBKhxY9v/pPYQmfR2uONFVSk7 X-Received: by 2002:a17:902:345:: with SMTP id 63-v6mr3656566pld.328.1530741225705; Wed, 04 Jul 2018 14:53:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530741225; cv=none; d=google.com; s=arc-20160816; b=Zww6yoqBZkW4JKQmsvbq2k0lK7HueqVtUFHQyOOs1qmKY0XUvQnu6EJvXA9Fg+ehuV zP5WEJrGoa4g8LBgCTDU451bX1DSsXEW+C2jnEyYcRLc29SwSUItLmIcWNs6OYA9oZI6 NlNU88wvLVyoWPDrmEWb3+p0y6HTrPO89V1V8Fbb7e3SH3R6ogYAikARKBkkqe7lY8rR Bofz0b2dxqtmvhrPQfYaZK9dJFTQ/ejSIurcjpSBUVon1dXzzG5FTtBcqwx5mGDCxFyB ZXytag6Z2cFRf1/9VcT2EtKdt/Xn2PUuJxYi+1FpKizSxFJuz0l2lULGQvj9f9cYlHaa P46g== 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=NZXQMsP0IZWzg3615623L5IQtN7lJygiLojYfuGLbD0=; b=Lm6GkYz0ueJrDIJcihYIxcNFe6X3bSpb05B0U+iMiDG/CzW8e5chB+GCYKszRA5XyH /0pwJvo4zl8x01nkWdEMuLUJ9yFDy2Flu/B1krkIIb9KYnAPMjUnwG2dxN80cZUT+FjN 2XTsnQYcQEpM+/XZhw7z0LyWnICqhAzSf+khfYkZgziDSCKOAtbDniReXGTd6nN39Eg6 ZZrXGNQEUtFEEOH/hSu5zVWij+MPczSa0oTJ//QjTKDt62HyZlYolxF0eMY+opVU7zqe TYv8Q2ofrjudvc3tYaHGzETmHmAq6qhmAe26PfFIlx+99nL+WVcpls7PTgSZjIbneyZp 4x7w== 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 r29-v6si4998604pff.24.2018.07.04.14.53.31; Wed, 04 Jul 2018 14:53:45 -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 S1753397AbeGDVw0 (ORCPT + 99 others); Wed, 4 Jul 2018 17:52:26 -0400 Received: from mga03.intel.com ([134.134.136.65]:1054 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752958AbeGDVut (ORCPT ); Wed, 4 Jul 2018 17:50:49 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.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 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 | 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; }