From patchwork Fri Nov 9 06:47:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 10675361 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 3373E109C for ; Fri, 9 Nov 2018 06:47:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22B3D2DD3D for ; Fri, 9 Nov 2018 06:47:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 16CFF2DD51; Fri, 9 Nov 2018 06:47:36 +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 A712B2DD3D for ; Fri, 9 Nov 2018 06:47:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FB046B0694; Fri, 9 Nov 2018 01:47:33 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 27FDE6B0696; Fri, 9 Nov 2018 01:47:33 -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 14D266B0697; Fri, 9 Nov 2018 01:47:33 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id B35616B0694 for ; Fri, 9 Nov 2018 01:47:32 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id g24-v6so752790pfi.23 for ; Thu, 08 Nov 2018 22:47:32 -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=l5JKmNzvuS6iydaU7R8RUszNW4wpAmUInCK2c9kGsbo=; b=QBePMLJImeKv8SO21nYA0lC7z/aBKa8550JOLWW05iKRlTeKHca2jE0JQpQAMeCWyh TfO8WuBsdwx0jwnCGjnsXVhNg10ji7tYPac9rALbw30TXy33MgUtsVs5dNVHW5WReXlS LAy8SRa88RHgE8yvEEBvnEYi5t8ZqWVuh1pYDG6njVpNXIsth6oaBIW0I8yU44me8zVv mJl87DLlBQo/bIgW1QWsHymd4wYTfi/3UabWOYtjHrGapFvCX/aHguD7liLaMtn7Yrjx m034XfHnkCrRIgnpRrweXLdLgja18mOaxPfeApaUlPqQHZ4MgRGGBWFOCSKcuPcrj4Ie I1tg== X-Gm-Message-State: AGRZ1gJYVNq0CHSVeXgnJDFkXJ4fobSldehNwm7DDPncH9LXQrXT+3uV WCsslEi+3LPNDZvrl68QNflr99sfMY41vt74HDRsWvUvIKwu2fNymWMSRWf6+88BoQReHRaGK8i otU3b5HM07N6oLRRrJRH1GyX9mrIizEuSRywikrN0++5R6RWHEI3W04N30X1g8DdHuj93+x+I78 Wurdp91yUKqc3x8ZyHPQR0V9TrbxGhrG4cDjLPdb/TZQo+pMZeUPy7/Z8h5otbyRlPOyT1pS5zC pBKAxMxzNhs4/V3OuN+OReFqNgTiwgBNIs/JFjCPlAReHJcLTeWZhzEIRzTxTypvtux9aYWIQlx CZFKkduGhyzOjBtPxdetIo9s4gYLAiL2QsGLNPuIgrUfHhRDM7fVB/TtcQqJhEXXdGyv3S/N5g= = X-Received: by 2002:a17:902:a81:: with SMTP id 1-v6mr7814530plp.75.1541746052406; Thu, 08 Nov 2018 22:47:32 -0800 (PST) X-Received: by 2002:a17:902:a81:: with SMTP id 1-v6mr7814504plp.75.1541746051718; Thu, 08 Nov 2018 22:47:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541746051; cv=none; d=google.com; s=arc-20160816; b=yrs5kUXXaQts2eFQdZMXumIK5x8OLt6/WeSJZfkGakjkD5NVKGUnU7OKybP5YxxdZp 3mADSkCQfVMwkyhwT/ofWLvOqM+IdGxcqiEYtoVxOwuEIeTAyMXmdkaPq8Qxn6qlyYH2 Zyy7DhLWW9MmIA0py+7KX9yb8tWtHXY96iIvHcyqZa4V9IopcQxSZe+oRt6LUVpeGwcH ZsaBgOFCldTqicTssgpwJXC0mHM2SXnG9Ztffl8U31DvAUTk+agay8+2tePQHCc3DgWk HQhOopQBV101YQ49dinr9I1Z7kMtr3CVbTxzzDy2otoadZsoq7nP4SZsWFWwzf/nRmUy lt7w== 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=l5JKmNzvuS6iydaU7R8RUszNW4wpAmUInCK2c9kGsbo=; b=YgbD32h/R8VSsq42jK58UlIHh9cnYVAyIsNnvGWD2zwHliqJvz+XJVq5bjp4TB4aQe HbYQIIL9kNmWvYefib/Dlb2/b9U1v/1MfD1HVCIgiUwpxbOGwyowJiOlCnS+EMw3UW7q M71fxcdxpY8fcL1VhfngAP4Ekxw7OaZ+0sCfhPIdRd54KGLXioQcAvjGwFBewOGuGB15 J+P/zFVazXqUzLfHJwFY5BDspAKgk6zHTqVEmjjWinxp76N1+6LI1GMleyoXjqy+R+sF MBD7xDv+Nd0Nv6Yzyk9DFUKix5PGZueSpi3pjZiI+UDI5HWZAHxJPhdVAtQHr1pLKHwj qoVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QBrLpFYq; spf=pass (google.com: domain of nao.horiguchi@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=nao.horiguchi@gmail.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id s17-v6sor7675424plp.3.2018.11.08.22.47.31 for (Google Transport Security); Thu, 08 Nov 2018 22:47:31 -0800 (PST) Received-SPF: pass (google.com: domain of nao.horiguchi@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QBrLpFYq; spf=pass (google.com: domain of nao.horiguchi@gmail.com designates 209.85.220.41 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=l5JKmNzvuS6iydaU7R8RUszNW4wpAmUInCK2c9kGsbo=; b=QBrLpFYqjQqSzfJK2rEnyXBfL6T8klW/IUbhJN3W/bGV0Gs55PMBGD1XAm4vdoWuhW xf4dHw2MQxKoaq8pFc+jw7EO6rK/0YkYCShBfJ33coD4lXrLFHhgmE1Jx9XravpmDPPR YO6xbHyJ2TlyuJ92Mtb4EDzFvaPtJM8YRanNfSxFWtMOOE5noY3ktidEsJBt2l+ZSrKk RMy+Rc3+UozEdlhcIVzGzvOrGYlbYEvOVfZArTIoIBHKloWHs952T5vjavHdoAjc2wYq sjjPl1iEBJ2G94QrJQxRalQCeTANjlCRJxMqp+vXw4iOUjbtklGwoLlPtABb3y3V4MMy mcQw== X-Google-Smtp-Source: AJdET5dgd3jDkoTeItxOkwHKWaCdYuYsaDeMUfeKi/y49QAwEpmRbauWlBf6nr8MS45dyDvKJOatCw== X-Received: by 2002:a17:902:ab83:: with SMTP id f3-v6mr7455402plr.122.1541746051224; Thu, 08 Nov 2018 22:47:31 -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.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 22:47:30 -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 01/11] mm: hwpoison: cleanup unused PageHuge() check Date: Fri, 9 Nov 2018 15:47:05 +0900 Message-Id: <1541746035-13408-2-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 memory_failure() forks to memory_failure_hugetlb() for hugetlb pages, so a PageHuge() check after the fork should not be necessary. Signed-off-by: Naoya Horiguchi Reviewed-by: Anshuman Khandual --- mm/memory-failure.c | 5 +---- 1 file changed, 1 insertion(+), 4 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 0cd3de3..9f09bf3 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 @@ -1357,10 +1357,7 @@ int memory_failure(unsigned long pfn, int flags) * page_remove_rmap() in try_to_unmap_one(). So to determine page status * correctly, we save a copy of the page flags at this time. */ - if (PageHuge(p)) - page_flags = hpage->flags; - else - page_flags = p->flags; + page_flags = p->flags; /* * unpoison always clear PG_hwpoison inside page lock 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))) { From patchwork Fri Nov 9 06:47:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 10675365 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 1280113BF for ; Fri, 9 Nov 2018 06:47:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01F562DD3D for ; Fri, 9 Nov 2018 06:47:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAB892DD51; Fri, 9 Nov 2018 06:47:40 +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 619242DD3D for ; Fri, 9 Nov 2018 06:47:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5DED66B0698; Fri, 9 Nov 2018 01:47:38 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 565446B069A; Fri, 9 Nov 2018 01:47:38 -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 3BD956B069B; Fri, 9 Nov 2018 01:47:38 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id E58676B0698 for ; Fri, 9 Nov 2018 01:47:37 -0500 (EST) Received: by mail-pf1-f199.google.com with SMTP id 190-v6so777205pfd.7 for ; Thu, 08 Nov 2018 22:47:37 -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=I5gsSunXdH895MmsSOVcjAuo3r5POwuiCmdFP97vCrk=; b=Z4mygZ/SpKm85NH7bV1w1VL2a84y35EqWg+zgvdqkkUknnt4ywjv5Uhv1/zQVMW/yz TduiYP93kus58/oPxbW0RhVuWccZ22xcoOG5Ad5tPN2O6Jqrlkb6BooYbIyz0mqkFaxq tAf8YOApoIDg4Wvue0eyC2N5FrtkGUb17YG1kyipJph613VXCkq+T5NB2Vfud1aprzP/ r4jkb/N0SupsJjZwkg+81hF0ZtW+5qF6vhxH0drc4OAlSrXAf1j3pBRtymfu7huRrvti AdK6NwSeW1AqJXR/Z4HaBXKiAPkiWrAwbZyAD9PLmIWODganVSJcOaehmL6lYRSjsvbe d8VA== X-Gm-Message-State: AGRZ1gI/B9QIsd00g/ZfXgywIuje/12g6/wib9ZYm9Y+vAyScx/FirE1 xUOtrL20EVINNlkVVcR2Oiznv+qFg9BlR+odHkQMYWepiZv93+tUrfLVMihFwBEkGv8t7VNugPb imbMPDjRBrtgfxXpwhF8U5qoZT5BuG0a7AqFqi+rLPz/UDqzP2IX0JjTiuqpu5R/y+ASG7wTLAw Cds5ghXq7+AIdQpxqhM7TV2GwR23X5lxncNU9YCmgrrxxG3i62OPObjC94aVly7dcOXlGbIB/UK rADYuflTqEKk8WZiE2MzrHQzU9C4qodjgqxVl7mj/H73y4Mh/ddHHWTp2kz0mtoRqfwun5eybRO A4sLlEujEFUhnOrV/nvEcVG9MinTUbvXCboU0YOugUYVaAJjhLWA0puxa0bYz1YnXmbTFNmG4Q= = X-Received: by 2002:a63:1204:: with SMTP id h4mr6456182pgl.51.1541746057553; Thu, 08 Nov 2018 22:47:37 -0800 (PST) X-Received: by 2002:a63:1204:: with SMTP id h4mr6456140pgl.51.1541746056231; Thu, 08 Nov 2018 22:47:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541746056; cv=none; d=google.com; s=arc-20160816; b=tJFFyf/A9/1JIqC80gTELoTJ0wWmgtvZCWAMmjq8FZYkq4gtZ8i4E13SzEjNQCN+1a hejfCzLnRFYMki09fispOYAC00TUj4SjUa/XFlffZi9Qw2B/8nkT1TaJ97mUSVThJMxM ewSJJHD76h+zCsz/y5jiSzaxN0M/NXFoxfPxUiv8fQF/MN/urCk+WMCv33F9/t0gsVEp RfNEzo+K9kL5BgondP6IFJR4ISjcWy1ldC9rCHC+UcuocsvxUmCeW0dxow01J7i13kEY UBlN+Qlf+YehteUwuq9+AcO9Hn2wnpMGr0c99ShbJO4d3hnpjSH4p2GuwjTvKhVtCD86 cWQg== 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=I5gsSunXdH895MmsSOVcjAuo3r5POwuiCmdFP97vCrk=; b=O9AOa8yTytV4Lbgs+WBzBqqKNPQ6hjdzkO2huQ9RRfEXlUMGZGPIXbKhz3hAvdjUhr smLEDWDHDwR9W6YIt7MPJVmz4K1BTRNEwjF8j8JpdiQzhEnUdNuHjyRWlOxqwS8LnDYH OfD95+y5Z2bcYISDcIc1DB2Z1agm+sMqdVOD4lnwXT9Wnn4sajbpw6opp/ol5y3xpPqE xAImG+q8RWVdeM04vD9EMLYfnk8rhfca57NJO5gN7UeHSKyc+1U/rBI+zds5L7Nyq4g7 BL6PVk6XYcnIEBuYXkltUjsUAGl845i3xh+oIgQaVktY8L+gxe/w782gieTGiC6elDDy iwOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sdRN1yRf; 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 j12-v6sor7852419plk.37.2018.11.08.22.47.36 for (Google Transport Security); Thu, 08 Nov 2018 22:47:36 -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=sdRN1yRf; 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=I5gsSunXdH895MmsSOVcjAuo3r5POwuiCmdFP97vCrk=; b=sdRN1yRf9dBJRcb+kLIszEwQGdNQOZ/Cr+T69TTOG33+p7+lHSgokccxp12AmGcVIv b91zsOA4UMyF4L+oVL6LsmtmQ0mrUPXuofZRoGL2SArKd4t78l8//9OXDgx2DByLzwTH bgn+qlrl5d8UAp2EsmA5ST/wxze2XAq74fATX8SIK1LqbWEWaxtnpfmlLifaIrlgvM2T +KVOe7h4t1J6EV679ilKNSH27x7hciLKHKWR36KGpRkR3Y8utPdIl0luWG0Zz028cmxA W3eGSr7QcHdRS1QEaYGPjeykA6PaFyjQ8LBPWvy/4j6IrhNw8DC3u40Jf+I+3hNC3Iu7 QedQ== X-Google-Smtp-Source: AJdET5eg902nQvUWpouttJ+YLnryXSQ9Zt4zI710Y5VxL9S/LDzptvX0L/igyGaFSk4UGTH0C2OnIw== X-Received: by 2002:a17:902:2cc1:: with SMTP id n59-v6mr542277plb.26.1541746055768; Thu, 08 Nov 2018 22:47:35 -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.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 22:47:35 -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 03/11] mm: move definition of num_poisoned_pages_inc/dec to include/linux/mm.h Date: Fri, 9 Nov 2018 15:47:07 +0900 Message-Id: <1541746035-13408-4-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 num_poisoned_pages_inc/dec had better be visible to some file like mm/sparse.c and mm/page_alloc.c (for a subsequent patch). So let's move it to include/linux/mm.h. Signed-off-by: Naoya Horiguchi Reviewed-by: Anshuman Khandual --- include/linux/mm.h | 13 ++++++++++++- include/linux/swapops.h | 16 ---------------- mm/sparse.c | 2 +- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git v4.19-mmotm-2018-10-30-16-08/include/linux/mm.h v4.19-mmotm-2018-10-30-16-08_patched/include/linux/mm.h index 59df394..22623ba 100644 --- v4.19-mmotm-2018-10-30-16-08/include/linux/mm.h +++ v4.19-mmotm-2018-10-30-16-08_patched/include/linux/mm.h @@ -2741,7 +2741,7 @@ extern void shake_page(struct page *p, int access); extern atomic_long_t num_poisoned_pages __read_mostly; extern int soft_offline_page(struct page *page, int flags); - +#ifdef CONFIG_MEMORY_FAILURE /* * Error handlers for various types of pages. */ @@ -2777,6 +2777,17 @@ enum mf_action_page_type { MF_MSG_UNKNOWN, }; +static inline void num_poisoned_pages_inc(void) +{ + atomic_long_inc(&num_poisoned_pages); +} + +static inline void num_poisoned_pages_dec(void) +{ + atomic_long_dec(&num_poisoned_pages); +} +#endif + #if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_HUGETLBFS) extern void clear_huge_page(struct page *page, unsigned long addr_hint, diff --git v4.19-mmotm-2018-10-30-16-08/include/linux/swapops.h v4.19-mmotm-2018-10-30-16-08_patched/include/linux/swapops.h index 4d96166..88137e9 100644 --- v4.19-mmotm-2018-10-30-16-08/include/linux/swapops.h +++ v4.19-mmotm-2018-10-30-16-08_patched/include/linux/swapops.h @@ -320,8 +320,6 @@ static inline int is_pmd_migration_entry(pmd_t pmd) #ifdef CONFIG_MEMORY_FAILURE -extern atomic_long_t num_poisoned_pages __read_mostly; - /* * Support for hardware poisoned pages */ @@ -336,16 +334,6 @@ static inline int is_hwpoison_entry(swp_entry_t entry) return swp_type(entry) == SWP_HWPOISON; } -static inline void num_poisoned_pages_inc(void) -{ - atomic_long_inc(&num_poisoned_pages); -} - -static inline void num_poisoned_pages_dec(void) -{ - atomic_long_dec(&num_poisoned_pages); -} - #else static inline swp_entry_t make_hwpoison_entry(struct page *page) @@ -357,10 +345,6 @@ static inline int is_hwpoison_entry(swp_entry_t swp) { return 0; } - -static inline void num_poisoned_pages_inc(void) -{ -} #endif #if defined(CONFIG_MEMORY_FAILURE) || defined(CONFIG_MIGRATION) diff --git v4.19-mmotm-2018-10-30-16-08/mm/sparse.c v4.19-mmotm-2018-10-30-16-08_patched/mm/sparse.c index 33307fc..7ada2e5 100644 --- v4.19-mmotm-2018-10-30-16-08/mm/sparse.c +++ v4.19-mmotm-2018-10-30-16-08_patched/mm/sparse.c @@ -726,7 +726,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages) for (i = 0; i < nr_pages; i++) { if (PageHWPoison(&memmap[i])) { - atomic_long_sub(1, &num_poisoned_pages); + num_poisoned_pages_dec(); ClearPageHWPoison(&memmap[i]); } } 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; From patchwork Fri Nov 9 06:47:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 10675369 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 41818109C for ; Fri, 9 Nov 2018 06:47:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 311252DD3D for ; Fri, 9 Nov 2018 06:47:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 257492DD52; Fri, 9 Nov 2018 06:47:46 +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 B078E2DD3D for ; Fri, 9 Nov 2018 06:47:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BAF2D6B069C; Fri, 9 Nov 2018 01:47:42 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B32386B069E; Fri, 9 Nov 2018 01:47:42 -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 9AD526B069F; Fri, 9 Nov 2018 01:47:42 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id 44BF06B069C for ; Fri, 9 Nov 2018 01:47:42 -0500 (EST) Received: by mail-pg1-f199.google.com with SMTP id w7-v6so634483pgi.3 for ; Thu, 08 Nov 2018 22:47:42 -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=9DJFcKlJJiJ+Adjp9pPwaHOqo/nJGemRGYZuMELBj8A=; b=d5H3mqc2CcL4gjdnzDtddsOMHAw79OiAh7BWVsZK03HldGuDJPE2gyxnGjV/QiiNuO q/F1LA6FIZXoVj8LJipKUpas1iDUqcScY6U2++Sq4fvhcSFM1z2cycO6ojTemjzdoVzY twIEOKFXRuIG9pSaxgFqJyFj+AXjOKQw4cGhmnGv1IOrI4AjaZQWtZot7gY1PUn1Sk6k SxXvhWyMiU6lQWMLDixx9aXrEs24hWtBJi+LWSxr4CUy0HttPGsAHB43iBlna0lpedKY 87CVosRlrMMLe5to4JZfszK59dOcpIHBRIBp3kNB4AjBWk8HNWsSlObfg5m9DO/ShkxN 6QIA== X-Gm-Message-State: AGRZ1gKQyEzcQGyN1L6pRmqoL81ZrqNpVGPZh5VLUg+HCusG97yXXJ41 bucFUerLs4aS+itKLI+XhTSX9FJunF9KzuRbe35lDvbojZusG2Tz/DtDRBBixlJHop0OvZr3nbb hn84FqPkj6uLeouGAUeZmve+3bwFeTcT/nwn/GPxTRei+11e5TAUcJrRyDzqpqWUkf9nWxpq7uH jcGk4kHhEFdqGvR94At2J8JLntNWaCm4fpfeFtds76ikzUKT0G8LwRY2BqPebsb9Hw5BAPBi1NQ JPMqE4YnuPx4QzFZS4hW0CU49IWXlCuXuxy4GKBiRBPyN+Srdkpna0GSaLxXBw+eKlCQGyfuYux UGdCWhK7Lxyc7QNjWyJfsh6tM5y5aZGulYXDmomZ1c+kxC44nY6omRpiqROSfraqZcaKmhjpDA= = X-Received: by 2002:a17:902:4324:: with SMTP id i33-v6mr7849033pld.253.1541746061951; Thu, 08 Nov 2018 22:47:41 -0800 (PST) X-Received: by 2002:a17:902:4324:: with SMTP id i33-v6mr7848992pld.253.1541746060615; Thu, 08 Nov 2018 22:47:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541746060; cv=none; d=google.com; s=arc-20160816; b=YoIo2tsv6Xm7QWxVxTHshIA8yz2AL9wOd57FxgGFld0leYNfSSfbRO1fTUysDEFcFB BFotNC46xIg8zIoLYXX3mzpy/4o0EkVUjc5DcYHQMVg9c8WhxhanYgU5dmzy860fZ2RA 5QxQ2C2a124DoGSq0JFoxQUq6rqLpEbPOAWBG7HvF5EsKn+EsIeewrnLoetsDrVyrwIz uGsKy3RBjq1EqR1WcvxlC1KyDbpKQEa+RyPgQxe2BB6hAryRhxo+ujth20cDEnh67LzX bDD//9eAxBfHa0pEhsX7MWWGswOj4w+wAT6tbDVYK0eCIurXo+ESjNVMt4y7I5wNzjDT HA3g== 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=9DJFcKlJJiJ+Adjp9pPwaHOqo/nJGemRGYZuMELBj8A=; b=LWVkzabyos8X1IvA/uDfqgEdXRDzCBmlroDzpCKGT3YvtH1zBKshw3x9vdnl+rT9wa 9MZpiNFXZMNoJl1218sh2zxpZyMA16CdoXLW3XeR2WKsdisGNsQrN0NYTWObpcY7WcJ8 fQhk0Yf/iratXxXFii1b/YSC7tQeawoBLr7/CQy1YlxQKMeNorzTPYo26aRT06P7epam WdXQMjwTzXxZlzpYxASDPpFc9l1XMxm6S6wNfnqVZWmhCy5ZmlWXFcSQhOUO6t7IMwy4 QissyVOHR8Z3gSepMj+JWI8+wSLQHLbdNGWbZwgtygHoAtdBa6b+gbrhp6lXWyMvhyQw sQlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uQCid65T; 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 b1-v6sor7829870plr.70.2018.11.08.22.47.40 for (Google Transport Security); Thu, 08 Nov 2018 22:47:40 -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=uQCid65T; 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=9DJFcKlJJiJ+Adjp9pPwaHOqo/nJGemRGYZuMELBj8A=; b=uQCid65TF8sng2YSSfz4J4DdW5Or8lUZ8VX5K8FXmbK6ie7EpUB9Rg3E81Z+ZKzh75 x6JxMb8pw79ckVogFV5IJd81nJcjoRBj8XA1tHzURc5tneRQ+HUDfOmAGmw55jjyUvEs YreOhgU4/Z5Ik2lxFQtHDiZDyge5PiquAMF1aEh+rk9diamSA/koWheiesZ0itasdbaU 97yU45tEDNUYzpEYS6YNVdzPIMJuED/OZiuXFD02YW1fHBAJhy7TbDse9LQpH0lpv3k8 udtveFHnbfRa2hyqcL747oEIj/OEb0NvKWCyy+5Yl1DLCTDWp8WKBQC8O2W6Cw4YxCdz sy8A== X-Google-Smtp-Source: AJdET5c18VaLRA2NAXOA8WsQgpjRuBVfBbcG23XHcUbq5h80KjAALEeN9ruRMTSSaEPaypfq9ccq3g== X-Received: by 2002:a17:902:8486:: with SMTP id c6-v6mr7466272plo.119.1541746060224; Thu, 08 Nov 2018 22:47:40 -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.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 22:47:39 -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 05/11] mm: hwpoison-inject: don't pin for hwpoison_filter() Date: Fri, 9 Nov 2018 15:47:09 +0900 Message-Id: <1541746035-13408-6-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 Another memory error injection interface debugfs:hwpoison/corrupt-pfn also takes bogus refcount for hwpoison_filter(). It's justified because this does a coarse filter, expecting that memory_failure() redoes the check for sure. Signed-off-by: Naoya Horiguchi --- mm/hwpoison-inject.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git v4.19-mmotm-2018-10-30-16-08/mm/hwpoison-inject.c v4.19-mmotm-2018-10-30-16-08_patched/mm/hwpoison-inject.c index b6ac706..766062c 100644 --- v4.19-mmotm-2018-10-30-16-08/mm/hwpoison-inject.c +++ v4.19-mmotm-2018-10-30-16-08_patched/mm/hwpoison-inject.c @@ -25,11 +25,6 @@ static int hwpoison_inject(void *data, u64 val) p = pfn_to_page(pfn); hpage = compound_head(p); - /* - * This implies unable to support free buddy pages. - */ - if (!get_hwpoison_page(p)) - return 0; if (!hwpoison_filter_enable) goto inject; @@ -39,23 +34,20 @@ static int hwpoison_inject(void *data, u64 val) * This implies unable to support non-LRU pages. */ if (!PageLRU(hpage) && !PageHuge(p)) - goto put_out; + return 0; /* - * do a racy check with elevated page count, to make sure PG_hwpoison - * will only be set for the targeted owner (or on a free page). + * do a racy check to make sure PG_hwpoison will only be set for + * the targeted owner (or on a free page). * memory_failure() will redo the check reliably inside page lock. */ err = hwpoison_filter(hpage); if (err) - goto put_out; + return 0; inject: pr_info("Injecting memory failure at pfn %#lx\n", pfn); - return memory_failure(pfn, MF_COUNT_INCREASED); -put_out: - put_hwpoison_page(p); - return 0; + return memory_failure(pfn, 0); } static int hwpoison_unpoison(void *data, u64 val) From patchwork Fri Nov 9 06:47:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 10675371 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 A79D213BF for ; Fri, 9 Nov 2018 06:47:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 979BF2DD3D for ; Fri, 9 Nov 2018 06:47:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BFE22DD52; Fri, 9 Nov 2018 06:47:48 +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 185A62DD3D for ; Fri, 9 Nov 2018 06:47:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0FD876B069E; Fri, 9 Nov 2018 01:47:45 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 08A106B06A0; Fri, 9 Nov 2018 01:47:44 -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 D55096B06A1; Fri, 9 Nov 2018 01:47:44 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 897486B069E for ; Fri, 9 Nov 2018 01:47:44 -0500 (EST) Received: by mail-pf1-f199.google.com with SMTP id b88-v6so789332pfj.4 for ; Thu, 08 Nov 2018 22:47:44 -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=Ow8luW8HYDT6HHVRhv0uM4c/Zk3Ha3snWz7rsKYzHxE=; b=pK08dqRYeyjmbH8uCwzbPJ2TBGBvIYgTMIvb2kmwAO6xUZ+bGZGmHtNYHV5rlXNmtS MYrtPghdVrWK+ISihzB87KY7u4cXHAXSFZrB12oCWNgqQk5ByWiEKlJUV5xMxMs2+EVh BQNDdN6ozYfejrL3azt+nTH1AWsCdD7OBe/9rVuxMOFyb1V7eqtQ9FS1X4H7heMLSoL7 ckSgwmKp59S2VeZ8TDuMzuiyiXXvPtd7iSmtET14Za8wbm2lh8ptndAqImJGfyrfBAa9 mNtPmy6QsG4OnR6I4gZq9Mhz+SP/UD09qbjcNdQ8+ozL0W9Dtu8XjtBKVM093WMgHOu7 8IXg== X-Gm-Message-State: AGRZ1gIwIR6EahPfaaeoEneCzIHli9OjRG6CVFB7sWdIhRoaEvFheb9O Rn4uO0eSVmqUJkGX7yXvnLlpTF8byUcDGs8KNo0k5pFVHrxHG5EjEY6AEQ1JUs57xHubsggnWxS VOWHxVTiRV8NOnNe0iuVgTnRr2Ps320v59z4KgMCM1q2GsBfnXbdsxCHmYyh5T9GVH/86OcD9KB BszW7NOohy+j0dUDYubYhRY0/SroypAWePiSlbVcjDBdPt2oRXI/HYFLknEVtGIkPPxfRzSnyz/ kmrIM9iTvH/TFGpEBXau/5DKlUU9U8iSjgHd2QvE2Y1GlWAgmAg3iNKqIOZ9RSzUJuZKGTggImG RcKbeEI/RvEu9igLkroda5kXtY4+5JNRzuU0t1tr3CRn94f8GYSEYQeG8tLnHuIx7Bx80/HklA= = X-Received: by 2002:a17:902:7c94:: with SMTP id y20-v6mr7709941pll.218.1541746064218; Thu, 08 Nov 2018 22:47:44 -0800 (PST) X-Received: by 2002:a17:902:7c94:: with SMTP id y20-v6mr7709904pll.218.1541746063104; Thu, 08 Nov 2018 22:47:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541746063; cv=none; d=google.com; s=arc-20160816; b=KoYBgEUvdrWXvf78qyu+paDLYQnAZeyfx3DnA6y8jKhO0IND4XWRCFdI4DxsrlliKT AuuA1qy9oa5JtnvShtqmbuJDxRdRouqT4OH25ARfLgdN3Zy6U3b7rdCJlbA3UT66qkzM 5tgH8SOHcO5SJWKFCfHToUyp8c/NOKIEuA8sJc3Iu22PZ8CnvMgYNtWIC94mbl/qjR9i NrjMV+sls2gVf2I+A2GN7N9lk1P5WVuygKMp+mc1nKYuTibLVLp1yV+cMcw1jeX9hn7j vVq9kGjLKu7Xr58UNyyVQLsMQmJ8ykYtMibMkL4cpqUHSG/d4eGGHfyr2liyy88EkNay R4vw== 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=Ow8luW8HYDT6HHVRhv0uM4c/Zk3Ha3snWz7rsKYzHxE=; b=nAinrKuQBuyTha5nLbuLM4bQFlBd2CrIJG3WIa7GON+YmzoNExsj9krv9BypJU1TfV FtmwZCRpoaLoBlrncQnpwfmZ58Vq4aRr2HS15KH7rXSavAB70HNYvf/6VeGtRHH0DTCa JdWx1e3+l3J0ViTJOBEPandGGMqGY4YRdpQgcLz9lUh/mjlHuRpxalhIqfdYJsO50zXi 2I0lIFAuSe69vWxxdddM6cjx94VYSKKDxT+U9pkT7Q6CtmoL2iVBFg+ksqI49C48t7fX Li94Ia9RFkylyLd7oGrUlQwNHxc7tsuJH1CPfwM10zi3Zp8DfXr0epcKi4fR8shkcfzO e/kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BtY6fS79; 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 q73-v6sor6655314pfi.33.2018.11.08.22.47.42 for (Google Transport Security); Thu, 08 Nov 2018 22:47:43 -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=BtY6fS79; 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=Ow8luW8HYDT6HHVRhv0uM4c/Zk3Ha3snWz7rsKYzHxE=; b=BtY6fS79qUSUdw6odCyXzhzKyXYHFlr6NvBRMERuhh1hDraSjt9j2yKUwAcdCPoBwL InSqNelUnjXxU+6LCXKn7SpGfYcMOG8yE0yARiFGYBiswQdpIsZku38c9uJ/vm3IgUqg El054i/6UGk31S6MC8S7A5Dbe5tiS/gpatKTvbg/xY5q54NvWEh/JQFtj8njQioFGNoq L4nccfR2A0zdLaA1zV3E6Zgxku7jh1iE6AsS3fS39drBeYdcH8I/iOrrGIKmSzDU2Dze OO57mO51BTtIBzSC7NigXa0I1iivpaNXjMINi4rgfDjDA4ATYjyguXdO9xAgkb55jrIU lQfA== X-Google-Smtp-Source: AJdET5cxtRfw2ZsPktJ3kZ8sESWDSkNL6zBg8GtYQZpKC+5MmuXfzJ+4cSys4HwvLnrVSpRIDXh2/w== X-Received: by 2002:a62:34c5:: with SMTP id b188-v6mr8125043pfa.65.1541746062460; Thu, 08 Nov 2018 22:47:42 -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.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 22:47:41 -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 06/11] mm: hwpoison: remove MF_COUNT_INCREASED Date: Fri, 9 Nov 2018 15:47:10 +0900 Message-Id: <1541746035-13408-7-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 Now there's no user of MF_COUNT_INCREASED, so we can safely remove all calling points. Signed-off-by: Naoya Horiguchi --- include/linux/mm.h | 7 +++---- mm/memory-failure.c | 16 +++------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git v4.19-mmotm-2018-10-30-16-08/include/linux/mm.h v4.19-mmotm-2018-10-30-16-08_patched/include/linux/mm.h index 22623ba..f85b450 100644 --- v4.19-mmotm-2018-10-30-16-08/include/linux/mm.h +++ v4.19-mmotm-2018-10-30-16-08_patched/include/linux/mm.h @@ -2725,10 +2725,9 @@ void register_page_bootmem_memmap(unsigned long section_nr, struct page *map, unsigned long nr_pages); enum mf_flags { - MF_COUNT_INCREASED = 1 << 0, - MF_ACTION_REQUIRED = 1 << 1, - MF_MUST_KILL = 1 << 2, - MF_SOFT_OFFLINE = 1 << 3, + MF_ACTION_REQUIRED = 1 << 0, + MF_MUST_KILL = 1 << 1, + MF_SOFT_OFFLINE = 1 << 2, }; extern int memory_failure(unsigned long pfn, int flags); extern void memory_failure_queue(unsigned long pfn, int flags); 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 11e283e..ed347f8 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 @@ -1094,7 +1094,7 @@ static int memory_failure_hugetlb(unsigned long pfn, int flags) num_poisoned_pages_inc(); - if (!(flags & MF_COUNT_INCREASED) && !get_hwpoison_page(p)) { + if (!get_hwpoison_page(p)) { /* * Check "filter hit" and "race with other subpage." */ @@ -1290,7 +1290,7 @@ int memory_failure(unsigned long pfn, int flags) * In fact it's dangerous to directly bump up page count from 0, * that may make page_ref_freeze()/page_ref_unfreeze() mismatch. */ - if (!(flags & MF_COUNT_INCREASED) && !get_hwpoison_page(p)) { + if (!get_hwpoison_page(p)) { if (is_free_buddy_page(p)) { action_result(pfn, MF_MSG_BUDDY, MF_DELAYED); return 0; @@ -1331,10 +1331,7 @@ int memory_failure(unsigned long pfn, int flags) shake_page(p, 0); /* shake_page could have turned it free. */ if (!PageLRU(p) && is_free_buddy_page(p)) { - if (flags & MF_COUNT_INCREASED) - action_result(pfn, MF_MSG_BUDDY, MF_DELAYED); - else - action_result(pfn, MF_MSG_BUDDY_2ND, MF_DELAYED); + action_result(pfn, MF_MSG_BUDDY_2ND, MF_DELAYED); return 0; } @@ -1622,9 +1619,6 @@ static int __get_any_page(struct page *p, unsigned long pfn, int flags) { int ret; - if (flags & MF_COUNT_INCREASED) - return 1; - /* * When the target page is a free hugepage, just remove it * from free hugepage list. @@ -1906,15 +1900,11 @@ int soft_offline_page(struct page *page, int flags) if (is_zone_device_page(page)) { pr_debug_ratelimited("soft_offline: %#lx page is device page\n", pfn); - if (flags & MF_COUNT_INCREASED) - put_page(page); return -EIO; } if (PageHWPoison(page)) { pr_info("soft offline: %#lx page already poisoned\n", pfn); - if (flags & MF_COUNT_INCREASED) - put_hwpoison_page(page); return -EBUSY; } From patchwork Fri Nov 9 06:47:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 10675373 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 CAB49109C for ; Fri, 9 Nov 2018 06:47:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB0692DD3D for ; Fri, 9 Nov 2018 06:47:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE3F82DD52; Fri, 9 Nov 2018 06:47:53 +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 0881A2DD3D for ; Fri, 9 Nov 2018 06:47:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF14C6B06A2; Fri, 9 Nov 2018 01:47:47 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 988096B06A0; Fri, 9 Nov 2018 01:47:47 -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 716AC6B06A3; Fri, 9 Nov 2018 01:47:47 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 0B4346B06A2 for ; Fri, 9 Nov 2018 01:47:47 -0500 (EST) Received: by mail-pf1-f198.google.com with SMTP id a72-v6so766576pfj.14 for ; Thu, 08 Nov 2018 22:47:47 -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=zosYmZIH/bMZx2kLa53kE3x2OPdcSq6ez0a9bP/tt24=; b=F0NG0JmQ3/uaL42CwtheHib0KRPpi8GsyxESAvXvhryYy/VBvB8v4erIP8adCD0P6v olKvG9SFVGyFJb/jPFoYgqPbGA4kr7efTzJWkW57/G7dCKTczV56Rfzhb4TPAH2pLL+O 4BUIplg/SwiiW/hJeMQWsWJIWPyl6+CDJiSMlddb1tkCZu6cN7F23LlTRf+V6OTCmSD1 1e1hpm8Rr7rTnrB8qAZTer8sWSempfvUx+HwxUv2gJzC486M9LsH6fS+5mrt4qFcj1Wi FkvXu4zOQy2IlEZONcJcvt6ViToliKxGKz0HeRbQzO0toBLsX5F4ja+9hvXizkI0KNeI roIA== X-Gm-Message-State: AGRZ1gJy71bfZgReeHAT2X5wANZSXehaBrOf+tn6z+L5SRc8LmVvg4Yg iKQPKoLXMwPxE8pgtjht4AsAJUWdFTEZIhUYg2hrB1pNyysvEEVW3MiE2XQmdUQBqDyxEvXpQo2 02K1vhfNxLEQ02lo131ZDrgnOBXL+gFG6z8brdxvi1DW3oPbt7Z4GzPxneYdcH8TDynWubgyhm5 8mj0751QZfcb1PQqZM2JbEu6eLTDEE9DpIYambZjuWBytEbQT6LHKhbDavHrVYrgCxvs/CzH0Ji zoQbkyWmhcJ4fH4ydp0Bc6poQT9k2Gzkv3/5e2IfmXMKVVPrgFNhs5rnF8EtMTLA9BK5DeUiENi AJS20t4aIQjoSCEUzfP8AuJDGQEJTXqjTrtr6iJXVNBgwHgueLrkDzifBk/+EpgBkuj6EdF3VQ= = X-Received: by 2002:a65:42c2:: with SMTP id l2-v6mr6176465pgp.139.1541746066668; Thu, 08 Nov 2018 22:47:46 -0800 (PST) X-Received: by 2002:a65:42c2:: with SMTP id l2-v6mr6176425pgp.139.1541746065197; Thu, 08 Nov 2018 22:47:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541746065; cv=none; d=google.com; s=arc-20160816; b=ZieQpyHZcvBDBedD+uJ9X+deZr23J0qNQL3maW9B66LobK3S0asNc4vz2H2IQnaZU/ 9aGtjttCs8+sNs37+V2DaKCVEW0e1Z25Uj6ssPP3ZZb5D901TEXF8cJuROR2FWOZFg2Z /rZ6q5Uwv+0l9cMz3ZQhE5PSHflAduotHR3pOu5IubGjknKQ3vQcSJW+mp/DeXTpNQq2 rgP+zIS+jNVSO6/jgSk63DsfITVzXxwMucKCeKovAD/kOfTz2uL9q9pR4p4b+nB0rJNa y2X0IVKvlYtd+a5dCtirZnuIFsGBPlX9US0ob267KnHiuSZ41Ym3thcZlX/6CXQLDLWK Mahg== 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=zosYmZIH/bMZx2kLa53kE3x2OPdcSq6ez0a9bP/tt24=; b=0P+jPjqk0RJnLbcEA22gGDhiKyzqor4GaG1kVjBKfi5Jjoe9k7vlTmILfQYYBVoxEs MWeXdJMgdLdVIH7gtO5DyTh181EKoFy8SlRaS2+8ipbrrNsbBPTQR+Yo2CNxZPArpKqJ jB8ua8DrqIY3GWkdmS4EBh4G5yti8sS42usz0Qgw4tOk7/Yx/RYPAip75WFM8YhQkjbc NOuaKjqoi24MDM2r62G/A8OZ+cWD1NVU0hgLrDeu689rDvYU/Hq3KeoYjgZ1ZWn1ZcTx u1Tm5nG+iBT97EUHlLWi/tl/8cIrRTJK6v7F4FMCcbdMiySBg9P3UaKsEG1NBRcBENUL 9FaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QwyMpnn9; 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 t78-v6sor8132087pfa.32.2018.11.08.22.47.45 for (Google Transport Security); Thu, 08 Nov 2018 22:47:45 -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=QwyMpnn9; 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=zosYmZIH/bMZx2kLa53kE3x2OPdcSq6ez0a9bP/tt24=; b=QwyMpnn9c+6gRddzOcen8u+RU89eMBYJSP0wvwfeKtViwuqu/oqR624Hi0FCCd5scq Nqo1jwYwCU+YTFBY5GWLyY0bu5tqBIG1L3uAlFT2u7sZQGqL7oLfXLUgtphEhVoy1x1k 5Pjib0hIlc2NILlQVMGs0xSyX5J9/w2AZT8szVR+3SOOprVcnJu93AUnlRGqgUmGMTHa MUU+o/GxHCR2lOwjfotjqwT2Q9NBiRBbMTyUMsR5szQ3PgfQIv67GQPjLAJc85XwLsgY oQ5C0ROwHR2LdlrDgtmifzQ1wZeYKP+xG3/NtjcgYW4euG1/v4TW7nxiLOoekbUEXqum 7WOA== X-Google-Smtp-Source: AJdET5cEO3P9TCk3E/SJ1+7RvyDFXdw4xMpccPJrqiypjxfdL6CGqC6goMUHPyet7uFuMIq3r2SceQ== X-Received: by 2002:a62:571b:: with SMTP id l27-v6mr7842901pfb.209.1541746064720; Thu, 08 Nov 2018 22:47:44 -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.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 22:47:44 -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 07/11] mm: remove flag argument from soft offline functions Date: Fri, 9 Nov 2018 15:47:11 +0900 Message-Id: <1541746035-13408-8-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 The argument @flag no longer affects the behavior of soft_offline_page() and its variants, so let's remove them. Signed-off-by: Naoya Horiguchi --- drivers/base/memory.c | 2 +- include/linux/mm.h | 2 +- mm/madvise.c | 2 +- mm/memory-failure.c | 27 +++++++++++++-------------- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git v4.19-mmotm-2018-10-30-16-08/drivers/base/memory.c v4.19-mmotm-2018-10-30-16-08_patched/drivers/base/memory.c index 0e59856..4a554a5 100644 --- v4.19-mmotm-2018-10-30-16-08/drivers/base/memory.c +++ v4.19-mmotm-2018-10-30-16-08_patched/drivers/base/memory.c @@ -548,7 +548,7 @@ store_soft_offline_page(struct device *dev, pfn >>= PAGE_SHIFT; if (!pfn_valid(pfn)) return -ENXIO; - ret = soft_offline_page(pfn_to_page(pfn), 0); + ret = soft_offline_page(pfn_to_page(pfn)); return ret == 0 ? count : ret; } diff --git v4.19-mmotm-2018-10-30-16-08/include/linux/mm.h v4.19-mmotm-2018-10-30-16-08_patched/include/linux/mm.h index f85b450..6c496da 100644 --- v4.19-mmotm-2018-10-30-16-08/include/linux/mm.h +++ v4.19-mmotm-2018-10-30-16-08_patched/include/linux/mm.h @@ -2738,7 +2738,7 @@ extern int sysctl_memory_failure_early_kill; extern int sysctl_memory_failure_recovery; extern void shake_page(struct page *p, int access); extern atomic_long_t num_poisoned_pages __read_mostly; -extern int soft_offline_page(struct page *page, int flags); +extern int soft_offline_page(struct page *page); #ifdef CONFIG_MEMORY_FAILURE /* 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 9fa0225..86453f3 100644 --- v4.19-mmotm-2018-10-30-16-08/mm/madvise.c +++ v4.19-mmotm-2018-10-30-16-08_patched/mm/madvise.c @@ -660,7 +660,7 @@ static int madvise_inject_error(int behavior, pr_info("Soft offlining pfn %#lx at process virtual address %#lx\n", pfn, start); - ret = soft_offline_page(page, 0); + ret = soft_offline_page(page); if (ret) return ret; continue; 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 ed347f8..869ff8f 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 @@ -1482,7 +1482,7 @@ static void memory_failure_work_func(struct work_struct *work) if (!gotten) break; if (entry.flags & MF_SOFT_OFFLINE) - soft_offline_page(pfn_to_page(entry.pfn), entry.flags); + soft_offline_page(pfn_to_page(entry.pfn)); else memory_failure(entry.pfn, entry.flags); } @@ -1615,7 +1615,7 @@ static struct page *new_page(struct page *p, unsigned long private) * that is not free, and 1 for any other page type. * For 1 the page is returned with increased page count, otherwise not. */ -static int __get_any_page(struct page *p, unsigned long pfn, int flags) +static int __get_any_page(struct page *p, unsigned long pfn) { int ret; @@ -1642,9 +1642,9 @@ static int __get_any_page(struct page *p, unsigned long pfn, int flags) return ret; } -static int get_any_page(struct page *page, unsigned long pfn, int flags) +static int get_any_page(struct page *page, unsigned long pfn) { - int ret = __get_any_page(page, pfn, flags); + int ret = __get_any_page(page, pfn); if (ret == 1 && !PageHuge(page) && !PageLRU(page) && !__PageMovable(page)) { @@ -1657,7 +1657,7 @@ static int get_any_page(struct page *page, unsigned long pfn, int flags) /* * Did it turn free? */ - ret = __get_any_page(page, pfn, 0); + ret = __get_any_page(page, pfn); if (ret == 1 && !PageLRU(page)) { /* Drop page reference which is from __get_any_page() */ put_hwpoison_page(page); @@ -1669,7 +1669,7 @@ static int get_any_page(struct page *page, unsigned long pfn, int flags) return ret; } -static int soft_offline_huge_page(struct page *page, int flags) +static int soft_offline_huge_page(struct page *page) { int ret; unsigned long pfn = page_to_pfn(page); @@ -1730,7 +1730,7 @@ static int soft_offline_huge_page(struct page *page, int flags) return ret; } -static int __soft_offline_page(struct page *page, int flags) +static int __soft_offline_page(struct page *page) { int ret; unsigned long pfn = page_to_pfn(page); @@ -1815,7 +1815,7 @@ static int __soft_offline_page(struct page *page, int flags) return ret; } -static int soft_offline_in_use_page(struct page *page, int flags) +static int soft_offline_in_use_page(struct page *page) { int ret; int mt; @@ -1847,9 +1847,9 @@ static int soft_offline_in_use_page(struct page *page, int flags) mt = get_pageblock_migratetype(page); set_pageblock_migratetype(page, MIGRATE_ISOLATE); if (PageHuge(page)) - ret = soft_offline_huge_page(page, flags); + ret = soft_offline_huge_page(page); else - ret = __soft_offline_page(page, flags); + ret = __soft_offline_page(page); set_pageblock_migratetype(page, mt); return ret; } @@ -1873,7 +1873,6 @@ static int soft_offline_free_page(struct page *page) /** * soft_offline_page - Soft offline a page. * @page: page to offline - * @flags: flags. Same as memory_failure(). * * Returns 0 on success, otherwise negated errno. * @@ -1892,7 +1891,7 @@ static int soft_offline_free_page(struct page *page) * This is not a 100% solution for all memory, but tries to be * ``good enough'' for the majority of memory. */ -int soft_offline_page(struct page *page, int flags) +int soft_offline_page(struct page *page) { int ret; unsigned long pfn = page_to_pfn(page); @@ -1909,11 +1908,11 @@ int soft_offline_page(struct page *page, int flags) } get_online_mems(); - ret = get_any_page(page, pfn, flags); + ret = get_any_page(page, pfn); put_online_mems(); if (ret > 0) - ret = soft_offline_in_use_page(page, flags); + ret = soft_offline_in_use_page(page); else if (ret == 0) ret = soft_offline_free_page(page); From patchwork Fri Nov 9 06:47:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 10675375 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 AFDA1109C for ; Fri, 9 Nov 2018 06:47:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EF642DD3D for ; Fri, 9 Nov 2018 06:47:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90ED82DD52; Fri, 9 Nov 2018 06:47:56 +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 E2A212DD3D for ; Fri, 9 Nov 2018 06:47:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE2F26B06A0; Fri, 9 Nov 2018 01:47:49 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C6B6C6B06A6; Fri, 9 Nov 2018 01:47:49 -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 B0BA46B06A7; Fri, 9 Nov 2018 01:47:49 -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 67C4F6B06A0 for ; Fri, 9 Nov 2018 01:47:49 -0500 (EST) Received: by mail-pg1-f200.google.com with SMTP id s22so627954pgv.8 for ; Thu, 08 Nov 2018 22:47:49 -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=CqlIoVW1d98lHuODa9U9NYQESN2YZOyjeuQFZV3TRgI=; b=WzRqofS5/qZeIOU50ubeHyo78H37cjIR54ahLsMLwB8DAKK1VoyBbYt3eLL7t+futw DNXSBq5oSCL7jO1UDHC8lnmMQKBuWda2y1MMF45/VO8nrKjxYaCUOfqbBOstUPFlCm7t Ft7v33ivXXVtufxDZ3tfRBAOmxGyJMu0guNsIRiPN6CcRsfcSVC/tI5+JEpoH0fW8ch1 EGsBnUUJ9djKcPxlovnKMip+ZriuIvx40DvvuVDtF/zKXZEnyMCXIFGUH5/eyQa+qSib 7oVFg5HQ5lBxSQMQN/JGgiZ0zWOa2GDwJKaM8s1RP6lUA6/VkUovvCATpJQBYcyYo0mv lw8w== X-Gm-Message-State: AGRZ1gLX7HbynGkk4pwtoTBI+FOaHJTr7Jg0hECkovoQdilpq7Z+5CbD Tfe6QreboEG6pHJhd62WaaUEvXdlzFRbRhQWsuEQ8Fo+pNxtF0tPAfGyI+Fl8Kp1765CZxjFd6x iJ2ikw15E6/kUDsiEKtyRsVYvJVHHGde6d927ATld2IXndc48MuxekbjuVNgrpNOyfmQjJtQpt7 n5fkXUTRsqE3EDb1hfUZe/2nUFRAG+X4Pcsy20PFnLqGC6iOmwK5KnEKtOhQ48B30aAuZplilVo 3n9BgaJr/pknxpeItdp3IpINc067nibcVczSurm+QxnCzwpgS1MtFhMxCg+VM+Nxru8KVPPekta N9hMPijQ88m7ivgMwkTEWJMM7o+5mvbbeVInw24e/Hc/LRZV//hqqN4R5gRe4b+2jrLTw3AHNA= = X-Received: by 2002:a62:da54:: with SMTP id w20-v6mr7775922pfl.106.1541746069083; Thu, 08 Nov 2018 22:47:49 -0800 (PST) X-Received: by 2002:a62:da54:: with SMTP id w20-v6mr7775866pfl.106.1541746067553; Thu, 08 Nov 2018 22:47:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541746067; cv=none; d=google.com; s=arc-20160816; b=HmZBRESovU4jtO7kkY2XtTwlTMirm6MoAhPst2LeOUvCXhVZRxjX+BTXSpvX3TMsIl A+TvvYxkOiAjKhh/IfTzDEp60vzmlI7LaVezfiirMwcRa4ltIkGLMK33trJkTARPtjoy 7JC+E2uOzhO/AWOJ29U4tovWeb6/YFHmFKogvppdjdHcuUC/i5HCMxQI+n7DRool3AMO JwucPgkN39DQac+r5lnXTdB12Z1HPq5WQCMiee6gn+cfOS/wfgyfa3X2Vq2x5EGdh3Is 6rqzR8k8mh7nCw7ZS277wonUw295APkqC+pGOCPP32fcz9GuwHc0S2JTvflNA64/zPC3 9pLw== 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=CqlIoVW1d98lHuODa9U9NYQESN2YZOyjeuQFZV3TRgI=; b=cze3FLgI7hfXlpwy5f5urIlfORSeX+w9wq1CTg4tgL+jIonWP/q2ms3u163sIHOIkz VrqPxH7VUb7sVkifRryWiySOdqcle+rdF2PSnnEQHp72EGE85qcizkKF/WRIu2427Jt4 Z2PaJoVmRpBGD6QLr181oSiXGJLAnCkNCR2xIptjZi0pOH53weE2E03FYJDh4eVEACqu FDb9zeai61Lb11iAqB10CFfOVMe4g1TnNVMHtJ13L0J8FAKKVx5XKngtSMKrLc62l778 8/vF4BPfSaRzev63OlVDQtPMPxnxN2EFmuMexdHAJ2UJxWLYei9R6+9jZ5+IgREoMr+q MVFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BZXfJP7E; 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 30sor6958120pgz.10.2018.11.08.22.47.47 for (Google Transport Security); Thu, 08 Nov 2018 22:47:47 -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=BZXfJP7E; 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=CqlIoVW1d98lHuODa9U9NYQESN2YZOyjeuQFZV3TRgI=; b=BZXfJP7E9452UWPu00jxx7AAEkL3FE0eiuA79Uq2lq79+nmfyqRUMQwn3p0Z5tdZrP 7fBk2ZeT3y1O/uQoN1kvFM7xM7OQzsATk98Dm87zfeV+soDfPLnzeXEkjVz4B36lMc2W zd2JY/UtzvA8UoaB23w+H9RPe8EysVWiguGFC6AUaKA4TeLg6ny7E/X6vj7ENVdAQZC+ mBQCq2bmn0Xvfo/hweqUk9F0P+erBmTwNtJsI8lyVMT85g4ht4x61mczVvF3aTjT9xIj 114z+3uGUEkR+db9bQ2l2/E/B4KOmvFelbNfdRSMi9QCyi+9UmSiG5SXYBcZCcYoWIes Uihw== X-Google-Smtp-Source: AJdET5cAN+kFUim4VY8q26Arb96EgiRTzks00K5X7xsj6J58mRGj6TVQ4mfDhPwnLf5PQLXLXpmSwQ== X-Received: by 2002:a63:88c7:: with SMTP id l190mr6336857pgd.110.1541746066992; Thu, 08 Nov 2018 22:47:46 -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.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 22:47:46 -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 08/11] mm: soft-offline: isolate error pages from buddy freelist Date: Fri, 9 Nov 2018 15:47:12 +0900 Message-Id: <1541746035-13408-9-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 Soft-offline shares PG_hwpoison with hard-offline to keep track of memory error, but recently we found that the approach can be undesirable for soft-offline because it never expects to stop applications unlike hard-offline. So this patch suggests that memory error handler (not only sets PG_hwpoison, but) isolates error pages from buddy allocator in its context. In previous works [1], we allow soft-offline handler to set PG_hwpoison only after successful page migration and page freeing. This patch, along with that, makes the isolation always done via set_hwpoison_free_buddy_page() with zone->lock, so the behavior should be less racy and more predictable. Note that only considering for isolation, we don't have to set PG_hwpoison, but my analysis shows that to make memory hotremove properly work, we still need some flag to clearly separate memory error from any other type of pages. So this patch doesn't change this. [1]: commit 6bc9b56433b7 ("mm: fix race on soft-offlining free huge pages") commit d4ae9916ea29 ("mm: soft-offline: close the race against page allocation") Signed-off-by: Naoya Horiguchi --- mm/memory-failure.c | 8 +++--- mm/page_alloc.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 70 insertions(+), 9 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 869ff8f..ecafd4a 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 @@ -1762,9 +1762,11 @@ static int __soft_offline_page(struct page *page) if (ret == 1) { put_hwpoison_page(page); pr_info("soft_offline: %#lx: invalidated\n", pfn); - SetPageHWPoison(page); - num_poisoned_pages_inc(); - return 0; + if (set_hwpoison_free_buddy_page(page)) { + num_poisoned_pages_inc(); + return 0; + } else + return -EBUSY; } /* diff --git v4.19-mmotm-2018-10-30-16-08/mm/page_alloc.c v4.19-mmotm-2018-10-30-16-08_patched/mm/page_alloc.c index ae31839..970d6ff 100644 --- v4.19-mmotm-2018-10-30-16-08/mm/page_alloc.c +++ v4.19-mmotm-2018-10-30-16-08_patched/mm/page_alloc.c @@ -8183,10 +8183,55 @@ bool is_free_buddy_page(struct page *page) } #ifdef CONFIG_MEMORY_FAILURE + +/* + * Pick out a free page from buddy allocator. Unlike expand(), this + * function can choose the target page by @target which is not limited + * to the first page of some free block. + * + * This function changes zone state, so callers need to hold zone->lock. + */ +static inline void pickout_buddy_page(struct zone *zone, struct page *page, + struct page *target, int torder, int low, int high, + struct free_area *area, int migratetype) +{ + unsigned long size = 1 << high; + struct page *current_buddy, *next_page; + + while (high > low) { + area--; + high--; + size >>= 1; + + if (target >= &page[size]) { /* target is in higher buddy */ + next_page = page + size; + current_buddy = page; + } else { /* target is in lower buddy */ + next_page = page; + current_buddy = page + size; + } + VM_BUG_ON_PAGE(bad_range(zone, current_buddy), current_buddy); + + if (set_page_guard(zone, &page[size], high, migratetype)) + continue; + + list_add(¤t_buddy->lru, &area->free_list[migratetype]); + area->nr_free++; + set_page_order(current_buddy, high); + page = next_page; + } +} + /* - * Set PG_hwpoison flag if a given page is confirmed to be a free page. This - * test is performed under the zone lock to prevent a race against page - * allocation. + * Isolate hwpoisoned free page which actully does the following + * - confirm that a given page is a free page under zone->lock, + * - set PG_hwpoison flag, + * - remove the page from buddy allocator, subdividing buddy page + * of each order. + * + * Just setting PG_hwpoison flag is not safe enough for complete isolation + * because rapidly-changing memory allocator code is always with the + * risk of mishandling the flag and potential race. */ bool set_hwpoison_free_buddy_page(struct page *page) { @@ -8199,10 +8244,24 @@ bool set_hwpoison_free_buddy_page(struct page *page) spin_lock_irqsave(&zone->lock, flags); for (order = 0; order < MAX_ORDER; order++) { struct page *page_head = page - (pfn & ((1 << order) - 1)); + unsigned int forder = page_order(page_head); + struct free_area *area = &(zone->free_area[forder]); - if (PageBuddy(page_head) && page_order(page_head) >= order) { - if (!TestSetPageHWPoison(page)) - hwpoisoned = true; + if (PageBuddy(page_head) && forder >= order) { + int migtype = get_pfnblock_migratetype(page_head, + page_to_pfn(page_head)); + /* + * TestSetPageHWPoison() will be used later when + * reworking hard-offline part is finished. + */ + SetPageHWPoison(page); + + list_del(&page_head->lru); + rmv_page_order(page_head); + area->nr_free--; + pickout_buddy_page(zone, page_head, page, 0, 0, forder, + area, migtype); + hwpoisoned = true; break; } } From patchwork Fri Nov 9 06:47:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 10675377 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 3EE0413BF for ; Fri, 9 Nov 2018 06:47:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E67B2DD3D for ; Fri, 9 Nov 2018 06:47:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2298C2DD52; Fri, 9 Nov 2018 06:47:59 +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 93DE02DD3D for ; Fri, 9 Nov 2018 06:47:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5BB4E6B06A6; Fri, 9 Nov 2018 01:47:51 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 541366B06A8; Fri, 9 Nov 2018 01:47:51 -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 3BDD16B06A9; Fri, 9 Nov 2018 01:47:51 -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 E14C06B06A6 for ; Fri, 9 Nov 2018 01:47:50 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id f28-v6so782893pfh.6 for ; Thu, 08 Nov 2018 22:47:50 -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=N7S6I8bftQslxdirzJ9Dh7FpKhaSjYR8AwdNzVMTAb8=; b=dD9UsFWxXsnT+knjpYfH5On1XcBuohar1tdpQjGTzev7TgyHjldFe+kTl5aNXVZfRu A1Lx1g8xNfQJMme5NYoIqdW038NVdbCbjAqnUoZLGdg+Q+gpiPy6KQnoTFBVXxji0bGR Kp+3PSWALgB6WbbO5/R4k4TKjlkFysrKRKP7HmBnDMYCrmfG6C0f0YOonTUs3ETESyeE d8Ad/x1gvrK8/N6NxCDh3eMysKSdJGWJRem+Rzo1FZ465tsb5SOMPYvgBZiTRRNrYLlk srs/NQFx0weiSmuYMhVwzEFw7U/UHNHbp7+upE7Jy2hDJPWhCEhyAD5OG03cZhH1jAOq h41g== X-Gm-Message-State: AGRZ1gJUeUDEQ9WjjdPDAx1KfV75XXf0BZK5ooisiKLeTxE1fmCNAVxv P27GV2zKQO3MqnQa73118UCGcEVI4xk64NvV2SZYFI12qyQnRmCqLuxnM3Q5iVHBAprEXmANRRK owsnQqNDLEnZvb2M+XPN+SUu1l0dnqD+P/Taix61kSplQUmzWOynCZ5Wh0f5U9+UeDkO2Tsbwlm kk5O4GMEdIrGNRaN+/3Vl4SbsOyUSUczeze9sw5DWqfw53897a83sgLfLtyXKAcdR1FosLvw05k qnu3o9424ybGY7EkHwLOjHhBbrjz9/Vh46nNRrFQZhBldk3QkYeNt8UAAvF2azU3iped87Fs8rK PxeKUiaH7WinB+/EYTJ1Bhvez+ulcXCZJqmWbsdBd/l9J3+ZIWYn0AQ1Cv1ArbIxWR1PUD9gHA= = X-Received: by 2002:a63:2bc9:: with SMTP id r192mr6543526pgr.172.1541746070594; Thu, 08 Nov 2018 22:47:50 -0800 (PST) X-Received: by 2002:a63:2bc9:: with SMTP id r192mr6543503pgr.172.1541746069655; Thu, 08 Nov 2018 22:47:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541746069; cv=none; d=google.com; s=arc-20160816; b=y0o2By+2cYWOGvdDBEdEhYm0uQT2UJWCKj3EHfa1wmpdkQXiaL4rXIYlIUoa/V4Q3P O/RvzhFGsS7q8C9gY4EMSICbTz4EWOTCY7toJluflKPk1afDRQYFKabOks58esz1ShRo 1G/cZsOCxvaA+p1qa8ATVSjuEtecIN+b6gMxLCXc0iViCbuXNiaz7PXlE6jYFlTys1x8 1MzzjopaXVhzg4wSIkL/hm2iXYakMbO1j/QnCTEVyfowbwFOsAqD5t8ZYrqb8EkYaFWr sqKiSMMl9af4BS/qLEPYr4p1uWtZq9Byt/SrtZR+SvBzmJ54W7LdOf95l4MpLp4S4K23 wTRA== 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=N7S6I8bftQslxdirzJ9Dh7FpKhaSjYR8AwdNzVMTAb8=; b=a/+bkjj17+zwqTzYPAOMDe6fPL4MSLdoXB1OMzTTxInhZbO9UtMquBGgkcIqRP7OKE TZxAU5Kgc5/2tMn+gj7JjB+iZglQwa8EbkQeeVa4HulL+FRaUAwo59pDa7VS2Bh0WGWu RLKjTOfbyvOM26h6QTUgyG/CZkg9K/XbsyxWBlbGI42rjEdbBEMLkje8uVPyPXONtO+t VtS194UqwaEjmCPrG2DrWVAt9IJ36gq8PzekpDSgyd78N0CKoUIuQjpk/j8IjZy1ujHl du6m7GHdlMFsy9l5srA6LClavBIHuXLszbEVMYbc8okYnAzMMdBqRX1NtaSapjS61MVx BySw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Vbtsjxzc; 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 q14-v6sor6959767pgv.63.2018.11.08.22.47.49 for (Google Transport Security); Thu, 08 Nov 2018 22:47:49 -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=Vbtsjxzc; 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=N7S6I8bftQslxdirzJ9Dh7FpKhaSjYR8AwdNzVMTAb8=; b=Vbtsjxzc4u+FeISNSR2pYhK61DdEYtKpq4/sBiclUcKp28SAlJ/ebQ3kz6WgJ+sKSK rCwEvFupUmRMKzsfTzv5QEwSqqt/tiqAzHcdRNYObvLle7KPs+ufmMdRz9KcLjTQzLIN 4BLFd49ItwISbR2Ov1n4VRukiCJZMv9CkhA6XEjDiDf6/KV7W4g30HpYD0xRa60G/Lbk Anzp3zCauT2LF2xV9SC0J4il0jh7HkSmo+a57gzmKuLNK/HwMjFLZ9vI9JbApHq+M3Ji +uWTgs/ssSFTjYL7TJtSfRPmB0ddAoRLVcZiH70dgCovCA+EjgpAwNvFgRBEP5X3bz/n DlNA== X-Google-Smtp-Source: AJdET5fHJHDcr0dhGRXWOs+m/7KLTmuB661ydLhlRsy1qSm1ieXKAutd9hhcrekp6ruTbsy3J8cuUQ== X-Received: by 2002:a63:e54d:: with SMTP id z13-v6mr6385719pgj.169.1541746069212; Thu, 08 Nov 2018 22:47:49 -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.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 22:47:48 -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 09/11] mm: hwpoison: apply buddy page handling code to hard-offline Date: Fri, 9 Nov 2018 15:47:13 +0900 Message-Id: <1541746035-13408-10-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 Hard-offline of free buddy pages can be handled in the same manner as soft-offline. So this patch applies the new semantics to hard-offline to more complete isolation of offlined page. As a result, the successful case is worth MF_RECOVERED instead of MF_DELAYED, so this patch also changes it. Signed-off-by: Naoya Horiguchi --- mm/memory-failure.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 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 ecafd4a..af541141 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 @@ -772,6 +772,16 @@ static int me_swapcache_clean(struct page *p, unsigned long pfn) return MF_FAILED; } +static int me_huge_free_page(struct page *p) +{ + int rc = dissolve_free_huge_page(p); + + if (!rc && set_hwpoison_free_buddy_page(p)) + return MF_RECOVERED; + else + return MF_FAILED; +} + /* * Huge pages. Needs work. * Issues: @@ -799,8 +809,7 @@ static int me_huge_page(struct page *p, unsigned long pfn) */ if (PageAnon(hpage)) put_page(hpage); - dissolve_free_huge_page(p); - res = MF_RECOVERED; + res = me_huge_free_page(p); lock_page(hpage); } @@ -1108,8 +1117,11 @@ static int memory_failure_hugetlb(unsigned long pfn, int flags) } } unlock_page(head); - dissolve_free_huge_page(p); - action_result(pfn, MF_MSG_FREE_HUGE, MF_DELAYED); + + res = me_huge_free_page(p); + if (res == MF_FAILED) + num_poisoned_pages_dec(); + action_result(pfn, MF_MSG_FREE_HUGE, res); return 0; } @@ -1270,6 +1282,13 @@ int memory_failure(unsigned long pfn, int flags) p = pfn_to_page(pfn); if (PageHuge(p)) return memory_failure_hugetlb(pfn, flags); + + if (set_hwpoison_free_buddy_page(p)) { + action_result(pfn, MF_MSG_BUDDY, MF_RECOVERED); + num_poisoned_pages_inc(); + return 0; + } + if (TestSetPageHWPoison(p)) { pr_err("Memory failure: %#lx: already hardware poisoned\n", pfn); @@ -1281,8 +1300,7 @@ int memory_failure(unsigned long pfn, int flags) /* * We need/can do nothing about count=0 pages. - * 1) it's a free page, and therefore in safe hand: - * prep_new_page() will be the gate keeper. + * 1) it's a free page, and removed from buddy allocator. * 2) it's part of a non-compound high order page. * Implies some kernel user: cannot stop them from * R/W the page; let's pray that the page has been @@ -1291,8 +1309,8 @@ int memory_failure(unsigned long pfn, int flags) * that may make page_ref_freeze()/page_ref_unfreeze() mismatch. */ if (!get_hwpoison_page(p)) { - if (is_free_buddy_page(p)) { - action_result(pfn, MF_MSG_BUDDY, MF_DELAYED); + if (set_hwpoison_free_buddy_page(p)) { + action_result(pfn, MF_MSG_BUDDY, MF_RECOVERED); return 0; } else { action_result(pfn, MF_MSG_KERNEL_HIGH_ORDER, MF_IGNORED); @@ -1330,8 +1348,8 @@ int memory_failure(unsigned long pfn, int flags) */ shake_page(p, 0); /* shake_page could have turned it free. */ - if (!PageLRU(p) && is_free_buddy_page(p)) { - action_result(pfn, MF_MSG_BUDDY_2ND, MF_DELAYED); + if (!PageLRU(p) && set_hwpoison_free_buddy_page(p)) { + action_result(pfn, MF_MSG_BUDDY_2ND, MF_RECOVERED); return 0; } From patchwork Fri Nov 9 06:47:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 10675379 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 AFCA913BF for ; Fri, 9 Nov 2018 06:48:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F3A42DD3D for ; Fri, 9 Nov 2018 06:48:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9358A2DD76; Fri, 9 Nov 2018 06:48:01 +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 225CB2DD40 for ; Fri, 9 Nov 2018 06:48:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD4506B06A8; Fri, 9 Nov 2018 01:47:53 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B0D7D6B06AA; Fri, 9 Nov 2018 01:47:53 -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 95EA66B06AB; Fri, 9 Nov 2018 01:47:53 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 4D0B06B06A8 for ; Fri, 9 Nov 2018 01:47:53 -0500 (EST) Received: by mail-pg1-f197.google.com with SMTP id s141-v6so607129pgs.23 for ; Thu, 08 Nov 2018 22:47:53 -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=reMxc0zME/3qnvb1lgC8fPj6wExKKId/iU2Ws7jwufo=; b=GPrY/BBGg4FjfngD0IIny/9efowWYfUy5rKcKACGw7lx9ADxFjEeJ/Gt9P6G3Wf46p mEm6lkBgClYf8oCO8M8jl7jXHuazJnZuWaOnqEmmj4WOgRUYaguvwMSFbCyb1UKzVVY2 1N+85/5wsXfP8VS+smuhH8ePZoaglzyUp7F6s081+/F4UzZl64R/lmiBDkfeCaf2gCiD 3kgalSKxnSajuY8Uz3kLO7RIXqQs56LQvT9TZPi5m9vv/j9iEHmVagB11pmFYhOAKGs0 O0OGQdsP4KDThMniVhwjodBL5XEtrnRswTyggdeoz7n2Akm1s1kyNaF+MnfcmdgKF+Dr R1JA== X-Gm-Message-State: AGRZ1gKNtIkDiCqdspJd1XZBXVNDca1Lqv+shA3oKMZgeKkU3bRHyj1+ NliaEmhftcqHU8Nz0CHQkfI/LpG47DnMAllrvQbCpooWQ/bPBbReWps/mOXnsu57DDTvajHbOSp GfD1lD6GmYZGd6SjV5QDXwVD7eeRM/vIAFT1jCV5yL6agDuIvfeRo+0NGzDrCQrEbJu8oF+x0Mz WZ8zhpRBADiXmXmoifMo3ibCaXnyclzdrFoM2Ja/WEf4pZu01KgzI4K+A4/zycBePhBCq6L7hMr KgiY/ZFqJm/8ofhhoE8j2dEc0/M0J3naan0m8rsgKUi/UKN8xQ7gIexYVk4jIMmOU3e7cbu8wG4 jBuEt933Afko2GXQpkbgrkD6DiJ66wvQQ6QsXEzEJq7HDcoCoUA1pqyO5/kc1H9W2TpZQC3nbQ= = X-Received: by 2002:a63:c141:: with SMTP id p1mr6456937pgi.424.1541746072976; Thu, 08 Nov 2018 22:47:52 -0800 (PST) X-Received: by 2002:a63:c141:: with SMTP id p1mr6456914pgi.424.1541746072131; Thu, 08 Nov 2018 22:47:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541746072; cv=none; d=google.com; s=arc-20160816; b=tOGZwun4o6DEuc82mcVuSuMmyQPtdd7Do5RQFmga2uo1FVepMtY1n8Nvd9SeRknRhq FrFDHEUvW/dg4/56H0ZXminRtuxhPSzQAl4JkhqXB2zuFwK/FcU2ykie0DI8n1vFigjp wFFNRE/7jBnGfOX28jBzy8d2zPZFiylcKXA6l3VKnjO89rEckDydSB1MUK8oXLrEHHEP AOEw5qmSzUR27p8/2Cxym9TnANN6Ba70d5dDrbSKMmdAyFIpvUhqkxnmI5daIDbrDvFr DwjGf2PNKVyAxWUClpjCNc61ze793jd4WxSeScQ8+K/GOhK1YP2gKhw/5/Z/4SymwN87 RZ/Q== 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=reMxc0zME/3qnvb1lgC8fPj6wExKKId/iU2Ws7jwufo=; b=yBrUAnB4WBPv7q07/qBOd7RI/iPw2CTLsFz0/fYXnARM8vwND+2UilNn7DpFLRVgN3 2HzldkIRuxYbMWjBjiuoo5n/sQ7iiFYjDCrXQF5uCqjxS9f2nIhrfxbeCfVfjVNc0HnS ZP0AuddEp98bn+YMFKUx+EdVXiwUNEkbDKidJ2zpHQmktpG5zOkMx1qieTygwbs61TzS 4oBdN+qPIgfczziB3WhJeSf34Bfjt/7sDEs1Wn7kDXKf30SegXwMtsHqttj2lxQ5KQVl E7qcZD7cu2AlVbXFx8rZ8LTgG5avtsvNzkGKhgduyAPcwaQPCMuBNXp3YWeHjgOXn2r5 r1KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sX4Na+DO; 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 z10-v6sor7712035pln.16.2018.11.08.22.47.52 for (Google Transport Security); Thu, 08 Nov 2018 22:47:52 -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=sX4Na+DO; 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=reMxc0zME/3qnvb1lgC8fPj6wExKKId/iU2Ws7jwufo=; b=sX4Na+DOIkEp8+jX1RN+XNnQhGy5F6jH9jm1540XiJ8QHjfVWTav7yF30BP24Im3eA VtWXF2EYY/5OnwdFfRFACh1uDZ9h6tEEPrw7UN3TXxByip33AO+cAGeA4ya8agN16JTd ymjkgXnVOa10zlcfD2526ggxsjZfoOGzkJpe48BZM0hNcZNLqJXUh/ZmQYE6sReI/QMc +A7KbCfDIhTB+uinSlk/F6oNYEWPPQBhObLkyTSEjBC+SSyGRgnm9UBm4L20YXKQOBbL yyrzuSut9vo+5DjD0eZ72yyIeX8Km5kLYl6Sj5HTiU/f7NefBPtQdax7RK71UmxTFTC6 YaZA== X-Google-Smtp-Source: AJdET5e2fP/t1Qu1zfXBkpc+PbootYxSvNp2FUi3S7keZeteohCfTl2hA/2vrBx+uO25u70WowANVw== X-Received: by 2002:a17:902:443:: with SMTP id 61-v6mr7536198ple.216.1541746071478; Thu, 08 Nov 2018 22:47:51 -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.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 22:47:50 -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 10/11] mm: clear PageHWPoison in memory hotremove Date: Fri, 9 Nov 2018 15:47:14 +0900 Message-Id: <1541746035-13408-11-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 One hopeful usecase of memory hotplug is to replace half-broken DIMMs with new ones, so it makes sense to clear hwpoison info at the time of memory hotremove. I hope that this patch covers the topic discussed in https://lkml.org/lkml/2018/1/17/1228 Signed-off-by: Naoya Horiguchi --- mm/page_alloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git v4.19-mmotm-2018-10-30-16-08/mm/page_alloc.c v4.19-mmotm-2018-10-30-16-08_patched/mm/page_alloc.c index 970d6ff..27826b3 100644 --- v4.19-mmotm-2018-10-30-16-08/mm/page_alloc.c +++ v4.19-mmotm-2018-10-30-16-08_patched/mm/page_alloc.c @@ -8139,8 +8139,9 @@ __offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn) * The HWPoisoned page may be not in buddy system, and * page_count() is not 0. */ - if (unlikely(!PageBuddy(page) && PageHWPoison(page))) { + if (unlikely(!PageBuddy(page) && TestClearPageHWPoison(page))) { pfn++; + num_poisoned_pages_dec(); SetPageReserved(page); continue; } From patchwork Fri Nov 9 06:47:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 10675381 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 41448109C for ; Fri, 9 Nov 2018 06:48:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D73A2DD40 for ; Fri, 9 Nov 2018 06:48:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 204282DD76; Fri, 9 Nov 2018 06:48:04 +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 A5CE32DD40 for ; Fri, 9 Nov 2018 06:48:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AEBD16B06AA; Fri, 9 Nov 2018 01:47:55 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A4A216B06AC; Fri, 9 Nov 2018 01:47:55 -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 878B76B06AD; Fri, 9 Nov 2018 01:47:55 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 3769B6B06AA for ; Fri, 9 Nov 2018 01:47:55 -0500 (EST) Received: by mail-pf1-f198.google.com with SMTP id j9-v6so757557pfn.20 for ; Thu, 08 Nov 2018 22:47:55 -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=4TesSbGB62xA3TfNct4mvP8iyx81/GNoDwFhQH3EAIk=; b=c3qTwc/GyYSpIY7HrxIT3WjgSB9WdHeoQ35Xqp5JIJOcH2ly3XEIXTPCrkqXWscncq TD3FcY4/yyIR2cwTta99wck9ct8pubciHvsoWouFrcKRrXhwGogIbh6S2jKrUyN1D/Ll GDQQQfohKfKq59PP0Lm3e42RqV2ILQYATIWAAKNEb66eOR4SkCw2neltY1LnPHD3n8Db H6D4b9HD8UcQVtvN4u+YJHsPW9XsRHqhPN+3u01OYM9jcwJT2bpevWNBqOkKIjMdAiS0 GjWe2Mpk7apx/mLTVnah7kaeYjGPTmDEYU/ZFN5FGxJh0EtEOTDLwN0US2iVTqQRaoZQ L7Vw== X-Gm-Message-State: AGRZ1gK6QFti5TYNGiQh4OJAmf4mrhz2bJmfDdR5UlBrcP1Q1ohHl99f zoFvAWWdqVQy7se+wvxmLl6V4PQms2bCldsMrmjIiKLQzlH3Runq7fsicmyffYTwlF2ifJ2O6LK vZ7Ztpbl1hH61WZTY80vFIAJH+PI/C2TTulDQKqxNnkdOCsC/EJIQ9RYQHlTMuWjo2gG6ui1xca lQD1UClTKvoIJXSs0HhIN6UlfX5QHRhUm6rQoYU7sI2h+34o1WQLQbRtJfgiaIXLiItURZFliV6 yZWmlQnnqKXWhCgRH8QWMk/Tu3QNtt+EmhBd0mWLwE1Zzyp2/RDN2uaKWAzZzxrAo4BUFkVyu8i bgDGYmauGpPaGINbK0G+4xprh8/LJXFxSUkYsLJSpb7N/rcS/5pKqSzuBloASU74u9JKbr2BLw= = X-Received: by 2002:a63:e19:: with SMTP id d25mr6450985pgl.272.1541746074895; Thu, 08 Nov 2018 22:47:54 -0800 (PST) X-Received: by 2002:a63:e19:: with SMTP id d25mr6450956pgl.272.1541746074162; Thu, 08 Nov 2018 22:47:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541746074; cv=none; d=google.com; s=arc-20160816; b=mZJ1KIDhtfRFLWLwogyDxcswlcfvRBaVJK4cwLAFwXPbjcupxj6lnkE2buEegIblwQ g4bA/1W5kXKPlVP+w95/QgFQaZX0nWRsU12i8ZodvmB2GpJO87PRdzXbkAJ+425cVD5y rhKqT7DKXKZAJe96Je0r84yzJnbE4nmRQmCMXEhCwluUMnVDMGZ2YtHSkCTJOZUDKbhF saLqrzfIXKaX18+6Dppk1q7b1otGGHYL4d9rDanutAIfB0rhxwZ/zwHC1kG4lycxE3Yd qb6uTlYicSUKzNCsnjpwMRoY9Xl6xhGV04pDV0zeXkdHBxv8bArqo18oF0Tjry3fxuWf Tm+A== 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=4TesSbGB62xA3TfNct4mvP8iyx81/GNoDwFhQH3EAIk=; b=Xyeln2W3lRNnwjDTOOr1LdXQnaGvvXfyhgRYOgYdzDarnQlRd/GjMQkzynH/H6Etir 7SbvGxwsZC9uLdtWZiKnDnYjVUTaeBxdVJIxkksGvpgUGCso1Id5pXkU7QLLtZ98NpwQ nIpInlR88fKrGAzhmbP/bRtZwC1pbkHNgtQFEIlJsyBpXrH5jbOspFgumMft6pBeRI0B N89Tf1IrUnqZ68ahPWXzz9L3ibJLiEwEgDXkMfx9HgnRKoUnBs/3wHjD46srmJ+BVjas Yh/2aQEfyxKQbqeKO9dz1Fy53NX1ngkw/+mlXzVRgz8tDAPNmRulR1456GSKvNBXhgc4 NeBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EQCCDU5j; 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 e2-v6sor7945475pfb.55.2018.11.08.22.47.54 for (Google Transport Security); Thu, 08 Nov 2018 22:47:54 -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=EQCCDU5j; 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=4TesSbGB62xA3TfNct4mvP8iyx81/GNoDwFhQH3EAIk=; b=EQCCDU5jq8dKBb9Bx2axPP3NPwImXWLIPPUpv6FEDxDH6cnYuYAEup/9e1nd1HT5N8 PrN6eCPerDhFcP0D3dfwCsuegvm/ltXibHwfpR33+gfOu09iv9sELlZWny6hu+Lh/Sr+ W9hCcUKUeeguNjMo0Rw68BNVGO+y1udwMd4/FgcMNnM8BAygV6TYK7tSZ93c5GaMXaPW nArAMbBHt61uPNwtg43oGpRHRI/cfPOZHANtnpon5Hbhhy8ejsy/UGu5F22z4rue0hAe 3qrpRMZ2WUJMmtsiuyVdGN6UD/PETdMFvaMhwgpg/AlwrYVL0KzJgjPa84BkSLYlzKGc 8O6g== X-Google-Smtp-Source: AJdET5e+UNfklH05dKVCHvqkkKfrITeoZS/A79nDLAMCoHowK8sSI9VuqNMTbZy8PQiybkjee+Akew== X-Received: by 2002:a62:2c16:: with SMTP id s22-v6mr7724641pfs.6.1541746073710; Thu, 08 Nov 2018 22:47:53 -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.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 22:47:53 -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 11/11] mm: hwpoison: introduce clear_hwpoison_free_buddy_page() Date: Fri, 9 Nov 2018 15:47:15 +0900 Message-Id: <1541746035-13408-12-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 The new function is a reverse operation of set_hwpoison_free_buddy_page() to adjust unpoison_memory() to the new semantics. Signed-off-by: Naoya Horiguchi --- include/linux/page-flags.h | 8 +++++++- mm/memory-failure.c | 5 +++-- mm/page_alloc.c | 21 +++++++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git v4.19-mmotm-2018-10-30-16-08/include/linux/page-flags.h v4.19-mmotm-2018-10-30-16-08_patched/include/linux/page-flags.h index 50ce1bd..ab0bde0 100644 --- v4.19-mmotm-2018-10-30-16-08/include/linux/page-flags.h +++ v4.19-mmotm-2018-10-30-16-08_patched/include/linux/page-flags.h @@ -382,11 +382,17 @@ PAGEFLAG(HWPoison, hwpoison, PF_ANY) TESTSCFLAG(HWPoison, hwpoison, PF_ANY) #define __PG_HWPOISON (1UL << PG_hwpoison) extern bool set_hwpoison_free_buddy_page(struct page *page); +extern bool clear_hwpoison_free_buddy_page(struct page *page); #else PAGEFLAG_FALSE(HWPoison) static inline bool set_hwpoison_free_buddy_page(struct page *page) { - return 0; + return false; +} + +static inline bool clear_hwpoison_free_buddy_page(struct page *page) +{ + return false; } #define __PG_HWPOISON 0 #endif 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 af541141..a0e1cd4 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 @@ -1590,8 +1590,9 @@ int unpoison_memory(unsigned long pfn) } if (!get_hwpoison_page(p)) { - if (TestClearPageHWPoison(p)) - num_poisoned_pages_dec(); + if (!clear_hwpoison_free_buddy_page(p)) + return 0; + num_poisoned_pages_dec(); unpoison_pr_info("Unpoison: Software-unpoisoned free page %#lx\n", pfn, &unpoison_rs); return 0; diff --git v4.19-mmotm-2018-10-30-16-08/mm/page_alloc.c v4.19-mmotm-2018-10-30-16-08_patched/mm/page_alloc.c index 27826b3..9a90f93 100644 --- v4.19-mmotm-2018-10-30-16-08/mm/page_alloc.c +++ v4.19-mmotm-2018-10-30-16-08_patched/mm/page_alloc.c @@ -8270,4 +8270,25 @@ bool set_hwpoison_free_buddy_page(struct page *page) return hwpoisoned; } + +/* + * Reverse operation of set_hwpoison_free_buddy_page(), which is expected + * to work only on error pages isolated from buddy allocator. + */ +bool clear_hwpoison_free_buddy_page(struct page *page) +{ + struct zone *zone = page_zone(page); + bool unpoisoned = false; + + spin_lock(&zone->lock); + if (TestClearPageHWPoison(page)) { + unsigned long pfn = page_to_pfn(page); + int migratetype = get_pfnblock_migratetype(page, pfn); + + __free_one_page(page, pfn, zone, 0, migratetype); + unpoisoned = true; + } + spin_unlock(&zone->lock); + return unpoisoned; +} #endif