From patchwork Fri Nov 9 06:47:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 10675367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7B79813BF for ; Fri, 9 Nov 2018 06:47:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B69E2DD3D for ; Fri, 9 Nov 2018 06:47:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FD0B2DD52; Fri, 9 Nov 2018 06:47:43 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham 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 D15F62DD3D for ; Fri, 9 Nov 2018 06:47:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 126426B069A; Fri, 9 Nov 2018 01:47:40 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0600E6B069C; Fri, 9 Nov 2018 01:47:39 -0500 (EST) 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 DA8DA6B069D; Fri, 9 Nov 2018 01:47:39 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 8D9C96B069A for ; Fri, 9 Nov 2018 01:47:39 -0500 (EST) Received: by mail-pg1-f200.google.com with SMTP id l2-v6so609587pgp.22 for ; Thu, 08 Nov 2018 22:47:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:sender:from:to:cc:subject:date :message-id:in-reply-to:references; bh=m0e0f9nzNxyxhpTcBsr3tCvUPNiuZ+bV+28ICuX+JQY=; b=lM43v9nd7f/vqPrGFwgXy+RGFCCJAb5xxaOt8fVMbTPrFUes0UC7HNq1Cxrln9mtIj wGT68KWTc6GI8WbYyYUVzr8ecrlI/rDyRtAyxP9jnxmOvchdnHTVc/S+UfsqGzC+qFd7 A0MKjuB7SwethleeiBwEekHkTVPaquWdqYXhwkW5J7dc1zhAcz5XYCLNi+AO1PFEoDdf EQH/50ssCMEFxiB+ICIC1KBRcTMp/dlyRiu6ZaW3x4W9zy+YZtXF2JbIp+aqJNw0eFt9 4iGi/oshHcRM48I9jZLirEhtnDOUVl0mQPmpmxwhn/uK5NYXZQPmKqwVcYsRxpeqi2W1 C4gQ== X-Gm-Message-State: AGRZ1gKTVTgT1d9KGHV0BegxsBSSxfWRZoox+IZ5ur9LA+26XkBwWB71 YoV4B9wP7LaHslIfBGS05dnz8Wqe5l1Gme7/QQH/2l6U8Uu9sAOYGwmYhY0cXjtuHmKsXNkzj1H xrirEM1c4dB8KCIGBR+wVCzXyk4pIx8YoMoR7ucmXKsYuXTnxoBH7IaH8ySs41J62AXTDZYV94f zfyq2VM8sU0GzL2hVJ+hPbIWLli2COIOOtvX3geuy0XCNjT/mt+6qR/yWHY37UC5QXb87ILgSHs zTSQ4ks3EaRVWcR1zMi2IydVtuSHiyJmMHW5P0J+IZV0l4CWZWRyUGyuO9q95ryAstkCmwl0zpX zWSmZYmpM5aLvyGcniBKR+qCQRnE8zUbyKcVeOim+dYcgv2MLeJMWJDsEpPAMuyczzddtfE3Xw= = X-Received: by 2002:a17:902:4281:: with SMTP id h1-v6mr7754698pld.114.1541746059196; Thu, 08 Nov 2018 22:47:39 -0800 (PST) X-Received: by 2002:a17:902:4281:: with SMTP id h1-v6mr7754672pld.114.1541746058444; Thu, 08 Nov 2018 22:47:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541746058; cv=none; d=google.com; s=arc-20160816; b=hWM+fZq6U5be5aoVQm2XInfJKHD4o0REnrc3GdvKp1cSF5aP2NENt6dvhK37LHAVEE +Lx14DltMFCW+ez115Zp0vhtxrHy27No5H7cF0wU/kMxg00fnk6JRnu8Bs9Qfxi+rttc LICZGlFNalnChGAt4lCFCcUxZzeBxf24auGptNkjeD4LQ0yp5yckeQcZTV794qHJGcsP SeL0Ms/16CGmblkosUQKl9kM00Ap7UBhzuPuS7u1gQ7pUcxf5QsdAhUB6IaCq03MBdPS omIPEU7eUjN9t5qDfnH+aeyynCuy/2jKvwo36ylULEz32CUCxgrF0slIDxPZTU8oOyGl j6zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=m0e0f9nzNxyxhpTcBsr3tCvUPNiuZ+bV+28ICuX+JQY=; b=1JuEnh0sClwBixn6OnGjLLaGS/ocExjuMD3u3Nqt/UPU6zKS7Et376HD84T9XmHqi4 uD84p3cTOkBFM4QgVeCwU/0n7n9H65H9jrxXGf9f/yxL8OKm0UqQqva7IzAZqtuhNR1g VjVuHRJAJDjo2dlldmb3k6Uif2cL+xeRPPMq7Tn5TsXO6FnXplWWOauUAFjunOgZECL8 oMRlW7iBYktq4XqLGq4wmzYxeCO6fuojdsi7yXcnmkKRp1mln1fkJVYCWSJTzq/YnDLH dyvdKXP+WVZDQVj95Wv5AcMllD3abvg56pw1QrHVhIhlak0qSqNkaSXk9Fe8g5guLU7f z5aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=f3fUO3sG; spf=pass (google.com: domain of nao.horiguchi@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=nao.horiguchi@gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id e16-v6sor6947988pgh.17.2018.11.08.22.47.38 for (Google Transport Security); Thu, 08 Nov 2018 22:47:38 -0800 (PST) Received-SPF: pass (google.com: domain of nao.horiguchi@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=f3fUO3sG; spf=pass (google.com: domain of nao.horiguchi@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=nao.horiguchi@gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=m0e0f9nzNxyxhpTcBsr3tCvUPNiuZ+bV+28ICuX+JQY=; b=f3fUO3sGOcfSkELF9VhwEATDLBjrZFtcbQKPtLzgiXaaYkML+7ejQCSpk2OalDEGzH lGsQBO43VDXY1NSNNnMO1qYjoh8fvUjH4AxaVhvqn7WvR3CnMtDmZEfFEnRmGcPpgDqC l2E0WUeLgN5ZFbJ8VY0FtBUpgdrOvxiFuiVOlSb+O3z73r9ia4od8Oi1C33rlMuxct/x izmo4xhtAIVtMDAESf57lGJHicM4lMWhwPvIPf6G7cWacr82ehZCx1aoBkBPvz7fyVBW MM1DWevtTcBipdEwBQxYder+tGsTmNtEVTb5ibLZOs4J6Gldrw5EujN9T9ZkOE2iEjmu A4tA== X-Google-Smtp-Source: AJdET5eQnu/2Z9HBZ98qfYLw+/ijhzOTROzAPjFfw2esGCkLFwrTpsn+UNpgSRk7SDYzPGhWflz7YA== X-Received: by 2002:a63:1b1f:: with SMTP id b31mr6399252pgb.66.1541746057988; Thu, 08 Nov 2018 22:47:37 -0800 (PST) Received: from www9186uo.sakura.ne.jp (www9186uo.sakura.ne.jp. [153.121.56.200]) by smtp.gmail.com with ESMTPSA id c70-v6sm6808355pfg.97.2018.11.08.22.47.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 22:47:37 -0800 (PST) From: Naoya Horiguchi To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Michal Hocko , Andrew Morton , Mike Kravetz , xishi.qiuxishi@alibaba-inc.com, Laurent Dufour Subject: [RFC][PATCH v1 04/11] mm: madvise: call soft_offline_page() without MF_COUNT_INCREASED Date: Fri, 9 Nov 2018 15:47:08 +0900 Message-Id: <1541746035-13408-5-git-send-email-n-horiguchi@ah.jp.nec.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1541746035-13408-1-git-send-email-n-horiguchi@ah.jp.nec.com> References: <1541746035-13408-1-git-send-email-n-horiguchi@ah.jp.nec.com> 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 Currently madvise_inject_error() pins the target page when calling memory error handler, but it's not good because the refcount is just an artifact of error injector and mock nothing about hw error itself. IOW, pinning the error page is part of error handler's task, so let's stop doing it. Signed-off-by: Naoya Horiguchi --- mm/madvise.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git v4.19-mmotm-2018-10-30-16-08/mm/madvise.c v4.19-mmotm-2018-10-30-16-08_patched/mm/madvise.c index 6cb1ca9..9fa0225 100644 --- v4.19-mmotm-2018-10-30-16-08/mm/madvise.c +++ v4.19-mmotm-2018-10-30-16-08_patched/mm/madvise.c @@ -637,6 +637,16 @@ static int madvise_inject_error(int behavior, ret = get_user_pages_fast(start, 1, 0, &page); if (ret != 1) return ret; + /* + * The get_user_pages_fast() is just to get the pfn of the + * given address, and the refcount has nothing to do with + * what we try to test, so it should be released immediately. + * This is racy but it's intended because the real hardware + * errors could happen at any moment and memory error handlers + * must properly handle the race. + */ + put_page(page); + pfn = page_to_pfn(page); /* @@ -646,16 +656,11 @@ static int madvise_inject_error(int behavior, */ order = compound_order(compound_head(page)); - if (PageHWPoison(page)) { - put_page(page); - continue; - } - if (behavior == MADV_SOFT_OFFLINE) { pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n", pfn, start); - ret = soft_offline_page(page, MF_COUNT_INCREASED); + ret = soft_offline_page(page, 0); if (ret) return ret; continue; @@ -663,14 +668,6 @@ static int madvise_inject_error(int behavior, pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n", pfn, start); - - /* - * 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(pfn, 0); if (ret) return ret;