Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1548953imu; Wed, 16 Jan 2019 22:34:37 -0800 (PST) X-Google-Smtp-Source: ALg8bN4/MZOAeveh5rV+pWtR7VIcIhM8IXhIorKALePgqlA93lEyxwrscj0PsD1zq5plaGNluweA X-Received: by 2002:a17:902:128c:: with SMTP id g12mr13273679pla.146.1547706877037; Wed, 16 Jan 2019 22:34:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547706877; cv=none; d=google.com; s=arc-20160816; b=AMPS3V0yapvjH0DkHiIPp1sWIPheVNgClGTQnItRA5DdkC6eQG50yQDjVP0Z7gnBDi ETkk+AlGp2GeIdR/ar3ji4AkGEGuVkVFxZU+mfoy3oqd9DW2nihgm5E8wnH7Yzwz1t9p 8QJ9eUKJ0H5WrO35N+ZSykWqdE9SIhAT2ZqZfX7StKbBZSuQ3+4rHHjwbmw0wOuOA8n8 zBjCymNnUABXDmOpj2xGQgty/LJtZ2qjMAM/OJyfESWTka66jCWiURsnoy07x2bYt5O4 c+KqECU/5mpDflhgTmmijpkflIXm2wiE+SONFcNsyFs7TbZqXcddpgDoLce5d92bocl9 Ir7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:in-reply-to:references:date :from:cc:to:subject; bh=v9C2bsdbZKN4wfrid2R3BaL4d2Hl91AmARUTxgFlVyE=; b=JuooPzQASzzA3abVBfHfmkieUu4xqVPJaBZ5vKSCV35BG5hjFpnWg8iaEw2vxgJe8q o7+9cRtoloiflvfutVupaAemcewnp4m6UzTJOB7UkmNUbZh6o0IgmtRgiy9apAw6m4+k ImGgXa6UgDE45naoUH/RbzPy+98zAyWMVYCEOHAX29siPi958WSCzDtziATOuNdcnLK6 /Yyqti3sU+wVyC07w3udyr8/9B4Dp6rsc14Z3Bf617a0xA4xFlXmW1W2ibjAOF6aYV2h JYGOxCiexnNzVmgjhDz/tc9ihdTJDmucDpc7CRi6nScBXJmcEM3LAxEIFLoG8v/5iGBN 4P4Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 61si839142plz.117.2019.01.16.22.34.21; Wed, 16 Jan 2019 22:34:37 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728615AbfAPSZo (ORCPT + 99 others); Wed, 16 Jan 2019 13:25:44 -0500 Received: from mga05.intel.com ([192.55.52.43]:10858 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728400AbfAPSZj (ORCPT ); Wed, 16 Jan 2019 13:25:39 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 10:25:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,487,1539673200"; d="scan'208";a="126559961" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by orsmga002.jf.intel.com with ESMTP; 16 Jan 2019 10:25:38 -0800 Subject: [PATCH 1/4] mm/resource: return real error codes from walk failures To: dave@sr71.net Cc: Dave Hansen , dan.j.williams@intel.com, dave.jiang@intel.com, zwisler@kernel.org, vishal.l.verma@intel.com, thomas.lendacky@amd.com, akpm@linux-foundation.org, mhocko@suse.com, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, ying.huang@intel.com, fengguang.wu@intel.com, bp@suse.de, bhelgaas@google.com, baiyaowei@cmss.chinamobile.com, tiwai@suse.de From: Dave Hansen Date: Wed, 16 Jan 2019 10:19:01 -0800 References: <20190116181859.D1504459@viggo.jf.intel.com> In-Reply-To: <20190116181859.D1504459@viggo.jf.intel.com> Message-Id: <20190116181901.CAF85066@viggo.jf.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; start = (u64) start_pfn << PAGE_SHIFT; end = ((u64)(start_pfn + nr_pages) << PAGE_SHIFT) - 1; _