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 D16FFC27C79 for ; Mon, 17 Jun 2024 19:13:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18BD08D0003; Mon, 17 Jun 2024 15:13:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 16D528D0002; Mon, 17 Jun 2024 15:13:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 051D78D0003; Mon, 17 Jun 2024 15:13:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id DB6F28D0002 for ; Mon, 17 Jun 2024 15:13:57 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 47869A1A92 for ; Mon, 17 Jun 2024 19:13:57 +0000 (UTC) X-FDA: 82241330514.09.5CFF51B Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf18.hostedemail.com (Postfix) with ESMTP id ACFF11C000B for ; Mon, 17 Jun 2024 19:13:53 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=sPaoe0iC; dmarc=none; spf=pass (imf18.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718651629; a=rsa-sha256; cv=none; b=F7uOJzev0XcUe+irLJ/ug6OZtMFK17nRKjBL4TRd5h6VTZSw7V9vUkM2wCQfuKkOvwtd+2 tCI9EUUO5xu+vB6hLEDpaTt5vi6FVDbdNQ0x1iiJ8+GheWX3qCTGr3vNVowDyZndHVh0tk O3rDPQ3+MyaPtArcxENBD7mfRo7a4LQ= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=sPaoe0iC; dmarc=none; spf=pass (imf18.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718651629; 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:dkim-signature; bh=FnnPhtwBIxW8ZIt+9TQIh4TfSfvZA1Edyvy5hGiGatk=; b=PJ/klFF8ZzJBZ8Pn8JzrNKfOJszLvAbQzJPpPs8LhZHGSsj0FN3TtxpvsD1/qVRsmk6bC5 3GrEpJRzEM6DkKAx+c7RX4PdTfhFtQVT/xPlXXX+/OEc2g9ahLlcsGIEDFO8Re0FiZJLSQ +SKOH1vgLGPpd1K2f8wXEJv36FIElIM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id AB046CE1287; Mon, 17 Jun 2024 19:13:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70D91C2BD10; Mon, 17 Jun 2024 19:13:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1718651629; bh=pbHUlH2855XEpgnVeBq3l1Gg1yHC8Uzv+j4aS6wtmU8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=sPaoe0iCBL6l1jMwgoXW+7ht0mqJDc8JbDNIYNbFYatzNU0799AiQvF1Vpf+6XMMM uZ1aShqucnLu5uwuDau6b/+jvxUubZTI2KIERBxaG3E9KBMjbptcgqsWY2x+b877H9 IMvYpDE1CNiHdz6ujhieDf8Sn6zbhQt8m+yRQdXI= Date: Mon, 17 Jun 2024 12:13:48 -0700 From: Andrew Morton To: Jiaqi Yan Cc: nao.horiguchi@gmail.com, linmiaohe@huawei.com, jane.chu@oracle.com, ioworker0@gmail.com, muchun.song@linux.dev, shuah@kernel.org, corbet@lwn.net, osalvador@suse.de, rientjes@google.com, duenwen@google.com, fvdl@google.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH v3 1/3] mm/memory-failure: userspace controls soft-offlining pages Message-Id: <20240617121348.4ee672a1d6bc9202b3ad0e08@linux-foundation.org> In-Reply-To: <20240617170545.3820912-2-jiaqiyan@google.com> References: <20240617170545.3820912-1-jiaqiyan@google.com> <20240617170545.3820912-2-jiaqiyan@google.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: ACFF11C000B X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 4mwf9xd3xro13onyux3xemhyaxu1tcxd X-HE-Tag: 1718651633-362808 X-HE-Meta: U2FsdGVkX1+n/Go1NUi8WH2v5R2xjQNtdaczjmr7ligycUvjYBMXruOeO6YauUsRoPCqZ6OhOctbKZu/pegN/BCwB7SEio1+MAZqJrHylbdKnSRopXx/mvz22kwwI0r+lksEndQcEwpxCTqFy0rm79a72tcHazsSKQPNCS+5W1ho/dxkgIMP+Eb88+0/9CQnyQnPc8mn+53I0BGmgWsTe6twNAom6tLnI7JFpFJrR+yY+WMGHG17RyrIMluinut9izTMp3xU5g8Bhgvqo3TxapjHTpadbanqsb6Urpv7Stopl7TkHk0oCLNcfPfMIZYCVWhG7YgycVjTSkmsj6tVVFRHDqBQTLsj6PDqE13KtHGpsAMEP1fhDUjpWkHqdqXmkNnUZesoz9REd70nrp6dYvsAMLvHTttilGYWo1eyqyySUumQ6femAOwjgASHnBwphno3KxhFE1JxkqE+poKduqSQDufNN9GqvCR+QLgMkjwmgO3cmYZ1YobhZPv0Z8RbRtM9VpD8zEEGw8z79NFRpT5bPlfzG9YAILKsHshRVp0/rjyJZqOQ83bz8VA2XEAls5z3x0buN0yrEIzbHCk+H0jAG3lICv6YH/xlXZvtgGJCne5Rq3cVmwG+oElwBIqgX95ACBjFErOlWcFW+Phwp2ms90AP/w6vp0oHWfA/5Q8kru2T63NIoGtScBqkQn4iAJmJUYJn61rlpi8PPFEPoah2HuN6+tRE1TUOnq0/pbBE+6ZNsAG4vPxHolKJKqYpmrMVBPET9iRU9eL+vMP3YMXgxYzHh7L5NKs/nWBkTsj0khcY0D7fuVMJqj6ZKVWwqBXu3XIvMlTknqsGj6O09OHhZQYMz0OxN6traxzR5yxOlPeUFQ+7+s752aWE60TdfKSGuEKz8ByLQC1NqYKTMO2p/UXBE5ipqvjhznft2c20f+A21GQJwsl43LA1UB/LWXKsgStbxv0bfKpeRyM E2QgqGja hP9zbEvcVrC0+BqNuWplXBllzM1lKSg+U+PjotX7yeUfpf0LoV+l/DgXnCN5/QvOQ/i61HuUE9fE+jwtGXZCqugYXcCNbrPPs59h+i8dorT27E5bKng6TKY/s4MoVoJPUyYNon8nXTrIdNynMfwoRvztd5ggx1XZv9F6cvKO45UgyFGV54aR/1gCFom9DMpJhHpjTSgXlMzbv4ulJNhcZ2xEzfAZ0xSRUsAUbwsQFeO5wlblkDZ8dyP93kD5+/IXReCRoNUt5mFcQf0IHFJ3tzgFpiZiTDBtw588qFFt6Zws0xmHxsimxnXLT/dg5SOWOhjeA 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 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. 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? > @@ -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.. > + put_ref_page(pfn, flags); > + return -EOPNOTSUPP; > + } > + > mutex_lock(&mf_mutex); >