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 7EA65C27C7B for ; Fri, 14 Jun 2024 03:29:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 406726B00A4; Thu, 13 Jun 2024 23:29:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B6AF6B00AD; Thu, 13 Jun 2024 23:29:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 62A006B00A8; Thu, 13 Jun 2024 23:29:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 8EA8F6B00E5 for ; Thu, 13 Jun 2024 23:28:49 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 35C5AA046A for ; Fri, 14 Jun 2024 03:28:49 +0000 (UTC) X-FDA: 82228062378.08.425C104 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf26.hostedemail.com (Postfix) with ESMTP id 6F093140009 for ; Fri, 14 Jun 2024 03:28:45 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 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=1718335726; a=rsa-sha256; cv=none; b=xeuMLA9zkdVnGDYjUtbaVpsKg0dFtg5QYi78HtQW6PrO3KpVORuRQI3qA3YFP1NliGKiVN Ar+5wZU0YzWy8TV95nKDadmghVIiyxZ0sTESqCR/yXI80D2AsquiQ6Gm8mhoA1iHEzu3qW Sh/9Rd2OBH2F/CCdnDdYLy4L935rneA= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 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=1718335726; 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=s8mp/l/WynqDYv7rG3x0C786wOauS5K5JICn18+HSUs=; b=i6UIbX404xmbDZLMYtyo2hSJYMdfn/VEMQG0O82ar/otsngTuxit0JMO2ZMgAXySs8udkW OR7FK18BekZudR9B+8jMi+FOFtAJtEhOX3KeSapCKVZoyjgFl98g186WO1aGNsxyOA4cyn tn9UxJTY8llu4DawYzclaBv3fHuvAjM= Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4W0l5k04JSzPqgX; Fri, 14 Jun 2024 11:25:14 +0800 (CST) Received: from canpemm500002.china.huawei.com (unknown [7.192.104.244]) by mail.maildlp.com (Postfix) with ESMTPS id EA0321400DC; Fri, 14 Jun 2024 11:28: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; Fri, 14 Jun 2024 11:28:40 +0800 Subject: Re: [PATCH v2 1/3] mm/memory-failure: userspace controls soft-offlining pages To: Jiaqi Yan CC: , , , , , , , , , , , , References: <20240611215544.2105970-1-jiaqiyan@google.com> <20240611215544.2105970-2-jiaqiyan@google.com> From: Miaohe Lin Message-ID: <1e6ecf75-c489-7711-3289-e4a396ca9484@huawei.com> Date: Fri, 14 Jun 2024 11:28: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: <20240611215544.2105970-2-jiaqiyan@google.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.173.127.72] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-Stat-Signature: 3zhix4jeotwco1m7r6yyinysapz9qzkq X-Rspamd-Queue-Id: 6F093140009 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1718335725-699169 X-HE-Meta: U2FsdGVkX1+xMXbXzwAGWrJNG+L2jXAYpC5u1uqE20bqkpeOoNosVFTPpBmsVXkmCvdpBLZFXJOXxkec7GlXqBrIdkiTSlgq3iXkLGFjryN7Z6EwbZbMq47+t6/w1BF3JYQwyUBvF3f8mdyZ0m4XnLqLL90OTMbP792KfnEIuhpcXFDM2YchKSPgr+t3RKlLJhqgUjgrS9RIcDfuz7gbuJ3lf26HGoIgHtBscTuK0bDi95nVOd49pIck3+1dzuQgxPrszbRoaBiZHE7gQAVWiNPqdIwF4msikv9blX87nYuwXGGNENMQAnL3vdgyfRq58xKEKmpjj1Aw0OVtTHZFg4l+6jiXsmd6o/h8VMNZWT02I7C5ROEP/Rz/qMV2qFLZe3YHCB98LqM77dmY087tWRNxM/80jV50zyn0AsUMqDNmm7mD0NCw7GwTs2ioKsDSBkl+ZmElDDTdtbNQ+rm4OTeRoUoLGxw1iGcO6yPXeuL0UX/9pMEINW3vW+Z+osp3jaDJqsc4bB49bGPSxtRTMcEPqFpSnaDfn6p4/GCPStpBsJrjZcyv+JSU0URzppCw4T/nJIaOAi1VQDBrOl0c+oKveHcVB3jCyT6y+P3vVM1HKNpo9hIoXM8g26FNza21Zbxw/PiTrzf+dqXcdyTFv6J8Bdd1/qvnxl7OCc3rG8+pK5wYdCaNfFpGWPVKtUoeE4lnksZu4hhwtq3ePitgklRwB4qzeOZMFkbMxOq3RaoRuNCwdYw6ti5POcM2dV126UHbkhIjPB54FIFOojPoZy1lcLlvrq4xk/6b3X3NuyzZojQsTYwxwu34VwgrlZ2pIXWQAwA49MVzyhDA7ptpt1/Y+/tD5yTY5iGIHfur1NFwMahAAZKE4GNwkaga7ygruszCsva1l31w9AkO6b3R/dCDDh9W1dL998HI1HPfZcePZ/HuPpE1Yzuo3B+exq1z3yFl27UhBSZJORkggAX uBkMn7Wd lsA/QGnmGOyQP/pcc9zVUaC4hrzrzAfEvpm4vX4e+rT1RUGIEKbsrwHd8tmeG5g4rDqvFZMTdK0zzP1SdyvX9GRiT9TZo7TkxocCuxTSqRY/UmFEFX+kOnoZmLN7/Jrw1qaDNIwO6cZV8l6ri+u5sFkTHQr+SXpmsq4wVRKeN/XxKo+ZK/XqyXp+35Xh+irLnpkE8ML3eT1pTwTjUsQUmTvBrUTha5IDxQNESE8JB8BONLJk= 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/12 5:55, 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 inuse; the original page is discarded for any future use. > Thanks for your update. > 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 mmap hugepages MAP_FAILED due to lack of hugepages. s/mmap hugepages MAP_FAILED/fails to mmap 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: s/doing/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 called enable_soft_offline under /proc/sys/vm. By default > enable_soft_line is 1 to preserve existing behavior in kernel. s/enable_soft_line/enable_soft_offline/ > > Signed-off-by: Jiaqi Yan > --- > mm/memory-failure.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index d3c830e817e3..23415fe03318 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -68,6 +68,8 @@ static int sysctl_memory_failure_early_kill __read_mostly; > > static int sysctl_memory_failure_recovery __read_mostly = 1; > > +static int sysctl_enable_soft_offline __read_mostly = 1; > + > atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0); > > static bool hw_memory_failure __read_mostly = false; > @@ -141,6 +143,15 @@ static struct ctl_table memory_failure_table[] = { > .extra1 = SYSCTL_ZERO, > .extra2 = SYSCTL_ONE, > }, > + { > + .procname = "enable_soft_offline", > + .data = &sysctl_enable_soft_offline, > + .maxlen = sizeof(sysctl_enable_soft_offline), > + .mode = 0644, > + .proc_handler = proc_dointvec_minmax, > + .extra1 = SYSCTL_ZERO, > + .extra2 = SYSCTL_ONE, > + } > }; > > /* > @@ -2771,6 +2782,11 @@ int soft_offline_page(unsigned long pfn, int flags) > bool try_again = true; > struct page *page; > > + if (!sysctl_enable_soft_offline) { > + pr_info("soft offline: %#lx: OS-wide disabled\n", pfn); > + return -EINVAL; > + } > + IMHO, callers might reach here with page refcnt increased. So we have to take care of releasing it first? Also will it be better to return -EOPNOTSUPP or some other better errno? Thanks. .