Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1295107imu; Wed, 16 Jan 2019 16:36:42 -0800 (PST) X-Google-Smtp-Source: ALg8bN4hYHeNT+dI9swgwHWZJdpzjy9ec0LDDtBG64Y1E/X57O80c6ooqsUywuTyAe0kG3ZjW6it X-Received: by 2002:a62:4851:: with SMTP id v78mr12779879pfa.97.1547685402347; Wed, 16 Jan 2019 16:36:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547685402; cv=none; d=google.com; s=arc-20160816; b=LBOl+RHnKdARoK6404LW46/jpgdJwxEVutw7VVfrxkJUkhfMZ7sLYciHWHt6JY7uln VbSNbET3kMfpcAiWvld1T5Gwthl0fxhEVWVu4gQMyd8BQihy8HuZxuBh/iTTTUuHKRLc UT+bkabbs68wlVHAo2qPYUE90KeXVFzV03JZ4BTGYfK+oEL00Srpoe8w4WVwK4BsleNs KxvS6AeVbfTSx8YdhmngSyLx0xZoIGALOWjpCU9sqbOKZvK4h22tJyCm1V+jArC1uaXi cqngmElTUWcUSfVeBwINAptzpWLS+0vWh3nCtnQdLzKatZD4NOizbi6tsJVvBSWJAZZj eRfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=EXENUcZQeQc4GpVOepu2JqCrBL5FekqSojjxZTgabJE=; b=yIZM2QqJ7q3DLNcSlI2QdhgrNCMEbduq976TQa+fqs3cjlzdzPEikqxANrcz9GPbLh GNONs86N14zpcKJ7BTA6tnv3wOmix5dk+dhZxsoHBsy+MVlfgd5xWNG+XkM5aMSlGdty b32Dlgq62gZPlUsuMU+OYCK+zA2LNST19cvTos12zFbtq63H63IP3AqISJJ244fHbBOT q7AcKCjxAtT3NO2fcrMv/EyNFhwaCnxm38jDhqTJ/WXLgxZTcuzgU6Jri1/26bnnUP7G R2Rdsw7qeQM+PxXWKKORcBm5c89MIgKPEIjezJF6oWZk0OrmlHeN7Z5fQ++NFTCB/bV8 mH4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JCWldirx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n13si6870886pgp.307.2019.01.16.16.36.27; Wed, 16 Jan 2019 16:36:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JCWldirx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727132AbfAPUih (ORCPT + 99 others); Wed, 16 Jan 2019 15:38:37 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:38101 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726646AbfAPUih (ORCPT ); Wed, 16 Jan 2019 15:38:37 -0500 Received: by mail-wm1-f65.google.com with SMTP id m22so3498355wml.3 for ; Wed, 16 Jan 2019 12:38:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EXENUcZQeQc4GpVOepu2JqCrBL5FekqSojjxZTgabJE=; b=JCWldirxMg//hUX4ioKgbonPMZuWXWN6HEC9HdxBMzSAWVFoVoWJFm2Y1KiskwlPZW itiYT++UShcarFg/zFJy8KfTI6HqbRYAx+Evx7qIm3jOSs5MIbE4O0B4BNrPyARXDOuh KYtUN/4omxn44KaN83fCPBSMxtFKU26Cpa7PSMnCyXCyFIvYoGWRLqWdhqFnCvNYz6R2 bhyLV3sWl+Ry+Iavnwp1Y9cl8CTO0T6Yyf7rx7fXds+A3Q63fKpeqMH4+NiVCakFGIEa ukB4vm2Kzt9V0x/tHozpZDaq1KyFXdiu+LTze5Kf7P66vr1MMeZPfYZh+5FLzMfPMuRF ulJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EXENUcZQeQc4GpVOepu2JqCrBL5FekqSojjxZTgabJE=; b=DEbPh3Uv8wOdwgmmnkbIumJHCut2YDZwu+J5VAGAtLyOy1TlmFN+wmUEJqv23rbv1A 0mr9B9MVy4RX8rcw2Tj83FBHst4S7acvfkaazOJ55n1njr95cXf4noBEKbWl6bE70UyD KpeppLraKTkHsSwo4sbb0AHgR5+2f6P9+9UtDe6J9m0CmCcay5uIoLhfyHQq2ehaYjjf XM/H20m+o0BEvkYXxPP+aPWyj59na+91DREbxxK8MMWwPum/d6uAsD41gsb1awjftb9w 11piG9lLQbhNXw62ke9znFsDseNwdduBhxsZwPHB1k01/H2S/d8iY3/yF7tdZcJwQQG+ yq7g== X-Gm-Message-State: AJcUukfrFPcCbXpmJZTEHRzFusCK6Bje9i2/F577aGqV7AeLeORuyh7o epjX8qgVtkAvPlwaSl4mN0QLLNhk9qW2Cou8Vgfn X-Received: by 2002:a1c:8d53:: with SMTP id p80mr9476229wmd.68.1547671114168; Wed, 16 Jan 2019 12:38:34 -0800 (PST) MIME-Version: 1.0 References: <20190116181859.D1504459@viggo.jf.intel.com> <20190116181901.CAF85066@viggo.jf.intel.com> In-Reply-To: <20190116181901.CAF85066@viggo.jf.intel.com> From: Bjorn Helgaas Date: Wed, 16 Jan 2019 14:38:21 -0600 Message-ID: Subject: Re: [PATCH 1/4] mm/resource: return real error codes from walk failures To: Dave Hansen Cc: dave@sr71.net, Dan Williams , Dave Jiang , zwisler@kernel.org, vishal.l.verma@intel.com, thomas.lendacky@amd.com, Andrew Morton , mhocko@suse.com, linux-nvdimm@lists.01.org, Linux Kernel Mailing List , linux-mm@kvack.org, Huang Ying , Wu Fengguang , Borislav Petkov , baiyaowei@cmss.chinamobile.com, Takashi Iwai Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 16, 2019 at 12:25 PM Dave Hansen wrote: > > > From: Dave Hansen > > 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 > Cc: Dave Jiang > Cc: Ross Zwisler > Cc: Vishal Verma > Cc: Tom Lendacky > Cc: Andrew Morton > Cc: Michal Hocko > Cc: linux-nvdimm@lists.01.org > Cc: linux-kernel@vger.kernel.org > Cc: linux-mm@kvack.org > Cc: Huang Ying > Cc: Fengguang Wu > > > Signed-off-by: Dave Hansen > --- > > 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; > _