Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp441596imm; Thu, 12 Jul 2018 23:38:06 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfTTqgBQqCrtara/nqIW1+I9NOfyFt9yqKH68JHDIamGI/QTp8RqqNkUQoZxsu8akbcIKNj X-Received: by 2002:a17:902:ab90:: with SMTP id f16-v6mr5271501plr.182.1531463886620; Thu, 12 Jul 2018 23:38:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531463886; cv=none; d=google.com; s=arc-20160816; b=EVm1I84hokfFxfIHiAhOYFsShk7GiDDeiw6G3H5pcDGFrPoGrfSYLpG7T4458yzGED OkiPvBGPhSJnneK3arpVKfO6xD/41GwpHR5CCeIWQyZXdyWlyjgJOEvLXQkAOlWIPlMe IedXHyKleSXFex4/7n5WSlYTPyd7/fRaKHZirpKhTiQB2g/VLBcJFb3kQ+nQaf6F5Wzh cLS0HBr7seahZEjwZ1M1O0k9xFIB/B+B3dRBQeqKWhJ3gkHbJYrY81baY6wg9EXFW2+w KnFFVEGgDBxEHRbgqvOtP1vA2HlBnZ/Tje0PehLJANVjPzG79p7dmYr/HMvz+FbrkhV4 y00Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :arc-authentication-results; bh=ziS1cosv95RFUm1yS9M1nLzij8h39P0w8jd4BeyL/rI=; b=NExf5eigw+nPHxvvi4SNss62zXFrKKXcd3pEseHIDEoFnkim0pnxsXIDLs6zjSIylG tloXFfTih2re0iU7DPWjTkc4z4Lr8AiJF3OxesbBK2AliePSDxVdUjGp95T+yt+lVEIG tNXDrlyv8halLM5UnHCtSaIwPS7kDiyJuRsYtaNlMG4rEscZDKyIcNUl+feCDnpW/Kjm 2f52VSrV6GG8v4TkoieQHQTHSWoCIwSNT77OUgQ8KVTGja1VnItPi+fatoqHk7yZ2mpG prswDmXtxV2JacTQ7C++MO+dBUyXD1o0wifOwGicjyq0HpGHE65BHtkO3Uh2nNhyf5fE RLmg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h17-v6si22149114pgg.218.2018.07.12.23.37.51; Thu, 12 Jul 2018 23:38:06 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728042AbeGMGuL convert rfc822-to-8bit (ORCPT + 99 others); Fri, 13 Jul 2018 02:50:11 -0400 Received: from tyo161.gate.nec.co.jp ([114.179.232.161]:50526 "EHLO tyo161.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726035AbeGMGuL (ORCPT ); Fri, 13 Jul 2018 02:50:11 -0400 Received: from mailgate01.nec.co.jp ([114.179.233.122]) by tyo161.gate.nec.co.jp (8.15.1/8.15.1) with ESMTPS id w6D6ZZ1l029912 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 13 Jul 2018 15:35:35 +0900 Received: from mailsv01.nec.co.jp (mailgate-v.nec.co.jp [10.204.236.94]) by mailgate01.nec.co.jp (8.15.1/8.15.1) with ESMTP id w6D6ZZRi013368; Fri, 13 Jul 2018 15:35:35 +0900 Received: from mail03.kamome.nec.co.jp (mail03.kamome.nec.co.jp [10.25.43.7]) by mailsv01.nec.co.jp (8.15.1/8.15.1) with ESMTP id w6D6YSGI006042; Fri, 13 Jul 2018 15:35:35 +0900 Received: from bpxc99gp.gisp.nec.co.jp ([10.38.151.149] [10.38.151.149]) by mail02.kamome.nec.co.jp with ESMTP id BT-MMP-1964812; Fri, 13 Jul 2018 15:31:27 +0900 Received: from BPXM23GP.gisp.nec.co.jp ([10.38.151.215]) by BPXC21GP.gisp.nec.co.jp ([10.38.151.149]) with mapi id 14.03.0319.002; Fri, 13 Jul 2018 15:31:26 +0900 From: Naoya Horiguchi To: Dan Williams CC: "linux-nvdimm@lists.01.org" , Michal Hocko , "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" Subject: Re: [PATCH v5 05/11] mm, madvise_inject_error: Let memory_failure() optionally take a page reference Thread-Topic: [PATCH v5 05/11] mm, madvise_inject_error: Let memory_failure() optionally take a page reference Thread-Index: AQHUE+ETIYw2FKVFeEC6cnQsWjGMfKSMJ5yA Date: Fri, 13 Jul 2018 06:31:25 +0000 Message-ID: <20180713063125.GA10034@hori1.linux.bs1.fc.nec.co.jp> References: <153074042316.27838.17319837331947007626.stgit@dwillia2-desk3.amr.corp.intel.com> <153074044986.27838.16910122305490506387.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <153074044986.27838.16910122305490506387.stgit@dwillia2-desk3.amr.corp.intel.com> Accept-Language: en-US, ja-JP Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.51.8.80] Content-Type: text/plain; charset="iso-2022-jp" Content-ID: Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-TM-AS-MML: disable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Dan, On Wed, Jul 04, 2018 at 02:40:49PM -0700, Dan Williams wrote: > 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); MF_COUNT_INCREASED means that the page refcount for memory error handling is taken by the caller so you don't have to take one inside memory_failure(). So this code don't keep with the definition, then another refcount can be taken in memory_failure() in normal LRU page's case for example. As a result the error message "Memory failure: %#lx: %s still referenced by %d users\n" will be dumped in page_action(). So if you want to put put_page() in madvise_inject_error(), I think that put_page(page); ret = memory_failure(pfn, 0); can be acceptable because the purpose of get_user_pages_fast() here is just getting pfn, and the refcount itself is not so important. IOW, memory_failure() is called only with pfn which never changes depending on the page's status. In production system memory_failure() is called via machine check code without taking any pagecount, so I don't think the this injection interface is properly mocking the real thing. So I'm feeling that this flag will be wiped out at some point. Thanks, Naoya Horiguchi