From patchwork Mon Jan 16 19:39:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaqi Yan X-Patchwork-Id: 13103611 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 AF5B4C54EBE for ; Mon, 16 Jan 2023 19:39:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 500826B0075; Mon, 16 Jan 2023 14:39:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4B0E86B0078; Mon, 16 Jan 2023 14:39:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 352026B007B; Mon, 16 Jan 2023 14:39:17 -0500 (EST) 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 26B546B0075 for ; Mon, 16 Jan 2023 14:39:17 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id F1FD4A0853 for ; Mon, 16 Jan 2023 19:39:16 +0000 (UTC) X-FDA: 80361675912.07.957F3FF Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) by imf10.hostedemail.com (Postfix) with ESMTP id 61D44C0005 for ; Mon, 16 Jan 2023 19:39:15 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=XDmsjOcs; spf=pass (imf10.hostedemail.com: domain of 34qfFYwgKCG0UTLbTjLYRZZRWP.NZXWTYfi-XXVgLNV.ZcR@flex--jiaqiyan.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=34qfFYwgKCG0UTLbTjLYRZZRWP.NZXWTYfi-XXVgLNV.ZcR@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=1673897955; 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=9m2TZ6IFiZM1VRO/0EBGpODM+jLu6Y9x1OYyXGlGaAE=; b=EP3j5CvoOXu9+j/oJYeTxqeZCVrvSHFz2thZow41Rr+TcBT1ZwaGCO/Nlg4dj17k/adF1B xC2n1syNkPtpxRvccvDstjAbfmo9jOD4gCDkogrLyBLF3HeQb/sRxx/nojDoriBDmOZAii 3DCoJFgCRVCxZxnSQ6IVsZL3nffttfs= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=XDmsjOcs; spf=pass (imf10.hostedemail.com: domain of 34qfFYwgKCG0UTLbTjLYRZZRWP.NZXWTYfi-XXVgLNV.ZcR@flex--jiaqiyan.bounces.google.com designates 209.85.214.201 as permitted sender) smtp.mailfrom=34qfFYwgKCG0UTLbTjLYRZZRWP.NZXWTYfi-XXVgLNV.ZcR@flex--jiaqiyan.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673897955; a=rsa-sha256; cv=none; b=eNbXoJw0YQChnQccGvaZdoywYDTEW+hOQn6FimpoySmB8+BVmbkkGZBvla9q7jKrotZiIZ ZkXYEUYZeKOxMSuDZVRFFTIkXvvENzpsuSKOgHbtXkDJ/8oRfREILYAtnaRYiACfcxhkpO /v89v2E8X/xXr7MWPxT5eTZfvBI8XKM= Received: by mail-pl1-f201.google.com with SMTP id u6-20020a170903124600b00188cd4769bcso20348918plh.0 for ; Mon, 16 Jan 2023 11:39:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=9m2TZ6IFiZM1VRO/0EBGpODM+jLu6Y9x1OYyXGlGaAE=; b=XDmsjOcsaWcHGJJzxrW7OL5na2AWW1mH+egu3heC6/XNRrJZsqUwQ8a5+MWtCtuCTD 40Ye7IvOY8HacScudAbcNdbFMJ/RaqoY+Tf3Eg+efRQAXhiEkZ6Olg232cgaWetQEn/F 05u4w4vxezb+eowmNASgbi/K9di2WD4mLxmxR3SUjN2DIM2Sh9y+TZhyVD8dfOIKsrE7 PIp2aOQyxasVBtAyWPUfWZifhmDSYIP9KWE0QL2n+pRGsQ96cOYI0c7RTmnCRdBhnuSP Mdbi8/ShErq8K26giVJFdPz885saCn2YTbyCBO6u/9I+oRPLZ9zhP64EwAOh0ntMT/Ka af5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=9m2TZ6IFiZM1VRO/0EBGpODM+jLu6Y9x1OYyXGlGaAE=; b=Slu7MrDTdzNeVdoPBJsyu3HkQuz52NMNMyuQhXS5JGmqO5wrbAOQLQTRlVh5syiYCK suWecj1YORAtVfF/FNk7MjTgWSSFxnlQDA84VWQd+NeOON4rJf5zJL7rE6lBu3mcCv/M siqJIPcU3YOkTr1A3vcILnQ2auTwWpnAjoqhINB82WCeiOvFo3/w4FhRzBKYdUj0SXEz gtw2wCG8UbWNFiD72YWnscCyTQctcQMjlJ6/k24JlbdPr6JoXpkZNjz+wReFUEQgWrV8 HmjIsuEM3bGtYNKv2y7XJ2c/dVyHPTxpZlUwTXvnC+PFpsR+ql3F0kRbRDT0in6FtXJc 9u+w== X-Gm-Message-State: AFqh2kqSzm3woABEr97mDhEraLhcPo8padlRJ3EV+DzAk6OVmM9xOJXS u6+oTcBxMhRPNIuio8/6KlbNf80WFCDsGQ== X-Google-Smtp-Source: AMrXdXu/Z2nDqVdVJuD71p4PILJiOHqmaIbqMlPlJ+Gs7GwlHZEt2FL5OM5vPI/9PJrHeeAB5sk4thKXipkFYg== X-Received: from yjq3.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:272f]) (user=jiaqiyan job=sendgmr) by 2002:a17:90b:3a90:b0:229:6b54:5a07 with SMTP id om16-20020a17090b3a9000b002296b545a07mr38451pjb.103.1673897954252; Mon, 16 Jan 2023 11:39:14 -0800 (PST) Date: Mon, 16 Jan 2023 19:39:01 +0000 In-Reply-To: <20230116193902.1315236-1-jiaqiyan@google.com> Mime-Version: 1.0 References: <20230116193902.1315236-1-jiaqiyan@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20230116193902.1315236-3-jiaqiyan@google.com> Subject: [PATCH v1 2/3] mm: memory-failure: Bump memory failure stats to pglist_data From: Jiaqi Yan To: tony.luck@intel.com, naoya.horiguchi@nec.com Cc: jiaqiyan@google.com, duenwen@google.com, rientjes@google.com, linux-mm@kvack.org, shy828301@gmail.com, akpm@linux-foundation.org, wangkefeng.wang@huawei.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 61D44C0005 X-Stat-Signature: 5b1dy74nxm9mo3ezqkauydmcgf18cpd8 X-Rspam-User: X-HE-Tag: 1673897955-430966 X-HE-Meta: U2FsdGVkX18f+xF95ND3xPWGws4A1tsu+2d/d5XJifOOs90J2xOdTaYkA6dPmBVg4rMey3Yn4DdNejtHhl/VqMxn5Xy7CTIGaygS7CwDL+rNeznDIqOzxQjZKemFAJzRhYwgCdOn9XwTQbxe89R2kaaXEHJ3Z0auR6+oqh4EMCoql/3LhZwQMjRpl6EdAJC1ulCM+cDBgoIi5KpJlz/NaQkwpiANJLJpWQQ7hdY8A7fhnirx47CGpU94xLga6HTU29D0SaiH0Y56LLMTU2PIUrK/NY8KnONsYy7BJDE9ecb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RRY/b2shdx0re6VDqOw4XJaZ33Kk= 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: Right before memory_failure finishes its handling, accumulate poisoned page's resolution counters to pglist_data's memory_failure_stats, so as to update the corresponding sysfs entries. Tested: 1) Start an application to allocate memory buffer chunks 2) Convert random memory buffer addresses to physical addresses 3) Inject memory errors using EINJ at chosen physical addresses 4) Access poisoned memory buffer and recover from SIGBUS 5) Check counter values under /sys/devices/system/node/node*/memory_failure/pages_* Acked-by: David Rientjes Signed-off-by: Jiaqi Yan --- mm/memory-failure.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index cb782fa552d5..c90417cfcda4 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1227,6 +1227,39 @@ static struct page_state error_states[] = { #undef slab #undef reserved +static void update_per_node_mf_stats(unsigned long pfn, + enum mf_result result) +{ + int nid = MAX_NUMNODES; + struct memory_failure_stats *mf_stats = NULL; + + nid = pfn_to_nid(pfn); + if (unlikely(nid < 0 || nid >= MAX_NUMNODES)) { + WARN_ONCE(1, "Memory failure: pfn=%#lx, invalid nid=%d", pfn, nid); + return; + } + + mf_stats = &NODE_DATA(nid)->mf_stats; + switch (result) { + case MF_IGNORED: + ++mf_stats->pages_ignored; + break; + case MF_FAILED: + ++mf_stats->pages_failed; + break; + case MF_DELAYED: + ++mf_stats->pages_delayed; + break; + case MF_RECOVERED: + ++mf_stats->pages_recovered; + break; + default: + WARN_ONCE(1, "Memory failure: mf_result=%d is not properly handled", result); + break; + } + ++mf_stats->pages_poisoned; +} + /* * "Dirty/Clean" indication is not 100% accurate due to the possibility of * setting PG_dirty outside page lock. See also comment above set_page_dirty(). @@ -1237,6 +1270,9 @@ static int action_result(unsigned long pfn, enum mf_action_page_type type, trace_memory_failure_event(pfn, type, result); num_poisoned_pages_inc(pfn); + + update_per_node_mf_stats(pfn, result); + pr_err("%#lx: recovery action for %s: %s\n", pfn, action_page_types[type], action_name[result]);