From patchwork Mon Jun 14 02:12:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 12318037 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 334A4C48BDF for ; Mon, 14 Jun 2021 02:12:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CFB836128B for ; Mon, 14 Jun 2021 02:12:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFB836128B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 74D186B007B; Sun, 13 Jun 2021 22:12:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 723846B007D; Sun, 13 Jun 2021 22:12:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5762E6B007E; Sun, 13 Jun 2021 22:12:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0019.hostedemail.com [216.40.44.19]) by kanga.kvack.org (Postfix) with ESMTP id 239226B007B for ; Sun, 13 Jun 2021 22:12:41 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B0EF68249980 for ; Mon, 14 Jun 2021 02:12:40 +0000 (UTC) X-FDA: 78250704714.01.319C766 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf30.hostedemail.com (Postfix) with ESMTP id 45D1AE000255 for ; Mon, 14 Jun 2021 02:12:35 +0000 (UTC) Received: by mail-pl1-f181.google.com with SMTP id 11so5733312plk.12 for ; Sun, 13 Jun 2021 19:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=06DPK/DIEfCFono0yuu1MCmhjq2CI/XtitXHneoP5fU=; b=oWnsV+BezW5KT/QArk9QVETWeqDfJl2d0xSVEz5fNV0UeDg3N0nGB6rHIPLkhFMd/l 3CDyZjxsWdP0wNJJ09O9ZUkWN3NL2fnd92bwl6sjl34LSCcfK8bguFt6wZlcqfswg9pa mrveVeMvidjJcKOLFf9eeAQvIRJIi+VnGYGTvCwf0dF3a7NbNRUWrYk9ECL8+s6chqk1 uLXgBjnhawBe2UKbquoCWVnptyLHUIzTBgkTIjQlAEB2Tf4+ytkwIMOFcaGUdA+d/jS+ Wgt2DoNznNULS4i12VJM4IW/Y+bRX5LXLjw4GXcc7LGQ5Wa4Xmhz2nx2xvY4ocpBGps4 dqpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=06DPK/DIEfCFono0yuu1MCmhjq2CI/XtitXHneoP5fU=; b=E4gcYo/7o14ABdGlewhW5IYz48qJp4P0CdyUH+cgD5Ya99nHj1c+SXIiHdWYfOEtqD KUQe2WsdBCMiEra9yXvlLudzygf4HyXbi+dNYkZkYnHCfNWAoWnWZ4tAwRAaKDcdDIdB 4XnJvcq7RUNXDGdK1N6hyEbmoAiZDqs6dqPvdHgvHj1afw7dzRcEs87f9jpzAcV8JbX1 FxM8tdSAGFV+NtWUuXoqGT6bH54K3JTgMHqiAXtAMy47kdR4QRiJVa7iinEaXjX7nRf8 LdS2efvr1SSUjzZQz0hgZ95CAY0/+AKMVjpleMd98+awHW7F9eEZghcSvsukcUp42XTV p8kA== X-Gm-Message-State: AOAM5333OMD+kKibgXoYJtjmwDsmPQrxE2WtJWFbQf0Sw+8Tk/NRp15t KpsmDTMCP0AX0P8DjSmjDH4eIRxD6oGr X-Google-Smtp-Source: ABdhPJyvl4bHahHn/RdmP86pL4VEvHOHD7AGza4lyMnl4KqJiAGuiYT+fHhiTBjNKFUP12KiHPsRMA== X-Received: by 2002:a17:90a:8816:: with SMTP id s22mr16662503pjn.231.1623636759326; Sun, 13 Jun 2021 19:12:39 -0700 (PDT) Received: from localhost.localdomain (h175-177-040-153.catv02.itscom.jp. [175.177.40.153]) by smtp.gmail.com with ESMTPSA id z14sm10952986pfn.11.2021.06.13.19.12.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jun 2021 19:12:39 -0700 (PDT) From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , David Hildenbrand , Oscar Salvador , Michal Hocko , Ding Hui , Tony Luck , "Aneesh Kumar K.V" , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v1 5/6] mm/hwpoison: make some kernel pages handlable Date: Mon, 14 Jun 2021 11:12:11 +0900 Message-Id: <20210614021212.223326-6-nao.horiguchi@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614021212.223326-1-nao.horiguchi@gmail.com> References: <20210614021212.223326-1-nao.horiguchi@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 45D1AE000255 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=oWnsV+Be; spf=pass (imf30.hostedemail.com: domain of naohoriguchi@gmail.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=naohoriguchi@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: w8mxxn5px4gxhi9455nqzh4g9qby164d X-HE-Tag: 1623636755-77406 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: From: Naoya Horiguchi HWPoisonHandlable() introduced by patch "mm,hwpoison: fix race with hugetlb page allocation" filters error events by page type, and only limited events reach get_page_unless_zero() to avoid race. Actually this is too restictive because get_hwpoison_page always fails to take refcount for any types of kernel page, leading to MF_MSG_KERNEL_HIGH_ORDER. This is not critical (no panic), but less informative than MF_MSG_SLAB or MF_MSG_PAGETABLE, so extend HWPoisonHandlable() to some basic types of kernel pages (slab, pgtable, and reserved pages). The "handling" for these types are still primitive (just taking refcount and setting PG_hwpoison) and some more aggressive actions for memory error containment are possible and wanted. But compared to the older code, these cases never enter the code block of page locks (note that page locks is not well-defined on these pages), so it's a little safer for functions intended for user pages not to be called for kernel pages. Signed-off-by: Naoya Horiguchi --- mm/memory-failure.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git v5.13-rc5/mm/memory-failure.c v5.13-rc5_patched/mm/memory-failure.c index b986936e50eb..0d51067f0129 100644 --- v5.13-rc5/mm/memory-failure.c +++ v5.13-rc5_patched/mm/memory-failure.c @@ -1113,7 +1113,8 @@ static int page_action(struct page_state *ps, struct page *p, */ static inline bool HWPoisonHandlable(struct page *page) { - return PageLRU(page) || __PageMovable(page); + return PageLRU(page) || __PageMovable(page) || + PageSlab(page) || PageTable(page) || PageReserved(page); } static int __get_hwpoison_page(struct page *page) @@ -1260,12 +1261,6 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, struct page *hpage = *hpagep; bool mlocked = PageMlocked(hpage); - /* - * Here we are interested only in user-mapped pages, so skip any - * other types of pages. - */ - if (PageReserved(p) || PageSlab(p)) - return true; if (!(PageLRU(hpage) || PageHuge(p))) return true; @@ -1670,7 +1665,10 @@ int memory_failure(unsigned long pfn, int flags) action_result(pfn, MF_MSG_BUDDY, res); res = res == MF_RECOVERED ? 0 : -EBUSY; } else { - action_result(pfn, MF_MSG_KERNEL_HIGH_ORDER, MF_IGNORED); + if (PageCompound(p)) + action_result(pfn, MF_MSG_KERNEL_HIGH_ORDER, MF_IGNORED); + else + action_result(pfn, MF_MSG_KERNEL, MF_IGNORED); res = -EBUSY; } goto unlock_mutex; @@ -1681,6 +1679,20 @@ int memory_failure(unsigned long pfn, int flags) } } + if (PageSlab(p)) { + action_result(pfn, MF_MSG_SLAB, MF_IGNORED); + res = -EBUSY; + goto unlock_mutex; + } else if (PageTable(p)) { + action_result(pfn, MF_MSG_PAGETABLE, MF_IGNORED); + res = -EBUSY; + goto unlock_mutex; + } else if (PageReserved(p)) { + action_result(pfn, MF_MSG_KERNEL, MF_IGNORED); + res = -EBUSY; + goto unlock_mutex; + } + if (PageTransHuge(hpage)) { if (try_to_split_thp_page(p, "Memory Failure") < 0) { action_result(pfn, MF_MSG_UNSPLIT_THP, MF_IGNORED);