From patchwork Mon Jun 24 16:33:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaqi Yan X-Patchwork-Id: 807416 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13A5A19DFBA for ; Mon, 24 Jun 2024 16:33:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719246835; cv=none; b=d3lV/d9hpf5EqHt7i3EbELczei/j1DEvJSyVHNb4ZsUeDpfahUyIczuvBLlhoSvxmeAg0VR2EylcW28j98MxK9vN0Mj/zNOpFSeeuCFZhXNdy51eTandyZvd5JwoO2dYrcvBiDcazNzxeibmKlMTg3QtueJFEGqmp/nxuM6mKHk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719246835; c=relaxed/simple; bh=ZJlt/X6PrwPET2Sqp74JHEjJORFV5iRxJOPxh1IkXWU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=udsnMBWq4ZJQ9r4Csx2zv0I+wp3TNmg9aSXI9s6F7kfN2rcViXBpAX4xDU7ZiIJ4MnP0Sp5O6s6bsk/lFt2DuM84kipYzKxnjyx7yu7mYarFSHw0JwpRbvkFZfFpYkAMEFNoIEBr3uufetxUKgsW0qeNDzSwVeNFLLGvDmXwyRE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jiaqiyan.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=XX6TdaPC; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jiaqiyan.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XX6TdaPC" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-717fdb2bf03so1823870a12.1 for ; Mon, 24 Jun 2024 09:33:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719246833; x=1719851633; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=1wu1wVc+3ogmDWb1QmIkKTSRvM9RrOiJDS3aYm0qmOo=; b=XX6TdaPCwOyqrWjzoOsRHf4heBe84hZepeYxn7tLBu5jpxD1EUJlbrJYNB/zYXkjDP b5XXxwfq8dDMf1WB1ZM612fl4K7W2VHZeDoU+2wcygkz2nQOSjo+rXauEjpE7tZtHxUx 1rXuSVp2LappGipBSmrPWL2JT19B0VBViQnxvgA+Qx7Dd67zKbzusOdJ8RrqZ4Vzle2H Clm3xk+9jfml3tMq78Rw3ZnYBATGvXjVuNSrEjEGMnjS7Ke1f0uHiR59cfgYT+bTFCvF C2pUidZzHKWRyUDLOwUFeLS2s1VpN8vcoEwLQ08R1F21rnveCit7wrClIT+Njk1Gl3C5 oHXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719246833; x=1719851633; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1wu1wVc+3ogmDWb1QmIkKTSRvM9RrOiJDS3aYm0qmOo=; b=UkRMC4p/Ohjki/Rl5EvZHu8+uTfEr2fQ7kYgz68kt+iue9SoTLsHG0Q6lThfKAVURb TcxrVKEz1dCyoBr119bTVcuwGNXz7+a3RrT3PLW720kadNAbL1D5puCVSpLMLN+p9cuj KUrC9lR/X0PCRNcCFLy15vrEMQ6pCBxXKRPyspdDTV1hWaT0UD1wi8sjeqQmjg5BfMXg GLkbv4uqYD3VB9AzDMr3OMe4Y2GRVEf4wUzQXNF/Dm/+WVx2MKFbM2xJth/2OiZeeJya 3yrF6reaOVMEag3l9oDWxGRpX10uoyBbeL9bhSfma7deWNCkVm1QANstZw8NFsIvE2VI k/fg== X-Forwarded-Encrypted: i=1; AJvYcCUjg4QXmPp6a7luc3z7P8fUqNikvx8hVcxK+IPlTlG0W0XcKYVGo9uBqb/wZoC3v+/2wgJq3QksEJkNBds1Q+8PMzPGFXhafvmBtoSQClHF X-Gm-Message-State: AOJu0Yy4Z6iCNV9qDrmAmrUtcEQYukAO04bD5ImoieSVhN9wG7ZS43Nl m5yzNPL+B01Qkp8+o/pHmflHRIDqlyw/QgyPIfCf0TLhkYBAFJzEytVc7dzkCJykXLFGu1kQmSa ByYTRq7UTcg== X-Google-Smtp-Source: AGHT+IF1GRQbf9f53JYi+zCzPqxL0zi378t5Qx/Cho038U/27Y5JAiHIF9pEqP5D5pV+1pUBlBOa/tOCbhRcIQ== X-Received: from yjq3.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:272f]) (user=jiaqiyan job=sendgmr) by 2002:a17:90b:3c4:b0:2c7:471d:172b with SMTP id 98e67ed59e1d1-2c848a4d8c7mr123984a91.2.1719246833134; Mon, 24 Jun 2024 09:33:53 -0700 (PDT) Date: Mon, 24 Jun 2024 16:33:45 +0000 In-Reply-To: <20240624163348.1751454-1-jiaqiyan@google.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240624163348.1751454-1-jiaqiyan@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Message-ID: <20240624163348.1751454-2-jiaqiyan@google.com> Subject: [PATCH v5 1/4] mm/memory-failure: refactor log format in soft offline code From: Jiaqi Yan To: nao.horiguchi@gmail.com, linmiaohe@huawei.com, jane.chu@oracle.com, ioworker0@gmail.com Cc: muchun.song@linux.dev, akpm@linux-foundation.org, 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, Jiaqi Yan Logs from soft_offline_page and soft_offline_in_use_page have different formats than majority of the memory failure code: "Memory failure: 0x${pfn}: ${lower_case_message}" Convert them to the following format: "Soft offline: 0x${pfn}: ${lower_case_message}" No functional change in this commit. Signed-off-by: Jiaqi Yan --- mm/memory-failure.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index d3c830e817e3..2a097af7da0e 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2631,6 +2631,9 @@ int unpoison_memory(unsigned long pfn) } EXPORT_SYMBOL(unpoison_memory); +#undef pr_fmt +#define pr_fmt(fmt) "Soft offline: " fmt + static bool mf_isolate_folio(struct folio *folio, struct list_head *pagelist) { bool isolated = false; @@ -2686,7 +2689,7 @@ static int soft_offline_in_use_page(struct page *page) if (!huge && folio_test_large(folio)) { if (try_to_split_thp_page(page)) { - pr_info("soft offline: %#lx: thp split failed\n", pfn); + pr_info("%#lx: thp split failed\n", pfn); return -EBUSY; } folio = page_folio(page); @@ -2698,7 +2701,7 @@ static int soft_offline_in_use_page(struct page *page) if (PageHWPoison(page)) { folio_unlock(folio); folio_put(folio); - pr_info("soft offline: %#lx page already poisoned\n", pfn); + pr_info("%#lx page already poisoned\n", pfn); return 0; } @@ -2711,7 +2714,7 @@ static int soft_offline_in_use_page(struct page *page) folio_unlock(folio); if (ret) { - pr_info("soft_offline: %#lx: invalidated\n", pfn); + pr_info("%#lx: invalidated\n", pfn); page_handle_poison(page, false, true); return 0; } @@ -2728,13 +2731,13 @@ static int soft_offline_in_use_page(struct page *page) if (!list_empty(&pagelist)) putback_movable_pages(&pagelist); - pr_info("soft offline: %#lx: %s migration failed %ld, type %pGp\n", + pr_info("%#lx: %s migration failed %ld, type %pGp\n", pfn, msg_page[huge], ret, &page->flags); if (ret > 0) ret = -EBUSY; } } else { - pr_info("soft offline: %#lx: %s isolation failed, page count %d, type %pGp\n", + pr_info("%#lx: %s isolation failed, page count %d, type %pGp\n", pfn, msg_page[huge], page_count(page), &page->flags); ret = -EBUSY; } @@ -2786,7 +2789,7 @@ int soft_offline_page(unsigned long pfn, int flags) mutex_lock(&mf_mutex); if (PageHWPoison(page)) { - pr_info("%s: %#lx page already poisoned\n", __func__, pfn); + pr_info("%#lx: page already poisoned\n", pfn); put_ref_page(pfn, flags); mutex_unlock(&mf_mutex); return 0; From patchwork Mon Jun 24 16:33:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaqi Yan X-Patchwork-Id: 807118 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E40919E7DA for ; Mon, 24 Jun 2024 16:33:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719246837; cv=none; b=YfzIlf+p4nbFdoWD1cCtLrpQQ0Wq36nvP2uFZ0K5+hFmPlr7EWDYWUfaqzwFAhn1HcJnmQLGSfpi/wkk12pZusdCKZnR3S2ScWbib+wtR2GZNsdg5mi1SBZE5r5kvVumCpxFHpIapjRxKC3WksjVvFSr8CY6ILs4IYLHDQj+0js= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719246837; c=relaxed/simple; bh=pVkOtKaCptTfJGM+OgexYNabmuyK43G7cNJ4MT8MK1U=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=joEPaUuLJYFSCmOsSLL1Fzmrp2IUKGAgi9auQjOYtoNpYRnlkOJY25l7wiVn6SL/AEcEUZbJ7frMV8wsBL9zT2h72baxI8UDAis3w40n4/dL47SVZfu8q6nwdlkqiySCdrVAPwFKv0Il6kjfNYaKVNl8mXuMcq6iPsJKjvlZ/mA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jiaqiyan.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=rnEOeL+N; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jiaqiyan.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="rnEOeL+N" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-6e3341c8865so5757926a12.1 for ; Mon, 24 Jun 2024 09:33:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719246835; x=1719851635; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=jaVeSRVMUEHHsCQ2CT1Mt2nWqEzTQXYnHsGL8HUoHVg=; b=rnEOeL+NaGfJPERg7JBRUd6xfOFjnt8caQSnXx635LA8DZwVQ+KIhf6hQ3JWU+a9Hn d+C09b2rnhKnBPCbeS2W5UYcPUPV2Z8o509zgzqUFrCCrd8k4TVSK2aOvxT8VzU8/e5w oiO6PaeEmWY8p8ZCsIyJR2AZTqMXnPIKmRidG1Nmnq2+dYlloMUuEFkcGgu6EkkGkkbO EUSpY4//9CmiMOiWooVhd8OvFga3qB6K14rfmcvZVWaPQDh6rp8qQMjvkGaQce18NonF /yddu8mNGyOyxGd++bhQqGTKfoxAvSO5y0w161gw+KIGhyhD+kPoN8OI+XIiU5yp6qAb lNxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719246835; x=1719851635; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jaVeSRVMUEHHsCQ2CT1Mt2nWqEzTQXYnHsGL8HUoHVg=; b=cMRVUgq+HNjwZ5M0HoQdrk0UUeA4C2OOIrV5lIGrFGC2jFXr2zOfhifllF3n2MUIY3 +4Ky3j3f6KKhdnnvUeqmLzbxciDUMbcJDqfIEhV8bSbHSPhFQ0g449n/DlBMOjB/9Itn TtxWmDM893yTg31GuDkqTMwZ5EKOZB6I+95yfyiQVP9JnrSizWnsL7YRwqfkeBNOs9No 1RgVJkBQdlevYw27OHLq1QTFPW1B3ukSn8b3XwlpYKnNsZcivWRD3QyZmsEza1JhGoKi 8aoW7gciWx/VxSkSSe9OtEFPE4rT+YHZMQhzrIibbZ2hCImrGZqqxdsr0hVaP+ElgNyJ 7d9Q== X-Forwarded-Encrypted: i=1; AJvYcCWohZvT5EOp+isLuhUZphm05x6PePHbET5p88hWlhqzBQF9byZRfL8Dg9SqtrIDTD34HW6n/Tk6fbtRoJclClLmS7G44M/eZtsGt1sxjSHV X-Gm-Message-State: AOJu0Yx0Hgpt9CWTRS6c1Cl9cBG/vMEWZ2dwTaA88JBzrxTLsTISLIXe 9sVrf8+rrGU9wNQNHYXo/7/JfI6bHT6Sew+Gp8l6pKjAFpaZH57voVG+Bl0oQURh2wiYhcFmrTD er+W/q4C6bw== X-Google-Smtp-Source: AGHT+IFmjiZXsOh4qVWVE4+iXLz6GybpRfvQXdLXA2xaKMrN+J7XAcxYTT8GInfxKIa7RXbtOwVhCfQSnU4XDg== X-Received: from yjq3.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:272f]) (user=jiaqiyan job=sendgmr) by 2002:a63:2354:0:b0:719:ae7d:9f2e with SMTP id 41be03b00d2f7-71a35641f60mr18300a12.2.1719246834803; Mon, 24 Jun 2024 09:33:54 -0700 (PDT) Date: Mon, 24 Jun 2024 16:33:46 +0000 In-Reply-To: <20240624163348.1751454-1-jiaqiyan@google.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240624163348.1751454-1-jiaqiyan@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Message-ID: <20240624163348.1751454-3-jiaqiyan@google.com> Subject: [PATCH v5 2/4] mm/memory-failure: userspace controls soft-offlining pages From: Jiaqi Yan To: nao.horiguchi@gmail.com, linmiaohe@huawei.com, jane.chu@oracle.com, ioworker0@gmail.com Cc: muchun.song@linux.dev, akpm@linux-foundation.org, 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, Jiaqi Yan 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. 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. when 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. Acked-by: Miaohe Lin Signed-off-by: Jiaqi Yan --- mm/memory-failure.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 2a097af7da0e..0013d338569b 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, + } }; /* @@ -2749,8 +2760,9 @@ static int soft_offline_in_use_page(struct page *page) * @pfn: pfn to soft-offline * @flags: flags. Same as memory_failure(). * - * Returns 0 on success - * -EOPNOTSUPP for hwpoison_filter() filtered the error event + * Returns 0 on success, + * -EOPNOTSUPP for hwpoison_filter() filtered the error event, or + * disabled by /proc/sys/vm/enable_soft_offline, * < 0 otherwise negated errno. * * Soft offline a page, by migration or invalidation, @@ -2786,6 +2798,13 @@ int soft_offline_page(unsigned long pfn, int flags) return -EIO; } + if (!sysctl_enable_soft_offline) { + pr_info_once("%#lx: disabled by /proc/sys/vm/enable_soft_offline\n", + pfn); + put_ref_page(pfn, flags); + return -EOPNOTSUPP; + } + mutex_lock(&mf_mutex); if (PageHWPoison(page)) { From patchwork Mon Jun 24 16:33:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaqi Yan X-Patchwork-Id: 807415 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36CE819E7EF for ; Mon, 24 Jun 2024 16:33:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719246840; cv=none; b=grIgVUZaFiVkzYsSSeieSgjjg/fcsWOtwuRNP1K8AiDM+rsMvHDthHrCyl4XcbitBbBwmwN5NH521OJJqKSNV+ptIHMw2KuV4Bihe2Hm1hspa5rwNS4a5iwJUb40QchxrUuD5yQsXDm3omKmQhn/R3piD2K9HUTqlJ05FK4fLoc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719246840; c=relaxed/simple; bh=DzacV7XHdNTLe+/xawDIh2gaRxPEQEKOapkpb885jyg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ufGIk/mk1Xk/IHtNCV1ABSeOqfcMdNd84HGor/V/TkjOOxL4cZesfO86ah9tAbDmF9AhJDKh+4sjK82/RZNV7nqsiZuyTDZmhQhFvKJZSjByje5N63oe9ilrjEeJMg5XKT5i6cT1FiFCrvVzdN+wkmldoIQwurgaxob+1aSCazo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jiaqiyan.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=RyQuo5h3; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jiaqiyan.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RyQuo5h3" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2c7c3069edcso5276115a91.3 for ; Mon, 24 Jun 2024 09:33:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719246836; x=1719851636; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=9vvhaZptFj6JTB0CcmvYAGAWn7bt9g4Ak/WxvFYJHHA=; b=RyQuo5h3gDhhuHf6lnoyNzmD03MGQPcn++tIZ7IQ5oMLIAXDju83xdiRuEjMNlwQhT be7BV8i+gTY1yJSWK2IRf6M/ZNR6ASe9463Cg2LSCm/1d5yGTyOIM8Oe1il7ZlIfnTqA QpwonJ1rWoGYXN7DGcuYyP4BZDIuVWqQ0VylgdybSC9vMbe0iSFLktE4g+BYCfzxf3tY hNA5e5P1J0Z+iVv33Aeg1m5lBhtvgJ0q5QdxsKwzezaV8wqIsDsVhTAvSpSY1jobPp90 WeQo51ExA54GWngebysc2nPe5nU9vHi8hlq205GMuCU53MdV1mDOUOaIvMIv/6vR9h/U c+CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719246836; x=1719851636; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9vvhaZptFj6JTB0CcmvYAGAWn7bt9g4Ak/WxvFYJHHA=; b=YlI+msHgYAtgFbaTG2QCCpUgfBNgfTp/OchrVJOllrSpqbL4KipT+kYjwL+hnSTVU9 hPkUREczTt9Z83G8qpJLUnW4wPqyvj8JRJ5eVQ6W71ohNW4rVzLh09Oxdalq/KTAMsRF a6e4zE8odvC5fB9+mKi9Ds57qBW7DAx08vQNcgDdbcf1Hqr/mVFAQ4jUUXHOc15msWJf 9JSGmCUuJHsXn4biit412OxIoObRcUZ0MDBBSMmi5UcpegrhMgM8ZY5jCv/68tpQXCb2 s5jYjNav0TFqtTa+1gOEAT6Zcjm9VHCPm7wDHUMhCHeeU4m62vtO66V5I0O99oaGHFnD k0LA== X-Forwarded-Encrypted: i=1; AJvYcCW4G/9FG4Oto0QyOu4lc9aODQJXMuHtajvKoGqV3MJBZvriFwGe64CE3qWwRAaPIcVHQD0FFD2BMPD9qI3LvZxt0d3mYi0/dnFl1r0gcmPP X-Gm-Message-State: AOJu0Yx8K8oXhRt7NisZ/iCnmLZidqXXjc2deYL5Gb56C3xSnOKD7Xx1 kkc/1aJmiEyU0nVzqqNZp1WHAOEnaK2+UMijy/gM0TzUwbuu9K1++I1HwYaHrwLZYZU8UyzbOW+ ps+FwrR+YIg== X-Google-Smtp-Source: AGHT+IGTiMcKI84dbFE5H2z0l2Fcmhs9y/kM+GPkY+GUg1Z/omR04Q3dPmkB+omY4azsFqSvT0rRbpXc5WHBqA== X-Received: from yjq3.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:272f]) (user=jiaqiyan job=sendgmr) by 2002:a17:90b:4d85:b0:2c2:fed7:d797 with SMTP id 98e67ed59e1d1-2c8507b2998mr45685a91.6.1719246836231; Mon, 24 Jun 2024 09:33:56 -0700 (PDT) Date: Mon, 24 Jun 2024 16:33:47 +0000 In-Reply-To: <20240624163348.1751454-1-jiaqiyan@google.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240624163348.1751454-1-jiaqiyan@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Message-ID: <20240624163348.1751454-4-jiaqiyan@google.com> Subject: [PATCH v5 3/4] selftest/mm: test enable_soft_offline behaviors From: Jiaqi Yan To: nao.horiguchi@gmail.com, linmiaohe@huawei.com, jane.chu@oracle.com, ioworker0@gmail.com Cc: muchun.song@linux.dev, akpm@linux-foundation.org, 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, Jiaqi Yan Add regression and new tests when hugepage has correctable memory errors, and how userspace wants to deal with it: * if enable_soft_offline=1, mapped hugepage is soft offlined * if enable_soft_offline=0, mapped hugepage is intact Free hugepages case is not explicitly covered by the tests. Hugepage having corrected memory errors is emulated with MADV_SOFT_OFFLINE. Signed-off-by: Jiaqi Yan --- tools/testing/selftests/mm/.gitignore | 1 + tools/testing/selftests/mm/Makefile | 1 + .../selftests/mm/hugetlb-soft-offline.c | 227 ++++++++++++++++++ tools/testing/selftests/mm/run_vmtests.sh | 4 + 4 files changed, 233 insertions(+) create mode 100644 tools/testing/selftests/mm/hugetlb-soft-offline.c diff --git a/tools/testing/selftests/mm/.gitignore b/tools/testing/selftests/mm/.gitignore index 0b9ab987601c..064e7b125643 100644 --- a/tools/testing/selftests/mm/.gitignore +++ b/tools/testing/selftests/mm/.gitignore @@ -6,6 +6,7 @@ hugepage-shm hugepage-vmemmap hugetlb-madvise hugetlb-read-hwpoison +hugetlb-soft-offline khugepaged map_hugetlb map_populate diff --git a/tools/testing/selftests/mm/Makefile b/tools/testing/selftests/mm/Makefile index 3b49bc3d0a3b..d166067d75ef 100644 --- a/tools/testing/selftests/mm/Makefile +++ b/tools/testing/selftests/mm/Makefile @@ -42,6 +42,7 @@ TEST_GEN_FILES += gup_test TEST_GEN_FILES += hmm-tests TEST_GEN_FILES += hugetlb-madvise TEST_GEN_FILES += hugetlb-read-hwpoison +TEST_GEN_FILES += hugetlb-soft-offline TEST_GEN_FILES += hugepage-mmap TEST_GEN_FILES += hugepage-mremap TEST_GEN_FILES += hugepage-shm diff --git a/tools/testing/selftests/mm/hugetlb-soft-offline.c b/tools/testing/selftests/mm/hugetlb-soft-offline.c new file mode 100644 index 000000000000..16fe52f972e2 --- /dev/null +++ b/tools/testing/selftests/mm/hugetlb-soft-offline.c @@ -0,0 +1,227 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Test soft offline behavior for HugeTLB pages: + * - if enable_soft_offline = 0, hugepages should stay intact and soft + * offlining failed with EINVAL. + * - if enable_soft_offline = 1, a hugepage should be dissolved and + * nr_hugepages/free_hugepages should be reduced by 1. + * + * Before running, make sure more than 2 hugepages of default_hugepagesz + * are allocated. For example, if /proc/meminfo/Hugepagesize is 2048kB: + * echo 8 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages + */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "../kselftest.h" + +#ifndef MADV_SOFT_OFFLINE +#define MADV_SOFT_OFFLINE 101 +#endif + +#define EPREFIX " !!! " + +static int do_soft_offline(int fd, size_t len, int expect_errno) +{ + char *filemap = NULL; + char *hwp_addr = NULL; + const unsigned long pagesize = getpagesize(); + int ret = 0; + + if (ftruncate(fd, len) < 0) { + ksft_perror(EPREFIX "ftruncate to len failed"); + return -1; + } + + filemap = mmap(NULL, len, PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_POPULATE, fd, 0); + if (filemap == MAP_FAILED) { + ksft_perror(EPREFIX "mmap failed"); + ret = -1; + goto untruncate; + } + + memset(filemap, 0xab, len); + ksft_print_msg("Allocated %#lx bytes of hugetlb pages\n", len); + + hwp_addr = filemap + len / 2; + ret = madvise(hwp_addr, pagesize, MADV_SOFT_OFFLINE); + ksft_print_msg("MADV_SOFT_OFFLINE %p ret=%d, errno=%d\n", + hwp_addr, ret, errno); + if (ret != 0) + ksft_perror(EPREFIX "madvise failed"); + + if (errno == expect_errno) + ret = 0; + else { + ksft_print_msg("MADV_SOFT_OFFLINE should ret %d\n", + expect_errno); + ret = -1; + } + + munmap(filemap, len); +untruncate: + if (ftruncate(fd, 0) < 0) + ksft_perror(EPREFIX "ftruncate back to 0 failed"); + + return ret; +} + +static int set_enable_soft_offline(int value) +{ + char cmd[256] = {0}; + FILE *cmdfile = NULL; + + if (value != 0 && value != 1) + return -EINVAL; + + sprintf(cmd, "echo %d > /proc/sys/vm/enable_soft_offline", value); + cmdfile = popen(cmd, "r"); + + if (cmdfile) + ksft_print_msg("enable_soft_offline => %d\n", value); + else { + ksft_perror(EPREFIX "failed to set enable_soft_offline"); + return errno; + } + + pclose(cmdfile); + return 0; +} + +static int read_nr_hugepages(unsigned long hugepage_size, + unsigned long *nr_hugepages) +{ + char buffer[256] = {0}; + char cmd[256] = {0}; + + sprintf(cmd, "cat /sys/kernel/mm/hugepages/hugepages-%ldkB/nr_hugepages", + hugepage_size); + FILE *cmdfile = popen(cmd, "r"); + + if (cmdfile == NULL) { + ksft_perror(EPREFIX "failed to popen nr_hugepages"); + return -1; + } + + if (!fgets(buffer, sizeof(buffer), cmdfile)) { + ksft_perror(EPREFIX "failed to read nr_hugepages"); + pclose(cmdfile); + return -1; + } + + *nr_hugepages = atoll(buffer); + pclose(cmdfile); + return 0; +} + +static int create_hugetlbfs_file(struct statfs *file_stat) +{ + int fd; + + fd = memfd_create("hugetlb_tmp", MFD_HUGETLB); + if (fd < 0) { + ksft_perror(EPREFIX "could not open hugetlbfs file"); + return -1; + } + + memset(file_stat, 0, sizeof(*file_stat)); + if (fstatfs(fd, file_stat)) { + ksft_perror(EPREFIX "fstatfs failed"); + goto close; + } + if (file_stat->f_type != HUGETLBFS_MAGIC) { + ksft_print_msg(EPREFIX "not hugetlbfs file\n"); + goto close; + } + + return fd; +close: + close(fd); + return -1; +} + +static void test_soft_offline_common(int enable_soft_offline) +{ + int fd; + int expect_errno = enable_soft_offline ? 0 : EOPNOTSUPP; + struct statfs file_stat; + unsigned long hugepagesize_kb = 0; + unsigned long nr_hugepages_before = 0; + unsigned long nr_hugepages_after = 0; + int ret; + + ksft_print_msg("Test soft-offline when enabled_soft_offline=%d\n", + enable_soft_offline); + + fd = create_hugetlbfs_file(&file_stat); + if (fd < 0) { + ksft_exit_fail_msg("Failed to create hugetlbfs file\n"); + return; + } + + hugepagesize_kb = file_stat.f_bsize / 1024; + ksft_print_msg("Hugepagesize is %ldkB\n", hugepagesize_kb); + + if (set_enable_soft_offline(enable_soft_offline)) { + ksft_exit_fail_msg("Failed to set enable_soft_offline\n"); + return; + } + + if (read_nr_hugepages(hugepagesize_kb, &nr_hugepages_before) != 0) { + ksft_exit_fail_msg("Failed to read nr_hugepages\n"); + return; + } + + ksft_print_msg("Before MADV_SOFT_OFFLINE nr_hugepages=%ld\n", + nr_hugepages_before); + + ret = do_soft_offline(fd, 2 * file_stat.f_bsize, expect_errno); + + if (read_nr_hugepages(hugepagesize_kb, &nr_hugepages_after) != 0) { + ksft_exit_fail_msg("Failed to read nr_hugepages\n"); + return; + } + + ksft_print_msg("After MADV_SOFT_OFFLINE nr_hugepages=%ld\n", + nr_hugepages_after); + + if (enable_soft_offline) { + if (nr_hugepages_before != nr_hugepages_after + 1) { + ksft_test_result_fail("MADV_SOFT_OFFLINE should reduced 1 hugepage\n"); + return; + } + } else { + if (nr_hugepages_before != nr_hugepages_after) { + ksft_test_result_fail("MADV_SOFT_OFFLINE reduced %lu hugepages\n", + nr_hugepages_before - nr_hugepages_after); + return; + } + } + + ksft_test_result(ret == 0, + "Test soft-offline when enabled_soft_offline=%d\n", + enable_soft_offline); +} + +int main(int argc, char **argv) +{ + ksft_print_header(); + ksft_set_plan(2); + + test_soft_offline_common(1); + test_soft_offline_common(0); + + ksft_finished(); +} diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh index 3157204b9047..781117fac1ba 100755 --- a/tools/testing/selftests/mm/run_vmtests.sh +++ b/tools/testing/selftests/mm/run_vmtests.sh @@ -331,6 +331,10 @@ CATEGORY="hugetlb" run_test ./thuge-gen CATEGORY="hugetlb" run_test ./charge_reserved_hugetlb.sh -cgroup-v2 CATEGORY="hugetlb" run_test ./hugetlb_reparenting_test.sh -cgroup-v2 if $RUN_DESTRUCTIVE; then +nr_hugepages_tmp=$(cat /proc/sys/vm/nr_hugepages) +echo 8 > /proc/sys/vm/nr_hugepages +CATEGORY="hugetlb" run_test ./hugetlb-soft-offline +echo "$nr_hugepages_tmp" > /proc/sys/vm/nr_hugepages CATEGORY="hugetlb" run_test ./hugetlb-read-hwpoison fi From patchwork Mon Jun 24 16:33:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaqi Yan X-Patchwork-Id: 807117 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25DF319E7F5 for ; Mon, 24 Jun 2024 16:33:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719246840; cv=none; b=Wp0Ms59A52/zmzYcARhRQcjyyZJQ5w3ZlpmWKvkbfiNC591mZlmN+k88Lpgiq/f0wIF6pXrHQi7M/EeuG3DAP9dsIcVKl5ujIbAKg7+Iz8buMualIaiXhNQaSz+XvmZf1MO+5tAXpq3vFcNEQGJyROuUG0PuU/EUoRO4uQJEdv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719246840; c=relaxed/simple; bh=7Wo1vdpRujfwVa5E2lZDEmMHiqeYmjrjdL5DzTInIks=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Xy2B5ZKUYO55hMd4H6QczkI5hk5EMT/lFce/5xeiJickNeyXOF8iJXvcewRdCoGmonwH4gt/WE2zvEgFA5xlAA3bcpPsQoKNLCx9txOywnqBfFQyw/V4eDSXDXEtUidAjxKVa0jDKrsAMJjiHqSYdOfVm8dKkL+Lz1iHbANe+FY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jiaqiyan.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=zNAKiJWR; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jiaqiyan.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="zNAKiJWR" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-1f98f733043so47172125ad.2 for ; Mon, 24 Jun 2024 09:33:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1719246838; x=1719851638; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=GVvAVLVgyp7BPn3YqnrE+Un4CdtD1Zv3a2093D82WyY=; b=zNAKiJWRrdiyMLcRtS9CEAPvNDVlwcMAU4MbzbBKU9uiSTu+/hgU1K4WcLc+7VEtXG E9s+XDKLBrFmHqG14TD9iVDtkOxr1kZ8KnbNWeDxXhL9wcL8YH9lTi8TJ6GTWtRonNkJ 8GPMnhdGp0WoTSLbdTGPQpiAqNDanbJn9dajd8JF4g/h+UvEXaYyFza/QWaWWdfuOtUS 76guww4d5ehYg3CSJgBSb4S/zEvb5eksfwAODnml17yZB2l/DHhc4axqxm9eVA7oqlhY Ejl5XdXhWnzqYFCjgCmnA9gZWU6OBvoD2xLChuE23L9jtXxo6KwwxY0kHq08TOkId0lF xkiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719246838; x=1719851638; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GVvAVLVgyp7BPn3YqnrE+Un4CdtD1Zv3a2093D82WyY=; b=C1jIbaAc4vfk9rQ7bAv73bEHMgikvOZmjzTJAGXuqOi8pe7PK6xPsudu575USxpkBr 7hwhhUQwouZahizRLNn2zIaEdeR7YGrh30b1hJRX+iHD9/pBrbBSOnUgvcTEreKRN3sl QIcbowo63ub08zmhuV9AOxN6cU+i4p8bz/ZOOxhtjGkIa0aN+ozNGC1DbuZT2NzLvYd9 s8KzLKXvpM3DjfDy1M+XtXDeDHf4aOEHhxVu3kucRDIAF7DoUuMD5+/SACzcR9XSbg0p nfGGvZICqF0nHrElDW5756fUPIlePC4XDZ8Gf8CPYanT38r1iGeuxqTyUGDnUq/ptNnk ZKuA== X-Forwarded-Encrypted: i=1; AJvYcCUgJq8wgf4L8mlb04HhL4kxNlxMl4W9JiN4cOkUhmd7/uf3BwzOGOpoidR17f42YyElaYYypu9WVCuCRfkbeMrmjYZXbTaZCiYAnuM301bQ X-Gm-Message-State: AOJu0YzAKfDd3ybm9Mi32DXtO1wCFM8ifyj1MJ7VYsOnjYPWhHfaiYQE qtFW9swZUSLGJlgfUPRa++Y+gKxFl+6W8ajUibfuN1Y5+BlsjfbekcybD0BIlKXQwI327t4zudn ExPk5SpAe6g== X-Google-Smtp-Source: AGHT+IFQ03M3aTRppiNCfLsuYEASJusj+ybeUo8fprfJ1Y1kR44v8CZCgZBXMkKg6JbKjrrKoR1HPHTKxUnd6g== X-Received: from yjq3.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:272f]) (user=jiaqiyan job=sendgmr) by 2002:a17:902:e74c:b0:1f9:c823:d3 with SMTP id d9443c01a7336-1fa1d516b81mr196425ad.6.1719246837884; Mon, 24 Jun 2024 09:33:57 -0700 (PDT) Date: Mon, 24 Jun 2024 16:33:48 +0000 In-Reply-To: <20240624163348.1751454-1-jiaqiyan@google.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240624163348.1751454-1-jiaqiyan@google.com> X-Mailer: git-send-email 2.45.2.741.gdbec12cfda-goog Message-ID: <20240624163348.1751454-5-jiaqiyan@google.com> Subject: [PATCH v5 4/4] docs: mm: add enable_soft_offline sysctl From: Jiaqi Yan To: nao.horiguchi@gmail.com, linmiaohe@huawei.com, jane.chu@oracle.com, ioworker0@gmail.com Cc: muchun.song@linux.dev, akpm@linux-foundation.org, 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, Jiaqi Yan Add the documentation for soft offline behaviors / costs, and what the new enable_soft_offline sysctl is for. Acked-by: Oscar Salvador Signed-off-by: Jiaqi Yan --- Documentation/admin-guide/sysctl/vm.rst | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Documentation/admin-guide/sysctl/vm.rst b/Documentation/admin-guide/sysctl/vm.rst index e86c968a7a0e..71463a7b3e2a 100644 --- a/Documentation/admin-guide/sysctl/vm.rst +++ b/Documentation/admin-guide/sysctl/vm.rst @@ -36,6 +36,7 @@ Currently, these files are in /proc/sys/vm: - dirtytime_expire_seconds - dirty_writeback_centisecs - drop_caches +- enable_soft_offline - extfrag_threshold - highmem_is_dirtyable - hugetlb_shm_group @@ -267,6 +268,37 @@ used:: These are informational only. They do not mean that anything is wrong with your system. To disable them, echo 4 (bit 2) into drop_caches. +enable_soft_offline +=================== +Correctable memory errors are very common on servers. Soft-offline is kernel's +solution for memory pages having (excessive) corrected memory errors. + +For different types of page, soft-offline has different behaviors / costs. +- For a raw error page, soft-offline migrates the in-use page's content to + a new raw page. +- For a page that is part of a transparent hugepage, soft-offline splits the + transparent hugepage into raw pages, then migrates only the raw error page. + As a result, user is transparently backed by 1 less hugepage, impacting + memory access performance. +- For a page that is part of a HugeTLB hugepage, soft-offline first migrates + the entire HugeTLB hugepage, during which a free hugepage will be consumed + as migration target. Then the original hugepage is dissolved into raw + pages without compensation, reducing the capacity of the HugeTLB pool by 1. + +It is user's call to choose between reliability (staying away from fragile +physical memory) vs performance / capacity implications in transparent and +HugeTLB cases. + +For all architectures, enable_soft_offline controls whether to soft offline +memory pages. When setting to 1, kernel attempts to soft offline the pages +whenever it thinks needed. When setting to 0, kernel returns EOPNOTSUPP to +the request to soft offline the pages. Its default value is 1. + +It is worth mentioning that after setting enable_soft_offline to 0, the +following requests to soft offline pages will not be performed: +- Request to soft offline pages from RAS Correctable Errors Collector. +- On ARM, the request to soft offline pages from GHES driver. +- On PARISC, the request to soft offline pages from Page Deallocation Table. extfrag_threshold =================