From patchwork Fri Jan 20 03:46:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaqi Yan X-Patchwork-Id: 13109102 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 BCFE4C38159 for ; Fri, 20 Jan 2023 03:46:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 591E76B0078; Thu, 19 Jan 2023 22:46:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5407F6B007B; Thu, 19 Jan 2023 22:46:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3DFE46B007D; Thu, 19 Jan 2023 22:46:34 -0500 (EST) 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 30B806B0078 for ; Thu, 19 Jan 2023 22:46:34 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 08EFA1A0D8E for ; Fri, 20 Jan 2023 03:46:34 +0000 (UTC) X-FDA: 80373790308.15.C1B08B0 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) by imf29.hostedemail.com (Postfix) with ESMTP id 49EB0120009 for ; Fri, 20 Jan 2023 03:46:32 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=aSRPxEVI; spf=pass (imf29.hostedemail.com: domain of 3lw7KYwgKCAIlkcsk0cpiqqing.eqonkpwz-oomxcem.qti@flex--jiaqiyan.bounces.google.com designates 209.85.215.202 as permitted sender) smtp.mailfrom=3lw7KYwgKCAIlkcsk0cpiqqing.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=1674186392; 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=Vh3ILj9DKG5irjvgNrvZrFCXWlHJpNIyi1XxviyUiJM=; b=Wj8yOt2887JFYlZXidEDhvuyfGUfnz4K5Aqa2joNRnjyS07LszgORjQ6P2DjGHdthlxY/v flBHnFA+wevzi6yMz56P6A3hEuePJrlE5PA8Tuka0K0+8+Wtwso+Xrb0XB0GZxkJbD/FP4 hH51H4rBWajLcHKI6zk6uylcBWiVMV0= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=aSRPxEVI; spf=pass (imf29.hostedemail.com: domain of 3lw7KYwgKCAIlkcsk0cpiqqing.eqonkpwz-oomxcem.qti@flex--jiaqiyan.bounces.google.com designates 209.85.215.202 as permitted sender) smtp.mailfrom=3lw7KYwgKCAIlkcsk0cpiqqing.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=1674186392; a=rsa-sha256; cv=none; b=J/z2vYFzRyvXdIIjhZDcJEEfroh7ugohG3XHBQFkrNhlVZUEcMCQev/YyqHqaGQ0eEyeMp 411RtexUnGnNsToV7lHw6Oksra0IzYsFxHvJk7bZyUNIvEYBZ5d6HadY4ndQNlFC0Rk0ER BYdtJDzY0PwWF78CssTh0FUMaoFHqUs= Received: by mail-pg1-f202.google.com with SMTP id s76-20020a632c4f000000b0049ceb0f185eso1963588pgs.7 for ; Thu, 19 Jan 2023 19:46:31 -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=Vh3ILj9DKG5irjvgNrvZrFCXWlHJpNIyi1XxviyUiJM=; b=aSRPxEVI/CVfxAGsMfP16EgxYh+QuktFjPe2t5kv3/qEgUxjHLp4r6OtjgHRV8Kbrd jvnYw7fObLCpkDzA+e+MgM36k26uqwJvxgHtKwbA01sSZmMlfF0l2FOCbwlToWLLW5zu 03tYuST+/8k57H/QGaeKnV+ahL4l6moZiWp4acOJILenZCd0xs7W5aOkfvhBtAb0aobC 0TkLXTyjuVQLkoKItW17lq3kAMM7PAvu11NycnYWXdwP/j0FVNjwgWO8wjjlPBJpYsvO VAU+31DeCLAF0ipyJE/7CmzaUXLqNKnRzw5EZjMm8xU1drRBbw2bweyV+LMWTj+NTCdt TPJg== 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=Vh3ILj9DKG5irjvgNrvZrFCXWlHJpNIyi1XxviyUiJM=; b=oOCv7NXjs2heeFwuabp5GVXSHk9pu9rt2D83X0xQZ9eF5IHsDPJHcC4xQvk4Svv8bc WySFtVe1nfZ9L0B7iC4n9PptOBMKHWeZDkbEgd5KuDHgjFYmqtK+1qQlrFkwenaz+O0n Q+UVfOW47olc/J7YWqcZR+W+0B2byTHXi0BGxTlU6XoFb8nw3oworWU2p+vOYbr3XKNy juQhOm6sap0F80hjGf2lhNrjsrMzqtTs0RDX+aKXbKEq6w4BIzxsUc893x0q5RU8reKS MjyL0OPL2lh82ofJQ+f12FmLHe9Oh9E5CNa5VN2XwKhDZUyZrkcdUcVZB9IX+Pa2Uvc4 mDTw== X-Gm-Message-State: AFqh2kqWDGknEPiZ67KbFn9JBVsKsrjXrObxOwz6aSkYkqk0pAXPfAtD RYWrjGmiuBbMScvKIvJv3Zf4XjNYIgcXWQ== X-Google-Smtp-Source: AMrXdXtsoYxNlsEAqRJH/XdnlwWvTvE7TChG6zzsq7buK/fDm6KdEHEH4do4apgl0fyFmz8UQSzifEEqW7fGnA== X-Received: from yjq3.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:272f]) (user=jiaqiyan job=sendgmr) by 2002:a17:90a:4945:b0:22b:ae7e:9698 with SMTP id c63-20020a17090a494500b0022bae7e9698mr53693pjh.170.1674186391025; Thu, 19 Jan 2023 19:46:31 -0800 (PST) Date: Fri, 20 Jan 2023 03:46:21 +0000 In-Reply-To: <20230120034622.2698268-1-jiaqiyan@google.com> Mime-Version: 1.0 References: <20230120034622.2698268-1-jiaqiyan@google.com> X-Mailer: git-send-email 2.39.0.246.g2a6d74b583-goog Message-ID: <20230120034622.2698268-3-jiaqiyan@google.com> Subject: [PATCH v2 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: 49EB0120009 X-Stat-Signature: rowihiagzii9ep1axso8pj56qcaaiozb X-Rspam-User: X-HE-Tag: 1674186392-510706 X-HE-Meta: U2FsdGVkX184LGwP10ErsUwqawqvyCOUdbTHnluypX0f4u+3476x9vLeQOogxNxiPQmWVZoNxhyrGXBDPXPsJ+WxKcP6DbWewt65gzwjWsBAA2Cn0Pc8vckcyx0KcXicdmK6TZBebv8/IbQx6fV2iE4PkFo3WoE1W4c/+QmP0x4Sti2RLlLTKun/Zz51i2fXMJGEebWfgNDrP8ckqMIiQUGELZdmNh/2CM5R0BM1lI7ABOwpuuzEeig0bWC1nYggmxGYPzOcOAsMQPkcmIuPo3N4lD9ZufzT8dsu+PpoKJgsSRsJoc6AS05prL4zfTA8gAw546TUNv37Vd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heer/8PYB5jk8myEwStwAx/aMHG5KWOnE3qZAeWXZtZnZxGhFfBtHonEd3VXno+zeO8QMxeu5vPHNhBAxp9eKyW6ING10Krfs/H+p1JjOqkscjsCOAn6qgcooWxBYD0WV/V71AbXUvAp+npIYha/ZPn9YDKyOL6xQBt6SJKgrXAlH7D93/qBHrQ09n+c+1fW/o42gq0ytBnCmySFySk1fTYyAtF92PIuiV+M2CdanXL4HllR5NLyF+Y2y29czyyrbcD5F5gxevWU0ShQ== 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/* Acked-by: David Rientjes Signed-off-by: Jiaqi Yan Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index c628f1db3a4d..f4990839ea66 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->ignored; + break; + case MF_FAILED: + ++mf_stats->failed; + break; + case MF_DELAYED: + ++mf_stats->delayed; + break; + case MF_RECOVERED: + ++mf_stats->recovered; + break; + default: + WARN_ONCE(1, "Memory failure: mf_result=%d is not properly handled", result); + break; + } + ++mf_stats->total; +} + /* * "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]);