From patchwork Mon Jul 9 04:16:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 10513459 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ABE5960318 for ; Mon, 9 Jul 2018 04:19:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80FB728A1B for ; Mon, 9 Jul 2018 04:19:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7445728A21; Mon, 9 Jul 2018 04:19:42 +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.9 required=2.0 tests=BAYES_00, 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 6C1E928A1B for ; Mon, 9 Jul 2018 04:19:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DDA86B0003; Mon, 9 Jul 2018 00:19:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 48CC46B0006; Mon, 9 Jul 2018 00:19:39 -0400 (EDT) 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 37CB36B0007; Mon, 9 Jul 2018 00:19:39 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f198.google.com (mail-pf0-f198.google.com [209.85.192.198]) by kanga.kvack.org (Postfix) with ESMTP id E78D16B0003 for ; Mon, 9 Jul 2018 00:19:38 -0400 (EDT) Received: by mail-pf0-f198.google.com with SMTP id h14-v6so10954008pfi.19 for ; Sun, 08 Jul 2018 21:19:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:thread-topic:thread-index:date:message-id:references :in-reply-to:accept-language:content-language:content-id :content-transfer-encoding:mime-version; bh=44vvLBKOe4o7XX9L5CCiw2Yt1akn7QYHhy+IlGTZs0c=; b=tnT9NzRTtXKKnpnZwpT0LQv70YsxltxjOSinZDNEgNZD6YurXkBRWQO8kERSEFIs1f mJh9MJM9S6KiIVeEq4gjseeVk0xgyvG5Sdc9JD1cpaEfyJEHQE1sbBq+dXwolXhndKEs GAquuNMeGsHXPqzV0psoavTkTc3hWE6KrUAgTaCROTW/PxA2pObMzW1q9p+4ANKnSM39 yhKvIMzUAcHUI8UWw8BEqMDjoqfj8mZBkC5blPaRfQlQWeS/eKq6cEVxyW7E78w4VdpT u4cWysiReF43LrL2rmUnEvQZD2X7akeeToUEBdq6YM/SJV+DTRhweNQog6XRGfqO6GOm 44Gw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of n-horiguchi@ah.jp.nec.com designates 114.179.232.162 as permitted sender) smtp.mailfrom=n-horiguchi@ah.jp.nec.com X-Gm-Message-State: APt69E0+7p0ypYlY79HeCg/1087j7fl4qirad4cMoajkgFrDiuA37V6n jpM1dq3P3/sYjdzLyAeJ1ppeOPsNkayBBLuKKpTLe7iK9Rbwis4o9XtKZUswdyq/Vm8TkEFTEgw c17lxbiOg+uU7JOWSAxQJSPW9P0Muvj3AQzoqL+KM+OXSFI74gnu2+iUiplwvrhRC9A== X-Received: by 2002:a62:3481:: with SMTP id b123-v6mr19735027pfa.4.1531109978518; Sun, 08 Jul 2018 21:19:38 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeIZRctz2CzsydqQ7/ZVjdcXatxAgq1IWeQJTSzNlS/pt30s1ekldM+RUOd54hivKE+6vhH X-Received: by 2002:a62:3481:: with SMTP id b123-v6mr19734992pfa.4.1531109977394; Sun, 08 Jul 2018 21:19:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531109977; cv=none; d=google.com; s=arc-20160816; b=TSLbmKOn4iHINVnpwk5mPImrKF9qc8kN2WjJBM5AntgV+ALypGDWvEeBJApR8PFPuj lJHZNB1HDqrgnRU6P2j3kmTKO+7C/LE9uwzlNHz0aDj2YBqKDDw70IueJ7Nw4mZ3T+Fi W3RM3gO7BsVPU+loeGeKLPbGn7h6n77UA09QdmKkhu9jyvNZZ3eeJNJNeKRx8shR8QuT YwbmO4S4AFcRKhrfH3ARoapLewemooOI7GaoXg/naeWavAcOSmlhQ89YwutaXUWqpnNS zL8qnvjxkNO4QxJ89Gshj194Ya1+k7dF9pnl+zFZGb9x4vy2HFVbfOeQs6Cu2JHjMWmU dXvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-transfer-encoding:content-id:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:arc-authentication-results; bh=44vvLBKOe4o7XX9L5CCiw2Yt1akn7QYHhy+IlGTZs0c=; b=MVhmk1RH0JHZaqI8obbCPrJ6UhuJXgheMeFHddl3iqIXvEEizsjrqkW5CNchRCDgnb foAfkWXCW3Zj4HRtEBrDwYRBt2D5POtn78MdnZKB+JVB/Y1I3pSDlvLAhKJOvjIEhsXb xGnda7zIb74pAJJZ3dhMiccVanUeef4fJ1zE8AOFvnXwixa5UJ1wZRcRNlbzTFqpJG4C NxbEccNR2ZQKLQoh808AIQgJhNiGhE39dZzTDXfo82gX6bJOCUc1uMmgyccuVVcOC68t yTNKdJ3QrJn2VPZgbvs/HvMS4kSiiCQIdm+oyrgRHM21mPlHBeD3scREM+C6hok3azyT wwww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of n-horiguchi@ah.jp.nec.com designates 114.179.232.162 as permitted sender) smtp.mailfrom=n-horiguchi@ah.jp.nec.com Received: from tyo162.gate.nec.co.jp (tyo162.gate.nec.co.jp. [114.179.232.162]) by mx.google.com with ESMTPS id q129-v6si13022552pga.217.2018.07.08.21.19.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Jul 2018 21:19:37 -0700 (PDT) Received-SPF: pass (google.com: domain of n-horiguchi@ah.jp.nec.com designates 114.179.232.162 as permitted sender) client-ip=114.179.232.162; Authentication-Results: mx.google.com; spf=pass (google.com: domain of n-horiguchi@ah.jp.nec.com designates 114.179.232.162 as permitted sender) smtp.mailfrom=n-horiguchi@ah.jp.nec.com Received: from mailgate02.nec.co.jp ([114.179.233.122]) by tyo162.gate.nec.co.jp (8.15.1/8.15.1) with ESMTPS id w694JWcX015374 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 9 Jul 2018 13:19:32 +0900 Received: from mailsv02.nec.co.jp (mailgate-v.nec.co.jp [10.204.236.94]) by mailgate02.nec.co.jp (8.15.1/8.15.1) with ESMTP id w694JWlj014816; Mon, 9 Jul 2018 13:19:32 +0900 Received: from mail03.kamome.nec.co.jp (mail03.kamome.nec.co.jp [10.25.43.7]) by mailsv02.nec.co.jp (8.15.1/8.15.1) with ESMTP id w694JWmG006519; Mon, 9 Jul 2018 13:19:32 +0900 Received: from bpxc99gp.gisp.nec.co.jp ([10.38.151.151] [10.38.151.151]) by mail03.kamome.nec.co.jp with ESMTP id BT-MMP-1831189; Mon, 9 Jul 2018 13:16:54 +0900 Received: from BPXM23GP.gisp.nec.co.jp ([10.38.151.215]) by BPXC23GP.gisp.nec.co.jp ([10.38.151.151]) with mapi id 14.03.0319.002; Mon, 9 Jul 2018 13:16:53 +0900 From: Naoya Horiguchi To: =?gb2312?B?9MPPocqvKM+hyq8p?= CC: linux-mm , linux-kernel , =?gb2312?B?s8LS5cir?= Subject: =?gb2312?B?UmU6IFJlo7pbUkZDXSBhIHF1ZXN0aW9uIGFib3V0IHJldXNlIGh3cG9pc29u?= =?gb2312?B?IHBhZ2UgaW4gc29mdF9vZmZsaW5lX3BhZ2UoKQ==?= Thread-Topic: =?gb2312?B?UmWjultSRkNdIGEgcXVlc3Rpb24gYWJvdXQgcmV1c2UgaHdwb2lzb24gcGFn?= =?gb2312?B?ZSBpbiBzb2Z0X29mZmxpbmVfcGFnZSgp?= Thread-Index: AQHUFyzyen5req9zq0m4Y5pdL5T/YqSFshiA Date: Mon, 9 Jul 2018 04:16:52 +0000 Message-ID: <20180709041651.GA19949@hori1.linux.bs1.fc.nec.co.jp> References: <95e5634d-f78f-45bb-9847-1eb5bbdac3cf.xishi.qiuxishi@alibaba-inc.com> In-Reply-To: <95e5634d-f78f-45bb-9847-1eb5bbdac3cf.xishi.qiuxishi@alibaba-inc.com> Accept-Language: en-US, ja-JP Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.51.8.81] Content-ID: <296F04ED85E0D64FA875F495F431D34B@gisp.nec.co.jp> MIME-Version: 1.0 X-TM-AS-MML: disable 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 On Mon, Jul 09, 2018 at 10:31:25AM +0800, 裘稀石(稀石) wrote: > Hi Naoya, > > I think the double check can not fix the problem as I said in another email. > If someone mmap before soft offline, so the page_count(head) is still zero > in soft offline, then hwpoison flag set and it can not be alloced again in > dequeue_huge_page_node_exact() during page fault, so page fault return > no-mem, and someone will be killed (not mce kill). > > How about just set hwpoison flag after soft_offline_free_page - > dissolve_free_huge_page > successfully? It will fix the both two problems (mce kill and no-mem kill). Thank you for elaborating, you're right. So do you like a fix like this? diff --git a/mm/hugetlb.c b/mm/hugetlb.c index d34225c1cb5b..3c9ce4c05f1b 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1479,22 +1479,20 @@ static int free_pool_huge_page(struct hstate *h, nodemask_t *nodes_allowed, /* * Dissolve a given free hugepage into free buddy pages. This function does * nothing for in-use (including surplus) hugepages. Returns -EBUSY if the - * number of free hugepages would be reduced below the number of reserved - * hugepages. + * dissolution fails because a give page is not a free hugepage, or because + * free hugepages are fully reserved. */ int dissolve_free_huge_page(struct page *page) { - int rc = 0; + int rc = -EBUSY; spin_lock(&hugetlb_lock); if (PageHuge(page) && !page_count(page)) { struct page *head = compound_head(page); struct hstate *h = page_hstate(head); int nid = page_to_nid(head); - if (h->free_huge_pages - h->resv_huge_pages == 0) { - rc = -EBUSY; + if (h->free_huge_pages - h->resv_huge_pages == 0) goto out; - } /* * Move PageHWPoison flag from head page to the raw error page, * which makes any subpages rather than the error page reusable. @@ -1508,6 +1506,7 @@ int dissolve_free_huge_page(struct page *page) h->free_huge_pages_node[nid]--; h->max_huge_pages--; update_and_free_page(h, head); + rc = 0; } out: spin_unlock(&hugetlb_lock); diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 9d142b9b86dc..e4c7e3ec7b10 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1715,13 +1715,13 @@ static int soft_offline_in_use_page(struct page *page, int flags) static void soft_offline_free_page(struct page *page) { + int rc = 0; struct page *head = compound_head(page); - if (!TestSetPageHWPoison(head)) { + if (PageHuge(head)) + rc = dissolve_free_huge_page(page); + if (!rc && !TestSetPageHWPoison(head)) num_poisoned_pages_inc(); - if (PageHuge(head)) - dissolve_free_huge_page(page); - } } /**