From patchwork Thu Mar 18 04:08:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 12147291 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E50A2C433E9 for ; Thu, 18 Mar 2021 04:08:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 69C5264E6B for ; Thu, 18 Mar 2021 04:08:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 69C5264E6B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 830DD6B0072; Thu, 18 Mar 2021 00:08:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 794058D0001; Thu, 18 Mar 2021 00:08:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FB8C6B0074; Thu, 18 Mar 2021 00:08:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id 379556B0072 for ; Thu, 18 Mar 2021 00:08:27 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 003FE6D6D for ; Thu, 18 Mar 2021 04:08:26 +0000 (UTC) X-FDA: 77931663012.07.1ED4691 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by imf14.hostedemail.com (Postfix) with ESMTP id 0B93DC0001F7 for ; Thu, 18 Mar 2021 04:08:25 +0000 (UTC) IronPort-SDR: VDGXvZ/jCPkrAkgDytt8ip9RxCu0FL4/lKDckMVsdi2YM34dFJnSKKDjC0h+fo6q8UP5YfiyaY B9cEvSgKrkEQ== X-IronPort-AV: E=McAfee;i="6000,8403,9926"; a="168878223" X-IronPort-AV: E=Sophos;i="5.81,257,1610438400"; d="scan'208";a="168878223" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2021 21:08:24 -0700 IronPort-SDR: 1rq8sqVWSe6YHQ+WVrPVpOsMt43EYcMglJqHZo97oYfutFoyx3sJkcavfyuGw3PDOsaLdR1Dfz oB7zwAcabX0Q== X-IronPort-AV: E=Sophos;i="5.81,257,1610438400"; d="scan'208";a="389086762" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2021 21:08:18 -0700 Subject: [PATCH 1/3] mm/memory-failure: Prepare for mass memory_failure() From: Dan Williams To: linux-mm@kvack.org, linux-nvdimm@lists.01.org Cc: Naoya Horiguchi , Andrew Morton , vishal.l.verma@intel.com, david@fromorbit.com, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Date: Wed, 17 Mar 2021 21:08:08 -0700 Message-ID: <161604048859.1463742.10087657197118774859.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <161604048257.1463742.1374527716381197629.stgit@dwillia2-desk3.amr.corp.intel.com> References: <161604048257.1463742.1374527716381197629.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 X-Stat-Signature: 8hqj6ixqcsb46omot34rjqewxr611rnz X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 0B93DC0001F7 Received-SPF: none (intel.com>: No applicable sender policy available) receiver=imf14; identity=mailfrom; envelope-from=""; helo=mga12.intel.com; client-ip=192.55.52.136 X-HE-DKIM-Result: none/none X-HE-Tag: 1616040505-35841 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: Currently memory_failure() assumes an infrequent report on a handful of pages. A new use case for surprise removal of a persistent memory device needs to trigger memory_failure() on a large range. Rate limit memory_failure() error logging, and allow the memory_failure_dev_pagemap() helper to be called directly. Cc: Naoya Horiguchi Cc: Andrew Morton Signed-off-by: Dan Williams --- mm/memory-failure.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 24210c9bd843..43ba4307c526 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -395,8 +395,9 @@ static void kill_procs(struct list_head *to_kill, int forcekill, bool fail, * signal and then access the memory. Just kill it. */ if (fail || tk->addr == -EFAULT) { - pr_err("Memory failure: %#lx: forcibly killing %s:%d because of failure to unmap corrupted page\n", - pfn, tk->tsk->comm, tk->tsk->pid); + pr_err_ratelimited( + "Memory failure: %#lx: forcibly killing %s:%d because of failure to unmap corrupted page\n", + pfn, tk->tsk->comm, tk->tsk->pid); do_send_sig_info(SIGKILL, SEND_SIG_PRIV, tk->tsk, PIDTYPE_PID); } @@ -408,8 +409,9 @@ static void kill_procs(struct list_head *to_kill, int forcekill, bool fail, * process anyways. */ else if (kill_proc(tk, pfn, flags) < 0) - pr_err("Memory failure: %#lx: Cannot send advisory machine check signal to %s:%d\n", - pfn, tk->tsk->comm, tk->tsk->pid); + pr_err_ratelimited( + "Memory failure: %#lx: Cannot send advisory machine check signal to %s:%d\n", + pfn, tk->tsk->comm, tk->tsk->pid); } put_task_struct(tk->tsk); kfree(tk); @@ -919,8 +921,8 @@ static void action_result(unsigned long pfn, enum mf_action_page_type type, { trace_memory_failure_event(pfn, type, result); - pr_err("Memory failure: %#lx: recovery action for %s: %s\n", - pfn, action_page_types[type], action_name[result]); + pr_err_ratelimited("Memory failure: %#lx: recovery action for %s: %s\n", + pfn, action_page_types[type], action_name[result]); } static int page_action(struct page_state *ps, struct page *p, @@ -1375,8 +1377,6 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags, unlock: dax_unlock_page(page, cookie); out: - /* drop pgmap ref acquired in caller */ - put_dev_pagemap(pgmap); action_result(pfn, MF_MSG_DAX, rc ? MF_FAILED : MF_RECOVERED); return rc; } @@ -1415,9 +1415,12 @@ int memory_failure(unsigned long pfn, int flags) if (!p) { if (pfn_valid(pfn)) { pgmap = get_dev_pagemap(pfn, NULL); - if (pgmap) - return memory_failure_dev_pagemap(pfn, flags, - pgmap); + if (pgmap) { + res = memory_failure_dev_pagemap(pfn, flags, + pgmap); + put_dev_pagemap(pgmap); + return res; + } } pr_err("Memory failure: %#lx: memory outside kernel control\n", pfn);