[v11,2/3] mm: memory-failure: move return value documentation to function declaration
Message ID | 20240204080144.7977-3-xueshuai@linux.alibaba.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-51510-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp244415dyb; Sun, 4 Feb 2024 00:03:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IEDPDg4wBiRiZXCJCgH/onGQuPTh2V/YQUi7vGt76nK00ua9sr7aR+4PKyqKdEOZsCUPwU2 X-Received: by 2002:a05:6214:4882:b0:68c:9774:2254 with SMTP id pc2-20020a056214488200b0068c97742254mr3590950qvb.17.1707033798804; Sun, 04 Feb 2024 00:03:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707033798; cv=pass; d=google.com; s=arc-20160816; b=KsU6DKXzoRxiP3wxBfwQZyuv7XNXDTrXdWmkid/l7GUT0+3yEdwLcq/8CkMRRZiPra iL7+JyEBEPwXzFJ7kkO0PsYV1BquaF0MtZHvRvDGl+HuB7RFeAGKEIZ4Ov+ONpAjjnCP ZE3SkHPSbkdO3QCUBQ6nzrj/PL8x13UwW+QMuXS1oWOfI6cIEH5saH2AM0x+Ei0rbtN8 2Lzx9MTD92m1ngfOxt2/ic56kIomOYroWYbyV7PBlB0Ai8zPbwJ3W/a9yCP9nGFGVUD9 E1B98tqYNqIBbQY9guirmLgx+wso2iyhClghW8eI0YY6xxO6A1/p4I0HdQKnFVDc99rt +SEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=fnJBG1HYaP2ae74e0hOy/sgtFi6pdPcie6U/1Z9TVEk=; fh=y+k8IPEvHF7XadYuyCYQTmO2yleAT1j6SKYRYFLA0zU=; b=aJXDu3kwCASHMSfyITtHeKHfenlPk4qgZjf9ivULaFZLbz031fBmJftbv1iHXh+6od 1xa9pLxUf7wPnW78YpQM8ISa/lTI72Bf5tstpJvW0q+8V3+OmnCUwGnhEXaUEwJgqubM Nz3WJOSSY1P9tMFMt9LSqg3kazZ9/wFvG/E37BkvSMpZ/IlGd7V4sSRrPlhstbHv7POR fjzf5X6Mvud6OvyK9GXEo8GTk2TjDZtGTvqYQgIUTJiR8Kn8Hl4Uk3kFK9YFYtyCxdna yK4ZP/s8vr0BUw3O0x0/Mq1g6Noel7fMhexewNj50bczcA7HqxVx31rw1aB3jbkL9PTE QQ3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=D6gYpc3S; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-51510-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51510-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com X-Forwarded-Encrypted: i=1; AJvYcCV/4ctmUznvr+aF3CTos7UwkwBvqtl8oTUmpH6kKTIyDeL3/YyjPoOf9jCU1OCmfDXUJ1kpkSngSI5zggUQXrvpphQU0Q== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ct13-20020a056214178d00b0068c641b2886si5913803qvb.575.2024.02.04.00.03.18 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 00:03:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51510-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=D6gYpc3S; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-51510-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51510-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 968941C2181D for <ouuuleilei@gmail.com>; Sun, 4 Feb 2024 08:03:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1AFC111C87; Sun, 4 Feb 2024 08:02:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="D6gYpc3S" Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3E2C10958; Sun, 4 Feb 2024 08:02:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707033737; cv=none; b=FLhsu0LoMfvBsE3zk4TcMeJhrgs1TOprHiZnGOTZlRyeO9iU/695H6qd8HeQQen5ox/ZG/wWEcDb7/Maok/JtIvcRq1nShKs1DZHYf2pnPrr80XgavWCM3HJEWsmXdliwVpM0j3Zq3h/AIqNNlHL/dUZ32641omKQTE4jFcqz/E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707033737; c=relaxed/simple; bh=sUv5rFk0aEEpl0ZpdPmyX0o2IZjmXDBQ/ogddWLM6VY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EMh1R27D2nPFhHquRtgYdtqP2Cp24jbeFRjZrGrwQH+6YWJ0u8ecFHEx66L7/jwtUhWUvd0BoDLCpv07zr9gQ7nZU3TejhwZZSDnw+7XuVQ3io3CYYXAhYPyYjxDWLIgIhCl8m5wwEL+qzia1WGxOaa7gxwkMndl+mKMuGaynYA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=D6gYpc3S; arc=none smtp.client-ip=115.124.30.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1707033727; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=fnJBG1HYaP2ae74e0hOy/sgtFi6pdPcie6U/1Z9TVEk=; b=D6gYpc3SyRoDnRXktZQ+wQBYb7cQzTQFe4xXWVbL+r6VVAEh0ANWc+ChX2Mccgf+901sB5q1JKgI74V6IBo0bg2CcWQ6+LQwmNqHZ8ditRDVyOnl3vfDAEUPGORASn00lwWS/egHZDv6TUQNZjxcwrDlIN9Iytv58nt+7xeDuZs= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=xueshuai@linux.alibaba.com;NM=1;PH=DS;RN=33;SR=0;TI=SMTPD_---0W0003Lp_1707033722; Received: from localhost.localdomain(mailfrom:xueshuai@linux.alibaba.com fp:SMTPD_---0W0003Lp_1707033722) by smtp.aliyun-inc.com; Sun, 04 Feb 2024 16:02:05 +0800 From: Shuai Xue <xueshuai@linux.alibaba.com> To: bp@alien8.de, rafael@kernel.org, wangkefeng.wang@huawei.com, tanxiaofei@huawei.com, mawupeng1@huawei.com, tony.luck@intel.com, linmiaohe@huawei.com, naoya.horiguchi@nec.com, james.morse@arm.com, gregkh@linuxfoundation.org, will@kernel.org, jarkko@kernel.org Cc: linux-acpi@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, linux-edac@vger.kernel.org, x86@kernel.org, xueshuai@linux.alibaba.com, justin.he@arm.com, ardb@kernel.org, ying.huang@intel.com, ashish.kalra@amd.com, baolin.wang@linux.alibaba.com, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, lenb@kernel.org, hpa@zytor.com, robert.moore@intel.com, lvying6@huawei.com, xiexiuqi@huawei.com, zhuo.song@linux.alibaba.com Subject: [PATCH v11 2/3] mm: memory-failure: move return value documentation to function declaration Date: Sun, 4 Feb 2024 16:01:43 +0800 Message-Id: <20240204080144.7977-3-xueshuai@linux.alibaba.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221027042445.60108-1-xueshuai@linux.alibaba.com> References: <20221027042445.60108-1-xueshuai@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789954672547206871 X-GMAIL-MSGID: 1789954672547206871 |
Series |
None
|
|
Commit Message
Shuai Xue
Feb. 4, 2024, 8:01 a.m. UTC
Part of return value comments for memory_failure() were originally
documented at the call site. Move those comments to the function
declaration to improve code readability and to provide developers with
immediate access to function usage and return information.
Signed-off-by: Shuai Xue <xueshuai@linux.alibaba.com>
---
arch/x86/kernel/cpu/mce/core.c | 9 +--------
mm/memory-failure.c | 9 ++++++---
2 files changed, 7 insertions(+), 11 deletions(-)
Comments
On Sun, Feb 04, 2024 at 04:01:43PM +0800, Shuai Xue wrote: > Part of return value comments for memory_failure() were originally > documented at the call site. Move those comments to the function > declaration to improve code readability and to provide developers with > immediate access to function usage and return information. > > Signed-off-by: Shuai Xue <xueshuai@linux.alibaba.com> > --- > arch/x86/kernel/cpu/mce/core.c | 9 +-------- > mm/memory-failure.c | 9 ++++++--- > 2 files changed, 7 insertions(+), 11 deletions(-) > > diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c > index bc39252bc54f..822b21eb48ad 100644 > --- a/arch/x86/kernel/cpu/mce/core.c > +++ b/arch/x86/kernel/cpu/mce/core.c > @@ -1365,17 +1365,10 @@ static void kill_me_maybe(struct callback_head *cb) > return; > } > > - /* > - * -EHWPOISON from memory_failure() means that it already sent SIGBUS > - * to the current process with the proper error info, > - * -EOPNOTSUPP means hwpoison_filter() filtered the error event, > - * > - * In both cases, no further processing is required. > - */ > if (ret == -EHWPOISON || ret == -EOPNOTSUPP) > return; > > - pr_err("Memory error not recovered"); > + pr_err("Sending SIGBUS to current task due to memory error not recovered"); Unrelated change. > kill_me_now(cb); > } > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 636280d04008..d33729c48eff 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -2175,9 +2175,12 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags, > * Must run in process context (e.g. a work queue) with interrupts > * enabled and no spinlocks held. > * > - * Return: 0 for successfully handled the memory error, > - * -EOPNOTSUPP for hwpoison_filter() filtered the error event, > - * < 0(except -EOPNOTSUPP) on failure. > + * Return values: > + * 0 - success > + * -EOPNOTSUPP - hwpoison_filter() filtered the error event. > + * -EHWPOISON - sent SIGBUS to the current process with the proper > + * error info by kill_accessing_process(). kill_accessing_process() is not the only one returning -EHWPOISON. And if you look at the code, it should be: -EHWPOISON - the page was already poisoned, potentially kill process or so.
On 2024/2/26 18:46, Borislav Petkov wrote: > On Sun, Feb 04, 2024 at 04:01:43PM +0800, Shuai Xue wrote: >> Part of return value comments for memory_failure() were originally >> documented at the call site. Move those comments to the function >> declaration to improve code readability and to provide developers with >> immediate access to function usage and return information. >> >> Signed-off-by: Shuai Xue <xueshuai@linux.alibaba.com> >> --- >> arch/x86/kernel/cpu/mce/core.c | 9 +-------- >> mm/memory-failure.c | 9 ++++++--- >> 2 files changed, 7 insertions(+), 11 deletions(-) >> >> diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c >> index bc39252bc54f..822b21eb48ad 100644 >> --- a/arch/x86/kernel/cpu/mce/core.c >> +++ b/arch/x86/kernel/cpu/mce/core.c >> @@ -1365,17 +1365,10 @@ static void kill_me_maybe(struct callback_head *cb) >> return; >> } >> >> - /* >> - * -EHWPOISON from memory_failure() means that it already sent SIGBUS >> - * to the current process with the proper error info, >> - * -EOPNOTSUPP means hwpoison_filter() filtered the error event, >> - * >> - * In both cases, no further processing is required. >> - */ >> if (ret == -EHWPOISON || ret == -EOPNOTSUPP) >> return; >> >> - pr_err("Memory error not recovered"); >> + pr_err("Sending SIGBUS to current task due to memory error not recovered"); > > Unrelated change. Yes, I will drop the error message change. > >> kill_me_now(cb); >> } >> >> diff --git a/mm/memory-failure.c b/mm/memory-failure.c >> index 636280d04008..d33729c48eff 100644 >> --- a/mm/memory-failure.c >> +++ b/mm/memory-failure.c >> @@ -2175,9 +2175,12 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags, >> * Must run in process context (e.g. a work queue) with interrupts >> * enabled and no spinlocks held. >> * >> - * Return: 0 for successfully handled the memory error, >> - * -EOPNOTSUPP for hwpoison_filter() filtered the error event, >> - * < 0(except -EOPNOTSUPP) on failure. >> + * Return values: >> + * 0 - success >> + * -EOPNOTSUPP - hwpoison_filter() filtered the error event. >> + * -EHWPOISON - sent SIGBUS to the current process with the proper >> + * error info by kill_accessing_process(). > > kill_accessing_process() is not the only one returning -EHWPOISON. > > And if you look at the code, it should be: > > -EHWPOISON - the page was already poisoned, potentially > kill process > > or so. > You are right, will fix it in next version. Thank you. Best Regards. Shuai
diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index bc39252bc54f..822b21eb48ad 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -1365,17 +1365,10 @@ static void kill_me_maybe(struct callback_head *cb) return; } - /* - * -EHWPOISON from memory_failure() means that it already sent SIGBUS - * to the current process with the proper error info, - * -EOPNOTSUPP means hwpoison_filter() filtered the error event, - * - * In both cases, no further processing is required. - */ if (ret == -EHWPOISON || ret == -EOPNOTSUPP) return; - pr_err("Memory error not recovered"); + pr_err("Sending SIGBUS to current task due to memory error not recovered"); kill_me_now(cb); } diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 636280d04008..d33729c48eff 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2175,9 +2175,12 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags, * Must run in process context (e.g. a work queue) with interrupts * enabled and no spinlocks held. * - * Return: 0 for successfully handled the memory error, - * -EOPNOTSUPP for hwpoison_filter() filtered the error event, - * < 0(except -EOPNOTSUPP) on failure. + * Return values: + * 0 - success + * -EOPNOTSUPP - hwpoison_filter() filtered the error event. + * -EHWPOISON - sent SIGBUS to the current process with the proper + * error info by kill_accessing_process(). + * other negative values - failure */ int memory_failure(unsigned long pfn, int flags) {