From patchwork Mon Jul 9 05:43:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?UTF-8?B?6KOY56iA55+zKOeogOefsyk=?= X-Patchwork-Id: 10513593 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 5A9D660318 for ; Mon, 9 Jul 2018 05:43:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4228B28A21 for ; Mon, 9 Jul 2018 05:43:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33B7028A25; Mon, 9 Jul 2018 05:43:55 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FROM_EXCESS_BASE64, HTML_MESSAGE, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY 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 BD36528A21 for ; Mon, 9 Jul 2018 05:43:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86F6C6B000D; Mon, 9 Jul 2018 01:43:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7F7F76B000E; Mon, 9 Jul 2018 01:43:52 -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 698716B0010; Mon, 9 Jul 2018 01:43:52 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f200.google.com (mail-pf0-f200.google.com [209.85.192.200]) by kanga.kvack.org (Postfix) with ESMTP id 1EA616B000D for ; Mon, 9 Jul 2018 01:43:52 -0400 (EDT) Received: by mail-pf0-f200.google.com with SMTP id b17-v6so9601225pff.17 for ; Sun, 08 Jul 2018 22:43:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:reply-to :message-id:subject:mime-version; bh=3VAwHBQLuDLLf5b1uYhRM5S9JCqfnr2Ke8VKIA5ZcF0=; b=lJeRZ4cRkkwknH9SvbaeJHK4E5ieGttUORAcrRoBjLdJTzlplNsjOexr/5fBuHIGKL 8rHOQR1unEOi2rNlLab4tj8804E1oaTqlYOC6oL1EbNu0nYnIAxoBRZr+EVwM6zxBfBW gkzaZ//CsxdsY3SceEThXpqVQuyVlZyD2FO1GkCa6eaN8hRuqHxiafyqk84lshHrVGa8 V1V7qDZ1ltoL+JrhlRS3WwQupL5XCJl4xV9IlYSASh0enUnuiM4nqaYSxqPbAxu8TZUa bpOsKRPuspzb5+tciIkLvHyqIRQEwypIfe08xSM2PqmDtxDGShsVy3x3r5eLiskaE9RN Kb1A== X-Gm-Message-State: APt69E1tn1hxyJ9C5ZEHmDbP42G8KAQa4WbUORk+aZO+e62v7f2ybaQ7 PUVIlS94bpEF6+ADoU/uZS8lBjySl0IumSz3evfC57YrQWUKRY6iA8Zy1ft74I9fu7fCew18zLQ Pm6DKN6Lefe4gS8cqlu4figSb8ul83BrF7DSBDKNMXiSset/d0JsRhNGnYcr+LWOLlw== X-Received: by 2002:a62:569c:: with SMTP id h28-v6mr20078204pfj.201.1531115031771; Sun, 08 Jul 2018 22:43:51 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf26HbsRhNBwDy4n4rf1E9Vd+0nE9Azid9NuqLdgRCjzJMuyUL8raszwahUm2MAyvmtHsso X-Received: by 2002:a62:569c:: with SMTP id h28-v6mr20078181pfj.201.1531115030852; Sun, 08 Jul 2018 22:43:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531115030; cv=none; d=google.com; s=arc-20160816; b=Bey98pPqTXkX0MPZWtoH1fYZ/FhTnWEEaDFC0hBJURLKHL25njY4mJEI32zHwweWLm DR5mled1WMtP9HNOU+HxDzd2++zSzTCYUqvrQ+xqhYO2UTQnVgdUn892tDZIJHRhMDsT po3iIFV77Y+r8pwce5+NX+6cNJ/ePNgliLy1nPNcG/6bn4gnJZwHpp0AU6s42YPuIFyR RPZFZJ+JT/JobySn3Nzev8k1t+jzYyQJRefOHN1UH2RQz1ejXCrXZyM72R68bc3az8mg Nt593FL6ylBlb4VrfwPHuU4i7QZwF/o4RRvtOzj+/pRn7sGiSwuBqDacwOuq5D1n2fHY RMAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:subject:message-id:reply-to:cc:to:from:date :dkim-signature:arc-authentication-results; bh=3VAwHBQLuDLLf5b1uYhRM5S9JCqfnr2Ke8VKIA5ZcF0=; b=qxcyQG83bGtoO2Ifor7erhm//94Ol5KlCkzWFmuXJoGtYOL56skwS5+I4FxOlE4VEV vuNkDugB6T4/WyTVmdFFst6dbkn4X8A1lBXUWzc3qqAFHr14kYxv+cZm8m2zaDMG9rpa LQHLh6xR0JpKZb+ZQkD8tdNyhd/qfAknKRCkcma8OoSvRmPjByO92XzhvqBE31jJIF2G mA79+VvPi2VHRyjW3jop0w5zuhDwhAElXQrgtbm1cRUJadeb7vQPcfbAg0IGwrJbeTEZ XWC9t4l7/IyAZuNMlby6y+S8f9FSGShyIkcNh8H4KiHU5BH7bLlNE8LHMzM3s5oLmhWy hzBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alibaba-inc.com header.s=default header.b=Lfxmi9h8; spf=pass (google.com: domain of xishi.qiuxishi@alibaba-inc.com designates 47.88.44.33 as permitted sender) smtp.mailfrom=xishi.qiuxishi@alibaba-inc.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba-inc.com Received: from out4433.biz.mail.alibaba.com (out4433.biz.mail.alibaba.com. [47.88.44.33]) by mx.google.com with ESMTPS id t19-v6si661590plo.350.2018.07.08.22.43.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Jul 2018 22:43:50 -0700 (PDT) Received-SPF: pass (google.com: domain of xishi.qiuxishi@alibaba-inc.com designates 47.88.44.33 as permitted sender) client-ip=47.88.44.33; Authentication-Results: mx.google.com; dkim=pass header.i=@alibaba-inc.com header.s=default header.b=Lfxmi9h8; spf=pass (google.com: domain of xishi.qiuxishi@alibaba-inc.com designates 47.88.44.33 as permitted sender) smtp.mailfrom=xishi.qiuxishi@alibaba-inc.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba-inc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alibaba-inc.com; s=default; t=1531115016; h=Date:From:To:Message-ID:Subject:MIME-Version:Content-Type; bh=3VAwHBQLuDLLf5b1uYhRM5S9JCqfnr2Ke8VKIA5ZcF0=; b=Lfxmi9h8jUhchfpQbAgJI1j0VgPT0ZRA9E3XOpwjyFgcT7ERAXSdmw0GrLwhDENuHhqc7GYNMAQPGHrTS4h+muPbeEUVh4n6LMXIIGiyIgqRIicUv2+ldliJ9HIH9u77JOqdVkZYCm5NWh8juZNeILyt4Eb8/wLkGrEcgBI4uzg= X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R181e4; CH=green; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e02c03310; MF=xishi.qiuxishi@alibaba-inc.com; NM=1; PH=DW; RN=4; SR=0; TI=W4_5305839_v5ForDing_0A932697_1531114637516_o7001c357s; Received: from WS-web (xishi.qiuxishi@alibaba-inc.com[W4_5305839_v5ForDing_0A932697_1531114637516_o7001c357s]) by e02c03269.eu6 at Mon, 09 Jul 2018 13:43:35 +0800 Date: Mon, 09 Jul 2018 13:43:35 +0800 From: "=?UTF-8?B?6KOY56iA55+zKOeogOefsyk=?=" To: "Naoya Horiguchi" Cc: "linux-mm" , "linux-kernel" , "=?UTF-8?B?6ZmI5LmJ5YWo?=" Reply-To: "=?UTF-8?B?6KOY56iA55+zKOeogOefsyk=?=" Message-ID: <518e6b02-47ef-4ba8-ab98-8d807e2de7d5.xishi.qiuxishi@alibaba-inc.com> Subject: =?UTF-8?B?UmXvvJpbUkZDXSBhIHF1ZXN0aW9uIGFib3V0IHJldXNlIGh3cG9pc29uIHBhZ2UgaW4gc29m?= =?UTF-8?B?dF9vZmZsaW5lX3BhZ2UoKQ==?= X-Mailer: [Alimail-Mailagent revision 268][W4_5305839][v5ForDing][Chrome] MIME-Version: 1.0 x-aliyun-mail-creator: W4_5305839_v5ForDing_wgbTW96aWxsYS81LjAgKE1hY2ludG9zaDsgSW50ZWwgTWFjIE9TIFggMTBfMTJfNikgQXBwbGVXZWJLaXQvNTM3LjM2IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzYyLjAuMzIwMi45NCBTYWZhcmkvNTM3LjM2IERpbmdUYWxrKDQuMy43LW1hY09TKSBudw==NT 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 Hi Naoya, Shall we fix this path too? It also will set hwpoison before dissolve_free_huge_page(). soft_offline_huge_page migrate_pages unmap_and_move_huge_page if (reason == MR_MEMORY_FAILURE && !test_set_page_hwpoison(hpage)) dissolve_free_huge_page Thanks, Xishi QiuOn 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); - } } /**