From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71D61C27C79 for ; Tue, 18 Jun 2024 03:01:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A8D976B02CD; Mon, 17 Jun 2024 23:01:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A3CD66B02CE; Mon, 17 Jun 2024 23:01:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8DD186B02CF; Mon, 17 Jun 2024 23:01:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 6FFA96B02CD for ; Mon, 17 Jun 2024 23:01:49 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 02279120316 for ; Tue, 18 Jun 2024 03:01:48 +0000 (UTC) X-FDA: 82242509538.25.2EA3FED Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf17.hostedemail.com (Postfix) with ESMTP id 7024640008 for ; Tue, 18 Jun 2024 03:01:45 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718679698; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0i5xXvjmWFVLJrrJ8eThaGdDj12sG6MKzCM6tVctc0w=; b=4VCl5ozLYrlA5ZlTM5PcEg4acnShPVpXqQTgbMs7sEsg+BchJB7vCuH53lrgczle5DJvv+ xJdwUmLWFYf25I2ZushBbj0HhfYn0VbcpXD62C+DNQX0c+anfEUNd1Yb+D75BDz7OEt/zb 2QK3CynXMEp45q18vhsIkQmfnBReuPY= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718679698; a=rsa-sha256; cv=none; b=m5Zdl5U8r9xxwH4YZHhr6JyvqXZooYFFsS0WuKR2gP3pI0wQCCYPTvWMFH8TzDbwF6tg26 eyURuf89tBs2lFI6lORqNWc2jrWOGuwvm6R0CKEyRJf+clAKgiVu7tLZjRMSd1jWhRLzX5 +TLtnwqet/2lWZOktQTQgDz7/Qz6zEw= Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4W3BH42FR6znVbf; Tue, 18 Jun 2024 10:56:48 +0800 (CST) Received: from canpemm500002.china.huawei.com (unknown [7.192.104.244]) by mail.maildlp.com (Postfix) with ESMTPS id BA01518007A; Tue, 18 Jun 2024 11:01:40 +0800 (CST) Received: from [10.173.127.72] (10.173.127.72) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 18 Jun 2024 11:01:39 +0800 Subject: Re: [PATCH v3 1/3] mm/memory-failure: userspace controls soft-offlining pages To: Jiaqi Yan , Andrew Morton CC: , , , , , , , , , , , , References: <20240617170545.3820912-1-jiaqiyan@google.com> <20240617170545.3820912-2-jiaqiyan@google.com> <20240617121348.4ee672a1d6bc9202b3ad0e08@linux-foundation.org> From: Miaohe Lin Message-ID: <1a40217a-240c-4efb-5c2a-fe885c0109ea@huawei.com> Date: Tue, 18 Jun 2024 11:01:39 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.173.127.72] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500002.china.huawei.com (7.192.104.244) X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 7024640008 X-Stat-Signature: dmaqnj3itcotuw4a4y3mhr7n7sgou81h X-Rspam-User: X-HE-Tag: 1718679705-155345 X-HE-Meta: U2FsdGVkX1/EZ0qs583zDje0j+cfxwG3yshHZTNmR48JEICJ+PGbLl1diFv741inDFAjFZOwPp3Qicr53IYDi8DPqMIUxEFvvOW2DB/Ghk59h/X3f7ua7oh4TGY9PMn5tCriJw80yxXa2EaXCYnTmT7ajiEJDqC1SeQxWxtdiWkCzU1AevC9W6tFkfzIcGPbmWTz7bGuf2+OluQ/TKUWhEG5iGL0zA5Nex8Gq/4J8PJOba8pxasK5LcBpmebElNTevWxV2SbuuZz4A/TdXC9ooLDji2lYwkgBft7hig+H8uBPvW7C1RX/7OqlEPyHDmQuhgpfxJ22bfWSWr+mfhG1ozIjN9KqFqqV9MJEQI9W9Wupcg466sUFS8DS+OIrJNbTSBCTD9AH6M+g0B6K8/oYyr7mg8YWTq5AXQQpk0SbMeBoaS9VY8+8vgQARTTW/uUgme6XV/8rjlBj1XXXEqj7Ci6YcXynnF52WU+Bsw2dfiHVG1sDbRNHiZZlsae5holRxBMXzg88i9UmtturqzMD/r4h+/bN8yYSi0cVfO9xWJcHlrVHImsHGWv6VfZjNEil4FJqvh6yRRhAEKwUvz44EgiYCwvGdguYcHXylqVx45vKiLLbN3YItmvojIOCMv8zBaqwlnkJmSocVGuEBrCCEX+A5ivntVA2qBm8fENCWgBPoA2XiPQBSIsU4jjbLGnEQwbO3J8HK7ZIXoEyaW0eA2Mdmy2rZ5LYJqunlp/1ykGpAsC79JKl3/Dc2SmEd7ZQz5Gj0W280ii70pAdfIw7kyH7x/mZE8UoKCGI5JqQpYGabs8yyVjBNspe2RalZDPmP1GUOv8O20cB9FQ1MH4MiDs9RpNll8eXwqbpkbX4i2YAg9BQqkw62aLa8TG0crhc2qZ+8MllapBzwVOPHpKa3FUeLRWj2D9VidqtxbAgpIWNLrmNRfwLL8jglU5hGrgiUQHpWZzV1CcSlUbbt2 q2yvqaae HM0N3kAj0Ejx29YhT0EGLSqa0g1Y2N5e+zHeb4itTnrFl2Jlwf4amZJHQTa99IuM4CRzqQxEMQaKdn02cnQaAVCBYqhil8zg2jU8KiufRx7N4KHxLAh9eqcedpw/88eIcFeLsNMfq/eQyKQXvp3R02TEtVxk60DnZjhq+tOBVfqW1oUXPwMnYhQygGypLb0OJc2t72et0uYMmz9B7yeXHfW19d2tiLW3hCyL9Xdpx7glTAaYU5ODo57BvJu/5Wqj6vEvLaizGWD5D8WzgTvkecoalSqcpjUcrIzyQk3v1T8iwvdbWnVj5sdWt7A1PY6pkVISt 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: List-Subscribe: List-Unsubscribe: On 2024/6/18 7:17, Jiaqi Yan wrote: > On Mon, Jun 17, 2024 at 12:13 PM Andrew Morton > wrote: >> >> On Mon, 17 Jun 2024 17:05:43 +0000 Jiaqi Yan wrote: >> >>> Correctable memory errors are very common on servers with large >>> amount of memory, and are corrected by ECC. Soft offline is kernel's >>> additional recovery handling for memory pages having (excessive) >>> corrected memory errors. Impacted page is migrated to a healthy page >>> if it is in-use; the original page is discarded for any future use. >>> >>> The actual policy on whether (and when) to soft offline should be >>> maintained by userspace, especially in case of an 1G HugeTLB page. >>> Soft-offline dissolves the HugeTLB page, either in-use or free, into >>> chunks of 4K pages, reducing HugeTLB pool capacity by 1 hugepage. >>> If userspace has not acknowledged such behavior, it may be surprised >>> when later failed to mmap hugepages due to lack of hugepages. >>> In case of a transparent hugepage, it will be split into 4K pages >>> as well; userspace will stop enjoying the transparent performance. >>> >>> In addition, discarding the entire 1G HugeTLB page only because of >>> corrected memory errors sounds very costly and kernel better not >>> doing under the hood. But today there are at least 2 such cases >>> doing so: >>> 1. GHES driver sees both GHES_SEV_CORRECTED and >>> CPER_SEC_ERROR_THRESHOLD_EXCEEDED after parsing CPER. >>> 2. RAS Correctable Errors Collector counts correctable errors per >>> PFN and when the counter for a PFN reaches threshold >>> In both cases, userspace has no control of the soft offline performed >>> by kernel's memory failure recovery. >>> >>> This commit gives userspace the control of softofflining any page: >>> kernel only soft offlines raw page / transparent hugepage / HugeTLB >>> hugepage if userspace has agreed to. The interface to userspace is a >>> new sysctl at /proc/sys/vm/enable_soft_offline. By default its value >>> is set to 1 to preserve existing behavior in kernel. When set to 0, >>> soft-offline (e.g. MADV_SOFT_OFFLINE) will fail with EOPNOTSUPP. >>> >> >> Seems reasonable. A very simple patch. > > Thanks for taking a look, Andrew! > >> >> Is there sufficient instrumentation in place for userspace to be able >> to know that these errors are occurring? To be able to generally >> monitor the machine's health? > > For corrected memory errors, in general they are available in kernel > logs. On X86 Machine Check handling will log unparsed MCs (one needs > to read mci_status to know what exactly the error is). On ARM, GHES > logs parsed CPER (already containing error type and error severity). > The shortcoming is logs are rate limited. So in a burst of corrected > memory errors the user may not be able to figure out exactly how many > there were. > > For uncorrectable memory errors, num_poisoned_pages is a reliable counter. > >> >>> @@ -2783,6 +2795,12 @@ int soft_offline_page(unsigned long pfn, int flags) >>> return -EIO; >>> } >>> >>> + if (!sysctl_enable_soft_offline) { >>> + pr_info("%#lx: OS-wide disabled\n", pfn); >> >> This doesn't seem a very good message. There's no indication that it >> comes from the memory failure code at all. If the sysadmin sees this >> come out in the kernels logs, he/she will have to grep the kernel >> sources just to figure out where the message came from. Perhaps we can >> be more helpful here.. > > For sure. I took it for granted that any pr_info will have the "Memory > failure: " prefix, but now realize there is a `#undef pr_fmt` + > `#define pr_fmt(fmt) "" fmt` just above unpoison_memory. > > I propose to do `#define pr_fmt(fmt) "Soft offline: " fmt` above > mf_isolate_folio, so that any soft-offline related code generates logs > with the same following format: > > "Soft offline: 0x${pfn}: ${detailed_message}" > > If everyone thinks this is reasonable, in v4 I can insert a new commit > to make the log formats unified. This sounds fine to me. And even better, `#define pr_fmt(fmt) "Unpoison: " fmt` can also be done just above unpoison_memory. Thanks. .