From patchwork Fri May 31 21:34:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaqi Yan X-Patchwork-Id: 13682199 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 49343C27C50 for ; Fri, 31 May 2024 21:34:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A4FF46B00A3; Fri, 31 May 2024 17:34:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9FF8C6B00A5; Fri, 31 May 2024 17:34:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 87D436B00A8; Fri, 31 May 2024 17:34:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 615206B00A3 for ; Fri, 31 May 2024 17:34:49 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E69711C2480 for ; Fri, 31 May 2024 21:34:48 +0000 (UTC) X-FDA: 82179995856.13.BAC56E4 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf20.hostedemail.com (Postfix) with ESMTP id 301361C000B for ; Fri, 31 May 2024 21:34:46 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=i2v1uHc7; spf=pass (imf20.hostedemail.com: domain of 3dkJaZggKCJ0GF7NFV7KDLLDIB.9LJIFKRU-JJHS79H.LOD@flex--jiaqiyan.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3dkJaZggKCJ0GF7NFV7KDLLDIB.9LJIFKRU-JJHS79H.LOD@flex--jiaqiyan.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717191287; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=22c0UwDgNXgPsVV+qHmiQw5fv4pPjf+Lc0qLhHTqi88=; b=zGYA98rING/or5XJisGsv8InM+9sFrJhxTVlWRAZV8lzr77YgZTDfMOgtG+b0xELe8P+7b 2hpPt2ltQnjPIGNnJJ39inwcJpIXHd1033e9Z+dlYEYrQQ0zx4gFSgfTFXELxGSCdEt+fk Pjw4+Rik5ktLkLwlJLEZRxgVFAAvb94= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717191287; a=rsa-sha256; cv=none; b=y4BKkDoQaB7VADbmAaVIYvDQWZxUurf3uTHuk/acFARRTdWnh58e2+WnRu5enJAutvUU9m ISIuXPUFeLBv46EQoSygrbXd31LuFLYovEdOhUYbr04OlvKPUjeS6eXm0AbaZFMYWhP2/A pTAu087tPqoA6je6JB6zYfWbeAcS1nE= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=i2v1uHc7; spf=pass (imf20.hostedemail.com: domain of 3dkJaZggKCJ0GF7NFV7KDLLDIB.9LJIFKRU-JJHS79H.LOD@flex--jiaqiyan.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3dkJaZggKCJ0GF7NFV7KDLLDIB.9LJIFKRU-JJHS79H.LOD@flex--jiaqiyan.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-627e9a500faso39775367b3.1 for ; Fri, 31 May 2024 14:34:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717191286; x=1717796086; darn=kvack.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=22c0UwDgNXgPsVV+qHmiQw5fv4pPjf+Lc0qLhHTqi88=; b=i2v1uHc7mUU18GOubd4WO8ivhQznsKHNd9Cb/qPwjuUNQnpwMO7/yT1wASl5cdyPnA Ldgqd4PsT2V8eUlBy6xYgVTFdV6xoyblg61VcdBAF5uv96h0Eco7B4li9f55tcdjsynR Y08G32xfJdB05eWYIGPd70Elx70qRzQvlWLBJQJgYD57/eEB+18EOhQhfbt3eCRAPYWy THDbLI9cU/t4pnw7rsW0+8ELzUzK4QLP4s8KMtxXFAyBIMMJnn2eKqW6WlJAQa8XHaZ0 hTocIcbvfC2SBzSzWrqE2s7O9BMnHNSRn1poYia2e8ZeTZYCXWJUbo5SVlC6O/FTxBSz SDGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717191286; x=1717796086; 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=22c0UwDgNXgPsVV+qHmiQw5fv4pPjf+Lc0qLhHTqi88=; b=UQeAPjMz+I70mlC+DmrxYBizXz3gR1CaDNBh5vhpQGYUmu5+sCDHt/V9a3A6Q6ZhbI UEYtP3r2YYf2sJY6XjyNEhYmR3GZL6zbWaCWKv4R7raaC0IdDEX52xvsisgHNHO5RGBV IXAaotBa3D4BPfQOP77tyfdfuvPu1UeNGzDYGYg0u7W2+w0zbgxW6wx0+HYoZT8vkDsR iEtTJ/X8gfDoM4pnLGPkRF83Pq5QR6uixIb1L6bFb84kcOl9xCtIpEMGueBwbL9LBDp6 IFLT+lHD/Weq7OflMP3DUw3UznD3JAuT32BaRIHrupibjhuy0U4Mz03Uouqdeg99MtJ9 jk3Q== X-Forwarded-Encrypted: i=1; AJvYcCU7nGFFSspTeAFCMppuGtPtregEGy0twVkWYz4L+SyM/hlpGJUD3cxgL+JLH4D02WtKSmyEzYcmJFAz44SM4YY/lc8= X-Gm-Message-State: AOJu0YzuO0GVpKWDvwqaKB8RlSInIdCdMJI3ZRE2flSdOI7E7vAC53Hl ys6vbtn3Te7X8Iiz5pOHW7RqBmIo41z9adZDB5IdLgldti/geIW6s0TYFv0yY1sMgAV5sdOvpYz 0rAFY+mYwFQ== X-Google-Smtp-Source: AGHT+IEbPH0RxghVV8ANS15DCUTRp3o55R94/IFYmAtgmFEhINYqlUogTkNzjy7wCCu0jtBNvh0ajeeH7yA3Hw== X-Received: from yjq3.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:272f]) (user=jiaqiyan job=sendgmr) by 2002:a05:6902:1003:b0:df7:62ec:c517 with SMTP id 3f1490d57ef6-dfa73dba365mr150739276.11.1717191286235; Fri, 31 May 2024 14:34:46 -0700 (PDT) Date: Fri, 31 May 2024 21:34:37 +0000 In-Reply-To: <20240531213439.2958891-1-jiaqiyan@google.com> Mime-Version: 1.0 References: <20240531213439.2958891-1-jiaqiyan@google.com> X-Mailer: git-send-email 2.45.1.288.g0e0cd299f1-goog Message-ID: <20240531213439.2958891-2-jiaqiyan@google.com> Subject: [PATCH v1 1/3] mm/memory-failure: userspace controls soft-offlining hugetlb pages From: Jiaqi Yan To: naoya.horiguchi@nec.com, muchun.song@linux.dev, linmiaohe@huawei.com Cc: akpm@linux-foundation.org, mike.kravetz@oracle.com, 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 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 301361C000B X-Rspam-User: X-Stat-Signature: 1r4qbpsfw7byrdyj6duzwz9qxicupccj X-HE-Tag: 1717191286-728983 X-HE-Meta: U2FsdGVkX1/370uNenXzHphE8a1UHZHdkxstCZiUPC4ztB6obl4TGAXoRsfLkzk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A+rcdnaR8HkBDxy4Rnq9k65zaWNi6d83bkMX5cUyaySYM+AowGQuwf+54rbFtYouUKQNmwd+u3QP3U8/duWWXyJ6LQIUQ/saTzSfoDpfsmAJ7vh475pzC8FxQWAcTht8l2zoPAVz8luWpGWGYxJOqBQn7A3Q9gNSAe8p/vvKpq75yWISK94Sm0duXL0gUOtJl4wwO4xEdmZPUIfQlQn0VUWQhzOeRM+LjB0t1O1HPGNRfRnMTo6ZItvIG8bCrbf1DubfdzL6wAZQxjSKk5biEA1JYaa3yVeyKT9FyCgFv7XS4aA2XqQvBunHf+YfahMGQ1tx66ZB0Wf3lhNVwyC78lKJnYoUbX9//IvSfTWugChIPh1wHBlVVMREANYfkHbDbA2JmlN0cNFhJHGRa6OYvrZvfte1MQYZIpo91IC+qtEueVBbZOXvjoaLFr2G+w0IsioV3fAn7nC7gRR9LtZA39vMwCp6aw== 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: 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 mapped/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 HugeTLB hugepages. Soft-offline dissolves a hugepage, 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. In addition, discarding the entire 1G memory 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: 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 soft-offlining HugeTLB pages: kernel only soft offlines hugepage if userspace has opt-ed in in for that specific hugepage size. The interface to userspace is a new sysfs entry called softoffline_corrected_errors under the /sys/kernel/mm/hugepages/hugepages-${size}kB directory: * When softoffline_corrected_errors=0, skip soft offlining for all hugepages of size ${size}kB. * When softoffline_corrected_errors=1, soft offline as before this patch series. So the granularity of the control is per hugepage size, and is kept in corresponding hstate. By default softoffline_corrected_errors is 1 to preserve existing behavior in kernel. Signed-off-by: Jiaqi Yan --- include/linux/hugetlb.h | 17 +++++++++++++++++ mm/hugetlb.c | 34 ++++++++++++++++++++++++++++++++++ mm/memory-failure.c | 7 +++++++ 3 files changed, 58 insertions(+) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 2b3c3a404769..55f9e9593cce 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -685,6 +685,7 @@ struct hstate { int next_nid_to_free; unsigned int order; unsigned int demote_order; + unsigned int softoffline_corrected_errors; unsigned long mask; unsigned long max_huge_pages; unsigned long nr_huge_pages; @@ -1029,6 +1030,16 @@ void hugetlb_unregister_node(struct node *node); */ bool is_raw_hwpoison_page_in_hugepage(struct page *page); +/* + * For certain hugepage size, when a hugepage has corrected memory error(s): + * - Return 0 if userspace wants to disable soft offlining the hugepage. + * - Return > 0 if userspace allows soft offlining the hugepage. + */ +static inline int hugetlb_softoffline_corrected_errors(struct folio *folio) +{ + return folio_hstate(folio)->softoffline_corrected_errors; +} + #else /* CONFIG_HUGETLB_PAGE */ struct hstate {}; @@ -1226,6 +1237,12 @@ static inline bool hugetlbfs_pagecache_present( { return false; } + +static inline int hugetlb_softoffline_corrected_errors(struct folio *folio) +{ + return 1; +} + #endif /* CONFIG_HUGETLB_PAGE */ static inline spinlock_t *huge_pte_lock(struct hstate *h, diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 6be78e7d4f6e..a184e28ce592 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4325,6 +4325,38 @@ static ssize_t demote_size_store(struct kobject *kobj, } HSTATE_ATTR(demote_size); +static ssize_t softoffline_corrected_errors_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buf) +{ + struct hstate *h = kobj_to_hstate(kobj, NULL); + + return sysfs_emit(buf, "%d\n", h->softoffline_corrected_errors); +} + +static ssize_t softoffline_corrected_errors_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, + size_t count) +{ + int err; + unsigned long input; + struct hstate *h = kobj_to_hstate(kobj, NULL); + + err = kstrtoul(buf, 10, &input); + if (err) + return err; + + /* softoffline_corrected_errors is either 0 or 1. */ + if (input > 1) + return -EINVAL; + + h->softoffline_corrected_errors = input; + + return count; +} +HSTATE_ATTR(softoffline_corrected_errors); + static struct attribute *hstate_attrs[] = { &nr_hugepages_attr.attr, &nr_overcommit_hugepages_attr.attr, @@ -4334,6 +4366,7 @@ static struct attribute *hstate_attrs[] = { #ifdef CONFIG_NUMA &nr_hugepages_mempolicy_attr.attr, #endif + &softoffline_corrected_errors_attr.attr, NULL, }; @@ -4655,6 +4688,7 @@ void __init hugetlb_add_hstate(unsigned int order) h = &hstates[hugetlb_max_hstate++]; mutex_init(&h->resize_lock); h->order = order; + h->softoffline_corrected_errors = 1; h->mask = ~(huge_page_size(h) - 1); for (i = 0; i < MAX_NUMNODES; ++i) INIT_LIST_HEAD(&h->hugepage_freelists[i]); diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 16ada4fb02b7..7094fc4c62e2 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2776,6 +2776,13 @@ int soft_offline_page(unsigned long pfn, int flags) return -EIO; } + if (PageHuge(page) && + !hugetlb_softoffline_corrected_errors(page_folio(page))) { + pr_info("soft offline: %#lx: hugetlb page is ignored\n", pfn); + put_ref_page(pfn, flags); + return -EINVAL; + } + mutex_lock(&mf_mutex); if (PageHWPoison(page)) { From patchwork Fri May 31 21:34:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaqi Yan X-Patchwork-Id: 13682200 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 A4027C25B75 for ; Fri, 31 May 2024 21:34:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FD7F6B00A5; Fri, 31 May 2024 17:34:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 286386B00A9; Fri, 31 May 2024 17:34:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D99E6B00AB; Fri, 31 May 2024 17:34:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DCACD6B00A5 for ; Fri, 31 May 2024 17:34:51 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 982C9160BC8 for ; Fri, 31 May 2024 21:34:51 +0000 (UTC) X-FDA: 82179995982.27.B443114 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf13.hostedemail.com (Postfix) with ESMTP id D271420007 for ; Fri, 31 May 2024 21:34:49 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=hX2G165z; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf13.hostedemail.com: domain of 3eEJaZggKCJ8IH9PHX9MFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--jiaqiyan.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3eEJaZggKCJ8IH9PHX9MFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--jiaqiyan.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717191289; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PSzGyHzMerzTaST3R5/MMuosQBVUwsZqbBH4EMH0Fg0=; b=II9CaOD3MKN9kGHba1wwUz6Y1aIZLdXH7mBldRDPi7p6OxS4VImw4sIQN0bgYQUb71xYkf NO6Z8XZ1j6aJNqkd7hpyOOPB/olI2kwHbVCguaGdNYFsSCJe/v2DbOZJGPFBXFzffXsSQP U+x/yItDqrak5xrAcPmI39hk+LH1Q6E= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=hX2G165z; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf13.hostedemail.com: domain of 3eEJaZggKCJ8IH9PHX9MFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--jiaqiyan.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3eEJaZggKCJ8IH9PHX9MFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--jiaqiyan.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717191289; a=rsa-sha256; cv=none; b=2BKYFq9rPZQdE3vcJflMvompT5Ld/K0cl26CjghLJ9RJoXPojbqQeTdGMuKLYYZfD5GkXs SjkGPOGP9E1zBXHe0IY0rYc2TnL06TWs6rBDb3Sqqr+8lSsMo5QxbgP+3AKREA3gmimJh8 o7ssKeYlv6orJ+cA8KfrYG8CoG/ChKw= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-627eb3fb46cso42602877b3.2 for ; Fri, 31 May 2024 14:34:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717191289; x=1717796089; darn=kvack.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=PSzGyHzMerzTaST3R5/MMuosQBVUwsZqbBH4EMH0Fg0=; b=hX2G165zt+fZVfFq3kPbh7gg/Z9uTySM0xJV3LzPpv1ld9fdMz04ag7G1EbthyNEci 3QsOxKS6pAQOVbsapAf/EHFTNA3CVd7MDlrZvUzMgPgSGtLfnWHvoiQCMr0sFk10N43W s0cCBYjLpmbZVeV0JW0GAjTXEi4yls+OEDWsbAwIY6tyQ9P4phS3UQHjlJcYRALtH16+ 6GJjzZ+J4VCqsRzeJ6fwf7zHpvrEMuz0gCHUUlXTB8fkRPNMYN383SHgaZxwhs77+q0O k3OM4CVZd+CjTNPVwXBT/dGDIG27wBV3ClQZXchiLGr43qoaFaUWAf998GcakhG0yddk r/WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717191289; x=1717796089; 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=PSzGyHzMerzTaST3R5/MMuosQBVUwsZqbBH4EMH0Fg0=; b=Eq7Y5YQ8BM9IjnEajYLtRHHag4U27rLMcSi+6lggW0WvtfB6Z6+1Popt5/W55dwprd avMh7JJgTjZJAFL0cMezSQ95PZA7rHESBWpV2rZ3N36D37eq7G7ckzFRZ56vtZ5i+bRW CyxKVvH8/vcm8bHPSdc7D/7D1K+5cLs5l7y0ZLQyxil00tunwvqAv9HlLESDzJh1kt2f vuGHF3Ge37NCVrZPlIfI5g6d5S18taOx/YBam1unYhdII+RkjH9MkbQfjV8h9fq/sMTm U2H6FmJRxzq6Sv3vUE9ZprtKI3etwf5fzv3uz52OpRcyXWQWZTIoTD1AjJZWcTp/Bp2e kl0w== X-Forwarded-Encrypted: i=1; AJvYcCVxeQw6VBIQhJJ2y/cocSL9+CXZSEXMfcyN0TQBoUknF7g3pCCupV3MwHIVylDtgPUhsqUcRmJ8i0EizRlEMA0vtKQ= X-Gm-Message-State: AOJu0YxcIP0JGeF0CG1g6QsbbNmBMogK6mmiuZWO5qvEAq7QqhxMmZfS Do6l2Zv3/GJL5KHaaERmPTJFD6tPt0FxYHndutqeMLhyKU+4+DowAEeo6iWHZxCj8qr/Z/sII94 c+4pmTOGETQ== X-Google-Smtp-Source: AGHT+IEQi1nZ7QRqcXRTdtpnROLucQXBPkROpipk0R8nebc5FNrDvH4o9mUOqbtoIoIFxgTSbLnzJMZjzIErxw== X-Received: from yjq3.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:272f]) (user=jiaqiyan job=sendgmr) by 2002:a05:6902:1003:b0:df7:62ec:c517 with SMTP id 3f1490d57ef6-dfa73dba365mr150746276.11.1717191288972; Fri, 31 May 2024 14:34:48 -0700 (PDT) Date: Fri, 31 May 2024 21:34:38 +0000 In-Reply-To: <20240531213439.2958891-1-jiaqiyan@google.com> Mime-Version: 1.0 References: <20240531213439.2958891-1-jiaqiyan@google.com> X-Mailer: git-send-email 2.45.1.288.g0e0cd299f1-goog Message-ID: <20240531213439.2958891-3-jiaqiyan@google.com> Subject: [PATCH v1 2/3] selftest/mm: test softoffline_corrected_errors behaviors From: Jiaqi Yan To: naoya.horiguchi@nec.com, muchun.song@linux.dev, linmiaohe@huawei.com Cc: akpm@linux-foundation.org, mike.kravetz@oracle.com, 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 X-Rspamd-Queue-Id: D271420007 X-Stat-Signature: bt15i8c81j7z87em83chrxwy67wfgphg X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1717191289-582537 X-HE-Meta: U2FsdGVkX18qooWvGQdgFzgfE2r5I6BEWNCWzz+MCtSlAaks50NXHpgroHn2uqw7OXW8jL7k11wQHP8NEGrMGmCh8GB4yzsV2GdgxKUrLVRmqaLz/zMFB1LN15X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4Zd9GwSwlGObMZQqaoSGoT/oDxWGXTslr7ccYaHPyyO5BYyPQHJmnsQiH6plS8tH4EA2+9WRCCNXgYgSNsoV0Pk4PZKsv9vuU8ZGGlmMU+ZSlxZiHpCDcfi04VETCB4X+fNc33TDH0QSmbo0g5CNcLrTDEilmBzqvdgAwAIwOMvKbKBaFBAJPBbT0ZILd6tyhQoaNqcI2oNzlduB5HEOA2dLVTkqPW0iRItlxJrgD06vm9DNqOJCBhy6Bvx/2x0KM+cxQYz6bOm1i1LEzNRTQNC2cdVFmgeNAZFDey1z7Fq8JqobgrdNsUNm5Eo3AlrAaYDwHY+vXUVTJGIEkpJvcF+4gDl75FQWWT53sErtTG4an7hbHchDw9JqZa1dlvbJQZ2R0Mf5NWwe2uwv4kxSU2/Dcd8if8IvXP+8VOXZyOvG7y2DJcDiMgBsjJX3K5K9E2drCbtd0= 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: Add regression and new tests when hugepage has correctable memory errors, and how userspace wants to deal with it: * if softoffline_corrected_errors=0, mapped hugepage is soft offlined * if softoffline_corrected_errors=1, 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 | 262 ++++++++++++++++++ tools/testing/selftests/mm/run_vmtests.sh | 4 + 4 files changed, 268 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..8d1d7d4a84d8 --- /dev/null +++ b/tools/testing/selftests/mm/hugetlb-soft-offline.c @@ -0,0 +1,262 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Test soft offline behavior for HugeTLB pages: + * - if softoffline_corrected_errors = 0, hugepages should stay intact and soft + * offlining failed with EINVAL. + * - if softoffline_corrected_errors > 0, a hugepage should be dissolved and + * nr_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 + +#ifndef MADV_SOFT_OFFLINE +#define MADV_SOFT_OFFLINE 101 +#endif + +#define PREFIX " ... " +#define EPREFIX " !!! " + +enum test_status { + TEST_PASS = 0, + TEST_FAILED = 1, + // From ${ksft_skip} in run_vmtests.sh. + TEST_SKIPPED = 4, +}; + +static enum test_status do_soft_offline(int fd, size_t len, int expect_ret) +{ + char *filemap = NULL; + char *hwp_addr = NULL; + const unsigned long pagesize = getpagesize(); + int ret = 0; + enum test_status status = TEST_SKIPPED; + + if (ftruncate(fd, len) < 0) { + perror(EPREFIX "ftruncate to len failed"); + return status; + } + + filemap = mmap(NULL, len, PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_POPULATE, fd, 0); + if (filemap == MAP_FAILED) { + perror(EPREFIX "mmap failed"); + goto untruncate; + } + + memset(filemap, 0xab, len); + printf(PREFIX "Allocated %#lx bytes of hugetlb pages\n", len); + + hwp_addr = filemap + len / 2; + ret = madvise(hwp_addr, pagesize, MADV_SOFT_OFFLINE); + printf(PREFIX "MADV_SOFT_OFFLINE %p ret=%d, errno=%d\n", + hwp_addr, ret, errno); + if (ret != 0) + perror(EPREFIX "madvise failed"); + + if (errno == expect_ret) + status = TEST_PASS; + else { + printf(EPREFIX "MADV_SOFT_OFFLINE should ret %d\n", expect_ret); + status = TEST_FAILED; + } + + munmap(filemap, len); +untruncate: + if (ftruncate(fd, 0) < 0) + perror(EPREFIX "ftruncate back to 0 failed"); + + return status; +} + +static int set_softoffline_corrected_errors(unsigned long hugepage_size, int value) +{ + char cmd[256] = {0}; + FILE *cmdfile = NULL; + + if (value != 0 && value != 1) + return -EINVAL; + + sprintf(cmd, + "echo %d > /sys/kernel/mm/hugepages/hugepages-%ldkB/softoffline_corrected_errors", + value, hugepage_size); + cmdfile = popen(cmd, "r"); + + if (cmdfile == NULL) + perror(EPREFIX "failed to set softoffline_corrected_errors"); + else + printf(PREFIX + "softoffline_corrected_errors=%d for %ldkB hugepages\n", + value, hugepage_size); + + 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 (!fgets(buffer, sizeof(buffer), cmdfile)) { + 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) { + perror(EPREFIX "could not open hugetlbfs file"); + return -1; + } + + memset(file_stat, 0, sizeof(*file_stat)); + if (fstatfs(fd, file_stat)) { + perror(EPREFIX "fstatfs failed"); + goto close; + } + if (file_stat->f_type != HUGETLBFS_MAGIC) { + printf(EPREFIX "not hugetlbfs file\n"); + goto close; + } + + return fd; +close: + close(fd); + return -1; +} + +static enum test_status test_soft_offline(void) +{ + int fd; + struct statfs file_stat; + unsigned long hugepagesize_kb = 0; + unsigned long nr_hugepages_before = 0; + unsigned long nr_hugepages_after = 0; + enum test_status status = TEST_SKIPPED; + + printf("Test Soft Offline When softoffline_corrected_errors=1\n"); + + fd = create_hugetlbfs_file(&file_stat); + if (fd < 0) { + printf(EPREFIX "Failed to create hugetlbfs file\n"); + return status; + } + + hugepagesize_kb = file_stat.f_bsize / 1024; + printf(PREFIX "Hugepagesize is %ldkB\n", hugepagesize_kb); + + if (set_softoffline_corrected_errors(hugepagesize_kb, 1)) + return TEST_FAILED; + + if (read_nr_hugepages(hugepagesize_kb, &nr_hugepages_before) != 0) + return TEST_FAILED; + + printf(PREFIX "Before MADV_SOFT_OFFLINE nr_hugepages=%ld\n", + nr_hugepages_before); + + status = do_soft_offline(fd, 2 * file_stat.f_bsize, /*expect_ret=*/0); + + if (read_nr_hugepages(hugepagesize_kb, &nr_hugepages_after) != 0) + return TEST_FAILED; + + printf(PREFIX "After MADV_SOFT_OFFLINE nr_hugepages=%ld\n", + nr_hugepages_after); + + if (nr_hugepages_before != nr_hugepages_after + 1) { + printf(EPREFIX "MADV_SOFT_OFFLINE should reduced 1 hugepage\n"); + return TEST_FAILED; + } + + return status; +} + +static enum test_status test_disable_soft_offline(void) +{ + int fd; + struct statfs file_stat; + unsigned long hugepagesize_kb = 0; + unsigned long nr_hugepages_before = 0; + unsigned long nr_hugepages_after = 0; + enum test_status status = TEST_SKIPPED; + + printf("Test Soft Offline When softoffline_corrected_errors=0\n"); + + fd = create_hugetlbfs_file(&file_stat); + if (fd < 0) { + printf(EPREFIX "Failed to create hugetlbfs file\n"); + return status; + } + + hugepagesize_kb = file_stat.f_bsize / 1024; + printf(PREFIX "Hugepagesize is %ldkB\n", hugepagesize_kb); + + if (set_softoffline_corrected_errors(hugepagesize_kb, 0)) + return TEST_FAILED; + + if (read_nr_hugepages(hugepagesize_kb, &nr_hugepages_before) != 0) + return TEST_FAILED; + + printf(PREFIX "Before MADV_SOFT_OFFLINE nr_hugepages=%ld\n", + nr_hugepages_before); + + status = do_soft_offline(fd, 2 * file_stat.f_bsize, /*expect_ret=*/EINVAL); + + if (read_nr_hugepages(hugepagesize_kb, &nr_hugepages_after) != 0) + return TEST_FAILED; + + printf(PREFIX "After MADV_SOFT_OFFLINE nr_hugepages=%ld\n", + nr_hugepages_after); + + if (nr_hugepages_before != nr_hugepages_after) { + printf(EPREFIX "MADV_SOFT_OFFLINE reduced %lu hugepages\n", + nr_hugepages_before - nr_hugepages_after); + return TEST_FAILED; + } + + return status; +} + +int main(void) +{ + enum test_status status; + + status = test_soft_offline(); + if (status != TEST_PASS) + return status; + + status = test_disable_soft_offline(); + if (status != TEST_PASS) + return status; + + printf("Test Soft Offline All Good!\n"); + return TEST_PASS; +} diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh index 3157204b9047..91db9971ba69 100755 --- a/tools/testing/selftests/mm/run_vmtests.sh +++ b/tools/testing/selftests/mm/run_vmtests.sh @@ -332,6 +332,10 @@ CATEGORY="hugetlb" run_test ./charge_reserved_hugetlb.sh -cgroup-v2 CATEGORY="hugetlb" run_test ./hugetlb_reparenting_test.sh -cgroup-v2 if $RUN_DESTRUCTIVE; then CATEGORY="hugetlb" run_test ./hugetlb-read-hwpoison +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 fi if [ $VADDR64 -ne 0 ]; then From patchwork Fri May 31 21:34:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaqi Yan X-Patchwork-Id: 13682201 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 72A36C25B75 for ; Fri, 31 May 2024 21:34:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 065B86B00AC; Fri, 31 May 2024 17:34:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0144D6B00AD; Fri, 31 May 2024 17:34:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF88A6B00AE; Fri, 31 May 2024 17:34:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B84BC6B00AC for ; Fri, 31 May 2024 17:34:56 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3CABDA280A for ; Fri, 31 May 2024 21:34:56 +0000 (UTC) X-FDA: 82179996192.12.66698A7 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) by imf04.hostedemail.com (Postfix) with ESMTP id 68E9840003 for ; Fri, 31 May 2024 21:34:53 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=RZOyE2aR; spf=pass (imf04.hostedemail.com: domain of 3e0JaZggKCKILKCSKaCPIQQING.EQONKPWZ-OOMXCEM.QTI@flex--jiaqiyan.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=3e0JaZggKCKILKCSKaCPIQQING.EQONKPWZ-OOMXCEM.QTI@flex--jiaqiyan.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717191293; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=P2AZ5BMz5S/rOvkA9+gnvnvJlkq2fc4Ze4ycghZveII=; b=XxJ28fekUZE69AxjYAQ9K6HsN56f3CfmVusOD+B1OGbbbv+VSxcFYty5rrHirbA8zfprs0 Lz+bvrPuwmjmO0sp0YJDl7ojJBkwD1bvY3zF9/Tvgdywe5YdNEYh3sA7/e1lncE5e+ZRuc rVNGwCNqCpo9RBmacolHltrY6jFMExU= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=RZOyE2aR; spf=pass (imf04.hostedemail.com: domain of 3e0JaZggKCKILKCSKaCPIQQING.EQONKPWZ-OOMXCEM.QTI@flex--jiaqiyan.bounces.google.com designates 209.85.215.201 as permitted sender) smtp.mailfrom=3e0JaZggKCKILKCSKaCPIQQING.EQONKPWZ-OOMXCEM.QTI@flex--jiaqiyan.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717191293; a=rsa-sha256; cv=none; b=isJrsxJF/O9s9QuqShzyO/+gpFUfA+Sc/SgfGlIWyqtwx6lEHDn8lElnsW6STxqg2vLTCD QCXxhaAxkm4Dra51p2ovA2GlmbRpjJkBYGbdnJrU6Fmd7qAkmAflVqNChq9cZmZJxy8Q7a vlqew44AbO8/QcqiNJyuYp9bUZIfcT0= Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-5e4df21f22dso2068363a12.0 for ; Fri, 31 May 2024 14:34:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717191292; x=1717796092; darn=kvack.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=P2AZ5BMz5S/rOvkA9+gnvnvJlkq2fc4Ze4ycghZveII=; b=RZOyE2aRL/Nc+Z/QJz6WtP1BdoxjSbg3XP6LpetSEg+8+RsW7ijq76MPQ3MT3ARl+w CLwoYm3lgXIyDU3GCbBlVye90PAJtzeGH1L1E1KYlo8DVjf/JQ2svcvwJU4+YQ2BKLNx M2id6CELi700W8a9OVC6L/9to0H5CMmEj+wCNpMbNT68CgvnSm4OB6jOjwxNpfHzH1bl jvPfonF81YP3lOZT5Je9PHmGG3XseBpoAryQBIoaaYSr1/rgO48WlfwYXn4QE0x3OC9d 3LY0kULFM2hi2nEExLjCPi/HkHPWyaPhtBZMkFPZbgXbEQUny7yqMxvo0xmdPUwUVLtz sqog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717191292; x=1717796092; 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=P2AZ5BMz5S/rOvkA9+gnvnvJlkq2fc4Ze4ycghZveII=; b=bB/ZQ6Hh9uZYErgSj0N62bBZHroXRvrqtQaDhFsNjFH1qK2+05y58SNXl6i+vqFH9t yhjwa+HgWSDr+IobGGQV6ukF65XfJdUOLClIIUG2FilRUxWoBC71Gal04wlCYUu8u6DQ 1Iz51w2sciVQt05x5LLbjF2Clc5DJKHPYMvniI4icK5cohFYbdp83vGUTOs3s5gdNNAB r69rp4OkBMzIKdTzw1wp0xur8n2OTIJU4hQS0E8XNcBPY+aE1iswdvI+ai/tVK7G6Onb /3GqoqlnRCr3dg6NdGWmPPPqgPljsNRam2Zm0qGXgPBsQTe6cqwCXOC8Mrt5I+g4e54X jvhQ== X-Forwarded-Encrypted: i=1; AJvYcCVzSgKDxlYw976jkMuNMC8+E44wzjdrMYqdFHQms2pDXZZhStWUNPCq327c5f6LWW/NQN7B72wCe6AZKgZLxV9oNAw= X-Gm-Message-State: AOJu0Yw7DPNo3UdIuuYd7KT6aF71VuuccyWlZy2uVmo+aYCl4Db9BhfK u94nmfdku0eq01TlPBamKrYRUtKHLW8ojLPjQIaRaXN1x67tPLrOazPqkyQ7QeRMMNypS2vCVnl lWS14hOiAnA== X-Google-Smtp-Source: AGHT+IHSsGGAcQ6aUIuC8o2985ElkNa7qtVF2VAo7I83ZQQo63eVcbrD7ODzDOPp0guzHEL0/6bg5jblNOTUpg== X-Received: from yjq3.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:272f]) (user=jiaqiyan job=sendgmr) by 2002:a63:951a:0:b0:658:7c4c:25b with SMTP id 41be03b00d2f7-6c3e253c0c9mr14785a12.4.1717191291924; Fri, 31 May 2024 14:34:51 -0700 (PDT) Date: Fri, 31 May 2024 21:34:39 +0000 In-Reply-To: <20240531213439.2958891-1-jiaqiyan@google.com> Mime-Version: 1.0 References: <20240531213439.2958891-1-jiaqiyan@google.com> X-Mailer: git-send-email 2.45.1.288.g0e0cd299f1-goog Message-ID: <20240531213439.2958891-4-jiaqiyan@google.com> Subject: [PATCH v1 3/3] docs: hugetlbpage.rst: add softoffline_corrected_errors From: Jiaqi Yan To: naoya.horiguchi@nec.com, muchun.song@linux.dev, linmiaohe@huawei.com Cc: akpm@linux-foundation.org, mike.kravetz@oracle.com, 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 X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 68E9840003 X-Stat-Signature: gxhqq7fabj1ocj6dueupzedf9uztzb1x X-HE-Tag: 1717191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OsxOyb3zn1mjn7YJzapogN5i+E0oATVedjr2DXGuJqCoiiWH/nmyewDQCj6msIoYvPYvmK/iAFQanHz0HMVeX4nedmIHiHRd1uohKzhWvInOiCLlfhfKFNKH8sLjhZL1F77+X3vnnJKOKBojgnhuVQq3lxUnAEgdBFx3YSLVc9oNbsyxJw8tE/E9FP5y2OkluUddp6XMY7niSpeN/mWECjM/7aEpeGbRTRghiQqpfqbaGutiKiltsvJZllxnFqXuAghcns3lVys5ossCOPubl50FmbcC9UK3MuB5bzia/ig5/7r1C/upBw4RsvHi9y4kaoaxHpq5+HkJWhM61ovmxGm7CCxy0leSm5G9TQjmmfQVUtWjM9WqKPpxcfVccuy5gIsDM6Nvdkhm6/eCOzXVeZ/lkEEer1nvOoMxrQOaCfKyeNIe0Zj7cSodWkGVHDj08GfuPn8i1t3K9a4UB/r5HpHcGW/gTp0gkFUwt7JLlBI1TBfv6FKErjUWwdQ/Jdq/y2pRK4FhDdMlQIMyJA/IpEMSCOHZZNk5IKkR5tVMC9kRYlClm4laC/JJtBwREwDkpoESa2twJ1pl0Z0DV6r39Ur9Up5s= 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: Add the documentation for what softoffline_corrected_errors sysfs interface is for. Signed-off-by: Jiaqi Yan --- Documentation/admin-guide/mm/hugetlbpage.rst | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/mm/hugetlbpage.rst b/Documentation/admin-guide/mm/hugetlbpage.rst index f34a0d798d5b..7969ae47f5f1 100644 --- a/Documentation/admin-guide/mm/hugetlbpage.rst +++ b/Documentation/admin-guide/mm/hugetlbpage.rst @@ -244,7 +244,8 @@ will exist, of the form:: Inside each of these directories, the set of files contained in ``/proc`` will exist. In addition, two additional interfaces for demoting huge -pages may exist:: +pages, and one additional interface for handling corrected memory errors, +may exist:: demote demote_size @@ -254,6 +255,7 @@ pages may exist:: free_hugepages resv_hugepages surplus_hugepages + softoffline_corrected_errors The demote interfaces provide the ability to split a huge page into smaller huge pages. For example, the x86 architecture supports both @@ -276,6 +278,17 @@ demote actually demoted, compare the value of nr_hugepages before and after writing to the demote interface. demote is a write only interface. +The interface for handling corrected memory errors is + +softoffline_corrected_errors + allow userspace to control how to deal with hugepages that have + corrected memory errors. When setting to 1, kernel attempts to soft + offline the hugepage whenever it thinks needed. If soft offlinging a + huge page succeeds, for in-use hugepage, page content is migrated to a + new hugepage; however, regardless of in-use or free, capacity of the + hugepages will reduce by 1. When setting to 0, kernel won't attempt to + soft offline the hugepage of the specific size. Its default value is 1. + The interfaces which are the same as in ``/proc`` (all except demote and demote_size) function as described above for the default huge page-sized case.