Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp900412imu; Fri, 25 Jan 2019 13:03:32 -0800 (PST) X-Google-Smtp-Source: ALg8bN7olCKKGlwH6pLJO4WQkpDt/ypZfuZYyUYqtnq7P04gIKSACfQPYNYnvthXT3n9RKlNike1 X-Received: by 2002:a62:824c:: with SMTP id w73mr12424529pfd.150.1548450212645; Fri, 25 Jan 2019 13:03:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548450212; cv=none; d=google.com; s=arc-20160816; b=RTGSNx/++PY8cnJCL1nmMMmDhN5uP6WdaTwT1KH87S+AwMB4X+rrmOUzN/WgJrVGhF HeAVK653nmDbTAJ1OEN8p3Tx/a6ilVQecW4yM0NV7lMYbmIvFqS2TcgFoJgJ4xUSiW4B 7IohombH5e/VkUVmGhUPlYBvtteHhfDUvDKEP4Poo3GBg89hzAYssyuL/VhuoPpRWd3D punpzMCEKhiEf95x72TpqBAYppID25jp1v9rkGKV2Ju96tuto/uLWmvC6o1A4wFspWAV sTATHGoxyhKFVvNOxCz3cbt/V937Nb/B+plHZ2rMvK3sS5zRDZKvUosYtfoYMS0DAWLa V2TQ== 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=GlFA8LtVMqJOfnjC7UmYvTFlMlqdaOETYFtC07gL8c8=; b=C2jTZXXJ76V6HJhFzwImSQTrQ+sm073rqJ4uiG6qVloU18bKCJ2iUGZiLWyvWIkXyb BFubHvNsfgi4cscpardc6IhxA/hkoVZPicm8RIw7CmOZLLsGxLZJGJwFx/CnjgaicLg9 yX8w613qUN5SAMvVSD3FdPxQOTAhU6vJqR/dDHIFZR3c+lxXeSee2YueLQNKqkWhJUw0 sthsUcvbi3aELw6nzGblqjxNa2fy2jDLNp7va8clShEvlHFZM7Q+B3jI03FAe6CQprfL IU75qbxk1eMF8B4ifFcCegOlW/K7/3NJ+9nMA3KHel+Ikwel9x0dhrfDAaEEbNN/w/xM nK8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=JRDDhEn8; 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 u2si25618639pgo.544.2019.01.25.13.03.14; Fri, 25 Jan 2019 13:03:32 -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=JRDDhEn8; 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 S1729098AbfAYVDJ (ORCPT + 99 others); Fri, 25 Jan 2019 16:03:09 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:37433 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726257AbfAYVDI (ORCPT ); Fri, 25 Jan 2019 16:03:08 -0500 Received: by mail-wr1-f68.google.com with SMTP id s12so11737971wrt.4 for ; Fri, 25 Jan 2019 13:03:07 -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=GlFA8LtVMqJOfnjC7UmYvTFlMlqdaOETYFtC07gL8c8=; b=JRDDhEn8/pBLDYMXq+rCIIkS2PvE/vCc8+Vgigg/VxRv1eyxQObLuf9Ql56fZebign hZZqX3LZTlxh4qtYJaHRX2ZnZzRI7SNdQMloqP3An+Di6jaSMBjtcI/JkdMlqzFC7BEj tkjLMRL0VYIJA0AfWf3mSFlXN8mfnFRs1vQPOThm+lQyqR7/DIeHKPd2b+iEhtmP8cNq 4SJIynT+/KmTQu69nps1hVdBtXq267EqcDrobJaMrTFCskCvhU1WRvRJrO1Hf8U8jAuH 0OQeoiMxMDs+Md0Ca0wNaQmVQZ/n7I0rK2cPmMM6IwHp4d2nC7eHBJYVhXFM8VCGru71 w3TA== 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=GlFA8LtVMqJOfnjC7UmYvTFlMlqdaOETYFtC07gL8c8=; b=lJiLxiR6hoAKUkpAZPs223Ebc2k2nw6LNuULEswFF+8uay7nRvUhHQgpitW1OD9oNh 4PDHFxMYUpIXthvu9v9zr+w421IRVY7Ef3feSjTD6B82I8YT3yO7QsehzPAtpSIY9fkH 2m53ZaNrd6bVEFt74vUU30z99G4nqM87VBd2VMg46t1KdUKX8pFODCD8sRTgHmR9Fj7k txlMKPvrt1jqLGGRmmEbmlf/hbIlQgAzLBOBtTRRVZnOHFWkinnHBmhI18DW5gzikhGh lTQxaxeHFG/AH6qgoUyUFt8nlEacyS86MOZOiv6+4Q+g5aSucMQSFVynrNU0Lp2v83+w kyfA== X-Gm-Message-State: AJcUukelZ0i/DNDvq7czSHuK9dw51zDrQGRW5/M9s72G3/Huj1FHN/1M 00AHfep3oIojVHbla7lxzJFfzlv9sRpGGot64keb X-Received: by 2002:adf:9b11:: with SMTP id b17mr13033849wrc.168.1548450186690; Fri, 25 Jan 2019 13:03:06 -0800 (PST) MIME-Version: 1.0 References: <20190124231441.37A4A305@viggo.jf.intel.com> <20190124231442.EFD29EE0@viggo.jf.intel.com> In-Reply-To: <20190124231442.EFD29EE0@viggo.jf.intel.com> From: Bjorn Helgaas Date: Fri, 25 Jan 2019 15:02:55 -0600 Message-ID: Subject: Re: [PATCH 1/5] mm/resource: return real error codes from walk failures To: Dave Hansen Cc: Linux Kernel Mailing List , 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-mm@kvack.org, Huang Ying , Wu Fengguang , Borislav Petkov , baiyaowei@cmss.chinamobile.com, Takashi Iwai , Jerome Glisse 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 Thu, Jan 24, 2019 at 5:21 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. > > Signed-off-by: Dave Hansen > 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 > Cc: Borislav Petkov > Cc: Bjorn Helgaas > Cc: Yaowei Bai > Cc: Takashi Iwai > Cc: Jerome Glisse > --- > > 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 2019-01-24 15:13:13.950199540 -0800 > +++ b/kernel/resource.c 2019-01-24 15:13:13.954199540 -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; Can you either make a similar change to the powerpc version of walk_system_ram_range() in arch/powerpc/mm/mem.c or explain why it's not needed? It *seems* like we'd want both versions of walk_system_ram_range() to behave similarly in this respect. > start = (u64) start_pfn << PAGE_SHIFT; > end = ((u64)(start_pfn + nr_pages) << PAGE_SHIFT) - 1; > _