From patchwork Fri Nov 9 06:47:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 10675363 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 8F1FD109C for ; Fri, 9 Nov 2018 06:47:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EF5C2DD3D for ; Fri, 9 Nov 2018 06:47:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7328F2DD51; Fri, 9 Nov 2018 06:47:38 +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 EA7CD2DD3D for ; Fri, 9 Nov 2018 06:47:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 82B696B0696; Fri, 9 Nov 2018 01:47:35 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 787F86B0698; Fri, 9 Nov 2018 01:47:35 -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 5BA006B0699; Fri, 9 Nov 2018 01:47:35 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id 104856B0696 for ; Fri, 9 Nov 2018 01:47:35 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id n22-v6so787488pff.2 for ; Thu, 08 Nov 2018 22:47:35 -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=RtdH+8fxry6h6Pbb8TY5o2YMHv5QWx+98Zgkeuvb6yk=; b=kfmSbXtBY81Kar2nnOst3QTWQc0kjqIZO5U1KHvnh5YRXMTyTodoCfnoT5C1tPIuTU TLpNR2/C2eeWI63QB4GxScjTTOIQ9KshuMP0U2DGVsc3GOPuJSH3wlM6Ql/9SzqmME1I vShrJe+3bHkbJg/nW2H8Rp2qa5Vz6Byz65f374W18gNb0BUqr258MdP2mrFFF5amKI9+ BH45CO71GRajQbd0f9aI4VJsSIDV+cVloXBNUe8MRSVoyAylSRvpXc2udz8fmP4wiM+i NBxCJF/rBo4p5Y36tsCZp4jLdtJLps8+8h4JFM8Kp/uRDLkADlolgCLr9lYL+51GTTyP YHWQ== X-Gm-Message-State: AGRZ1gK0wIl/OfXc8guvl6SaR9Rg+DT2yju2SoDUl3Ihhn9IjLWNiN/a RFc3B9Nx4ZH0rKyArvgqDeE4HH2JohMm99dJOsyAyQqeCjhLW3xFiBScanqSKActcNCPR9SG7AJ WGXFlQNvo/i4jI8nX99e5b8GOznL3hKzgYyTEQPXzSqEHRhjW+0+QfvNhrX4i8BFcbGJ+jJT9ib 1DD3TGp4XtZdjeZTGc1d6lIz2i0FrJDoxngFOsTXOgjhx63TXvzJzPl2+kOLQGFNUasTLXS0fqE JEfKM82TC1UUUUjxl2RAuHXWCpkWYzn+GSRPX6dkOLCg9NDBQYxWPdWMqOClCexmNRxaJfq4cVT AAql9DiU2yGhVdiTqtdV00rPVANtdKP+0iz9DiXfpnIIw1kx4wYxIF/SU0D+h4jTuYYeQEJkVg= = X-Received: by 2002:a62:2f04:: with SMTP id v4-v6mr4010897pfv.2.1541746054734; Thu, 08 Nov 2018 22:47:34 -0800 (PST) X-Received: by 2002:a62:2f04:: with SMTP id v4-v6mr4010878pfv.2.1541746053918; Thu, 08 Nov 2018 22:47:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541746053; cv=none; d=google.com; s=arc-20160816; b=IIHlPbifkgMf3s/0LJYSPXVAc3UHxHkte6p5ZqHWYVuP2R8gC1dnhxqiKfmlss6Nul dSTYzU7qzHvBS6DLHzHiKr6+CBr/NqWrn0xpa6da2jo+TODYXR1XGGf5NSqC4706GkUQ AfzMIE5l3mwLwJc5q4MU3EQPNMGb1BXaE+V3FPN1pYRYCwTFty8ZzLvFV3BPGoDrJwRx WNXVTUVvPJgXCyCcBaEc89kkuu4POiRz/+PbPqHA5y6fJoX34nAcUSThOd/uKPkdiW8h 1zuLFXAuWjjR0eKKu86bTM9re++3xhb3Fc4DE02gORlrH150omOLnnOpIKIOAo0DraAc TE1w== 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=RtdH+8fxry6h6Pbb8TY5o2YMHv5QWx+98Zgkeuvb6yk=; b=v0kiPCQK88WTwGflqkFd0sux13LORiT3PzZ631naqwNnmajKhy8SE9+ROc6mGw4iw9 rst8gM3JdOq7S0miTQkatZegE9793b7vxaNZygNr4nkZJjeloHUzULgGO5krkSkvgZos bQiTkJkL8nY53HhRslMqx35n6UrWGpAtE6HBWM039HAX030tBZQMpuuM6ey9TohesYK5 fH/Sa/6WPjQWEFTh0jj1+eS8IVC8+gbuJk93To7F/48mRdyjECCFFDI0tbWJWTD0jAgn yJLRXYgR3wyVuE9skzSB5Zxx8TaDZ0fjCT+zREqYMW/zDu+S88uzOTZQ62CVNfO+bF3O gojQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ElkJIby2; 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 b21-v6sor8159922pfj.13.2018.11.08.22.47.33 for (Google Transport Security); Thu, 08 Nov 2018 22:47:33 -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=ElkJIby2; 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=RtdH+8fxry6h6Pbb8TY5o2YMHv5QWx+98Zgkeuvb6yk=; b=ElkJIby278Z9CaOTZIBqEFv9pFIG/BYuKQHgnezzaRdylmojC0zbp8sBRtVX/oV8PC yHBNaT2B8o841kQMAdzwDZGY39pWLzykg7ApEESA4gMcaGk42bMEVpbfzW1z38Aatuo3 LHzq3XwPNzxzYKCURxEt9WeQ6/wCS5tLxGid6QSkWRiG3ohbmZ/XNCEOZPI30urS22cL pik/Y9uAs1WaHup86v7sr8O5anrg6+B4SIaah/7QZJKWtHLwtvSSHoJm0HabxjLfbGJw dGY4ptfGWhQfR4Qtl+EU/zbwdclwjpwLmSkKbzpNI64knX6ATyQ7s03LyiFtzJ8ypdLz 6nDQ== X-Google-Smtp-Source: AJdET5dLYkKAGMikx0AVM1cpBD5gra2rJpxrwthuU9y4IFa1nzMP838s9nBknpVJS7aYq3HFCeZBkw== X-Received: by 2002:a62:7d10:: with SMTP id y16-v6mr7716522pfc.245.1541746053458; Thu, 08 Nov 2018 22:47:33 -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.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 22:47:32 -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 02/11] mm: soft-offline: add missing error check of set_hwpoison_free_buddy_page() Date: Fri, 9 Nov 2018 15:47:06 +0900 Message-Id: <1541746035-13408-3-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 set_hwpoison_free_buddy_page() could fail, then the target page is finally not isolated, so it's better to report -EBUSY for userspace to know the failure and chance of retry. And for consistency, this patch moves set_hwpoison_free_buddy_page() in unmap_and_move() to __soft_offline_page(). Fixes: 6bc9b56433b7 ("mm: fix race on soft-offlining free huge pages") Signed-off-by: Naoya Horiguchi --- mm/memory-failure.c | 15 ++++++++++++--- mm/migrate.c | 9 --------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git v4.19-mmotm-2018-10-30-16-08/mm/memory-failure.c v4.19-mmotm-2018-10-30-16-08_patched/mm/memory-failure.c index 9f09bf3..11e283e 100644 --- v4.19-mmotm-2018-10-30-16-08/mm/memory-failure.c +++ v4.19-mmotm-2018-10-30-16-08_patched/mm/memory-failure.c @@ -1719,14 +1719,18 @@ static int soft_offline_huge_page(struct page *page, int flags) /* * We set PG_hwpoison only when the migration source hugepage * was successfully dissolved, because otherwise hwpoisoned - * hugepage remains on free hugepage list, then userspace will - * find it as SIGBUS by allocation failure. That's not expected - * in soft-offlining. + * hugepage remains on free hugepage list. The allocator ignores + * such a hwpoisoned page so it's never allocated, but it could + * kill a process because of no-memory rather than hwpoison. + * Soft-offline never impacts the userspace, so this is + * undesired. */ ret = dissolve_free_huge_page(page); if (!ret) { if (set_hwpoison_free_buddy_page(page)) num_poisoned_pages_inc(); + else + ret = -EBUSY; } } return ret; @@ -1804,6 +1808,11 @@ static int __soft_offline_page(struct page *page, int flags) pfn, ret, page->flags, &page->flags); if (ret > 0) ret = -EIO; + } else { + if (set_hwpoison_free_buddy_page(page)) + num_poisoned_pages_inc(); + else + ret = -EBUSY; } } else { pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx (%pGp)\n", diff --git v4.19-mmotm-2018-10-30-16-08/mm/migrate.c v4.19-mmotm-2018-10-30-16-08_patched/mm/migrate.c index f7e4bfd..1742372 100644 --- v4.19-mmotm-2018-10-30-16-08/mm/migrate.c +++ v4.19-mmotm-2018-10-30-16-08_patched/mm/migrate.c @@ -1199,15 +1199,6 @@ static ICE_noinline int unmap_and_move(new_page_t get_new_page, */ if (rc == MIGRATEPAGE_SUCCESS) { put_page(page); - if (reason == MR_MEMORY_FAILURE) { - /* - * Set PG_HWPoison on just freed page - * intentionally. Although it's rather weird, - * it's how HWPoison flag works at the moment. - */ - if (set_hwpoison_free_buddy_page(page)) - num_poisoned_pages_inc(); - } } else { if (rc != -EAGAIN) { if (likely(!__PageMovable(page))) {