[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAErSpo63av+jnkSY-V_ZNKy1LDX7rGZ6rK1bWbTf3fgrhXqrwQ@mail.gmail.com>
Date: Wed, 16 Jan 2019 14:38:21 -0600
From: Bjorn Helgaas <bhelgaas@...gle.com>
To: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: dave@...1.net, Dan Williams <dan.j.williams@...el.com>,
Dave Jiang <dave.jiang@...el.com>, zwisler@...nel.org,
vishal.l.verma@...el.com, thomas.lendacky@....com,
Andrew Morton <akpm@...ux-foundation.org>, mhocko@...e.com,
linux-nvdimm@...ts.01.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-mm@...ck.org, Huang Ying <ying.huang@...el.com>,
Wu Fengguang <fengguang.wu@...el.com>,
Borislav Petkov <bp@...e.de>, baiyaowei@...s.chinamobile.com,
Takashi Iwai <tiwai@...e.de>
Subject: Re: [PATCH 1/4] mm/resource: return real error codes from walk failures
On Wed, Jan 16, 2019 at 12:25 PM Dave Hansen
<dave.hansen@...ux.intel.com> wrote:
>
>
> From: Dave Hansen <dave.hansen@...ux.intel.com>
>
> walk_system_ram_range() can return an error code either becuase *it*
> failed, or because the 'func' that it calls returned an error. The
> memory hotplug does the following:
>
> ret = walk_system_ram_range(..., func);
> if (ret)
> return ret;
>
> and 'ret' makes it out to userspace, eventually. The problem is,
> walk_system_ram_range() failues that result from *it* failing (as
> opposed to 'func') return -1. That leads to a very odd -EPERM (-1)
> return code out to userspace.
>
> Make walk_system_ram_range() return -EINVAL for internal failures to
> keep userspace less confused.
>
> This return code is compatible with all the callers that I audited.
>
> Cc: Dan Williams <dan.j.williams@...el.com>
> Cc: Dave Jiang <dave.jiang@...el.com>
> Cc: Ross Zwisler <zwisler@...nel.org>
> Cc: Vishal Verma <vishal.l.verma@...el.com>
> Cc: Tom Lendacky <thomas.lendacky@....com>
> Cc: Andrew Morton <akpm@...ux-foundation.org>
> Cc: Michal Hocko <mhocko@...e.com>
> Cc: linux-nvdimm@...ts.01.org
> Cc: linux-kernel@...r.kernel.org
> Cc: linux-mm@...ck.org
> Cc: Huang Ying <ying.huang@...el.com>
> Cc: Fengguang Wu <fengguang.wu@...el.com>
>
>
> Signed-off-by: Dave Hansen <dave.hansen@...ux.intel.com>
> ---
>
> b/kernel/resource.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff -puN kernel/resource.c~memory-hotplug-walk_system_ram_range-returns-neg-1 kernel/resource.c
> --- a/kernel/resource.c~memory-hotplug-walk_system_ram_range-returns-neg-1 2018-12-20 11:48:41.810771934 -0800
> +++ b/kernel/resource.c 2018-12-20 11:48:41.814771934 -0800
> @@ -375,7 +375,7 @@ static int __walk_iomem_res_desc(resourc
> int (*func)(struct resource *, void *))
> {
> struct resource res;
> - int ret = -1;
> + int ret = -EINVAL;
>
> while (start < end &&
> !find_next_iomem_res(start, end, flags, desc, first_lvl, &res)) {
> @@ -453,7 +453,7 @@ int walk_system_ram_range(unsigned long
> unsigned long flags;
> struct resource res;
> unsigned long pfn, end_pfn;
> - int ret = -1;
> + int ret = -EINVAL;
Don't you want a similar change in the powerpc version in arch/powerpc/mm/mem.c?
>
> start = (u64) start_pfn << PAGE_SHIFT;
> end = ((u64)(start_pfn + nr_pages) << PAGE_SHIFT) - 1;
> _
Powered by blists - more mailing lists