Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp298998img; Mon, 25 Feb 2019 23:42:47 -0800 (PST) X-Google-Smtp-Source: AHgI3IZXnEP20mRx4d2gC5KG3RBFrpkyKaWz6dXcjw+GKIKhDFokob94PCHlyu1P3fHns3Cq2X4A X-Received: by 2002:a63:455f:: with SMTP id u31mr14377935pgk.241.1551166967860; Mon, 25 Feb 2019 23:42:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551166967; cv=none; d=google.com; s=arc-20160816; b=0GM3q9kIZVnujDSy6uD7rW7F42IN8g+Bs9uXDvXK4tq9/jbPBjtoFBW6ClcNBlo1X0 D7PCQLhSvAjVBhWvNpyew4DvyUjJTilZadHqjc++4H6BM2NNOSotZHRSfaS7VNbFZMDu 9eJsYjfDmHo1MRzFsRxSncN1RVaQxs4bK3dnPhur5h4+fScNGzmZml6xzkXbhpUgWvFx 2afdLKvOl7Lo3QJNzvIovwKT5Qui72i6wUfXZoXzaCeGN2D6yraubLeIcLbkfXA/MHqU vYRzjXGK/bQPEfb0qgyG+UHQoN7tlHAVZMrvo6CgR2k/IcfyPiBbC7SdB3yYN3u6Xmpk riAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=WGRK7XUOculPeJLrz4JzavGSjbEwTXAS4iVpUNRRB/k=; b=HZT+K73G5pODKS4otr6Lc8hyFW9XQIxY+FdIe9n9lN2oxkyvTpe3M7V/dnaTyolO47 Eoi6no/YDcelLVETQT2KJe19cTzTVGikprPGVXkGhTsceTUSnIbzZtHTCa6SYaMbiGQ8 JTUT/WN61kQdOmju5+9YZuYM+Mc2H+eRVA9z4GfqiqsDONaTIKtAkCN+ecL62hMy08xF 7fKDR8QhcBt+xC6TKkpVSDqaxLDQiA7dnDC+ukmNbPMOSUXVaqPPo13FlHqkJJqiWkO0 bM2IQ9w678NrojxN8+feMzMg3hy4ZN21AjolMaT1nIQe0bPVOZ88+EgGwukcGG7qKZNk 1f4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=Mf9scPfn; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j9si10362224pgb.49.2019.02.25.23.42.32; Mon, 25 Feb 2019 23:42:47 -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=@c-s.fr header.s=mail header.b=Mf9scPfn; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727028AbfBZHlp (ORCPT + 99 others); Tue, 26 Feb 2019 02:41:45 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:31978 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725940AbfBZHlo (ORCPT ); Tue, 26 Feb 2019 02:41:44 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 447rNh1F9pz9v4sW; Tue, 26 Feb 2019 08:41:40 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=Mf9scPfn; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id Cd1Gi_BCb91v; Tue, 26 Feb 2019 08:41:40 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 447rNg73TSz9v4sS; Tue, 26 Feb 2019 08:41:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1551166900; bh=WGRK7XUOculPeJLrz4JzavGSjbEwTXAS4iVpUNRRB/k=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=Mf9scPfnJq09iY94lCFQ4KLoJsu5oZjihynYNCNo0d4O0zHKSHG2imdiP1aNhn1iT Ifj4GwyDtCF9LCXiD7brdSw9C+UzOdMC6wKC3+TeaD8qCDiHLMAbbKB/VZYammHSMJ odpD4WN1Bx8dRVCx8EjBema8ZUAKvwA40SLmBCFE= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id DBBD08B90F; Tue, 26 Feb 2019 08:41:40 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 3gTK6PjDqmLx; Tue, 26 Feb 2019 08:41:40 +0100 (CET) Received: from PO15451 (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id BEEB88B794; Tue, 26 Feb 2019 08:41:39 +0100 (CET) Subject: Re: [PATCH 1/5] mm/resource: return real error codes from walk failures To: Dave Hansen , linux-kernel@vger.kernel.org Cc: mhocko@suse.com, tiwai@suse.de, keith.busch@intel.com, linux-mm@kvack.org, paulus@samba.org, baiyaowei@cmss.chinamobile.com, zwisler@kernel.org, dave.jiang@intel.com, linux-nvdimm@lists.01.org, ying.huang@intel.com, bp@suse.de, thomas.lendacky@amd.com, jglisse@redhat.com, bhelgaas@google.com, dan.j.williams@intel.com, vishal.l.verma@intel.com, akpm@linux-foundation.org, fengguang.wu@intel.com, linuxppc-dev@lists.ozlabs.org References: <20190225185727.BCBD768C@viggo.jf.intel.com> <20190225185730.D8AA7812@viggo.jf.intel.com> From: Christophe Leroy Message-ID: <87f914ce-c9e8-7fc5-d048-702fa809013f@c-s.fr> Date: Tue, 26 Feb 2019 08:41:39 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <20190225185730.D8AA7812@viggo.jf.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 25/02/2019 à 19:57, Dave Hansen a écrit : > 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 > s, 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. > > This changes both the generic mm/ and powerpc-specific > implementations to have the same return value. > > Signed-off-by: Dave Hansen > Reviewed-by: Bjorn Helgaas > Acked-by: Michael Ellerman (powerpc) > 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: Yaowei Bai > Cc: Takashi Iwai > Cc: Jerome Glisse > Cc: Benjamin Herrenschmidt > Cc: Paul Mackerras > Cc: linuxppc-dev@lists.ozlabs.org > Cc: Keith Busch > --- > > b/arch/powerpc/mm/mem.c | 2 +- walk_system_ram_range() was droped in commit https://git.kernel.orghttps://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=26b523356f49a0117c8f9e32ca98aa6d6e496e1a Christophe > b/kernel/resource.c | 4 ++-- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff -puN arch/powerpc/mm/mem.c~memory-hotplug-walk_system_ram_range-returns-neg-1 arch/powerpc/mm/mem.c > --- a/arch/powerpc/mm/mem.c~memory-hotplug-walk_system_ram_range-returns-neg-1 2019-02-25 10:56:47.452908034 -0800 > +++ b/arch/powerpc/mm/mem.c 2019-02-25 10:56:47.458908034 -0800 > @@ -189,7 +189,7 @@ walk_system_ram_range(unsigned long star > struct memblock_region *reg; > unsigned long end_pfn = start_pfn + nr_pages; > unsigned long tstart, tend; > - int ret = -1; > + int ret = -EINVAL; > > for_each_memblock(memory, reg) { > tstart = max(start_pfn, memblock_region_memory_base_pfn(reg)); > 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-02-25 10:56:47.454908034 -0800 > +++ b/kernel/resource.c 2019-02-25 10:56:47.459908034 -0800 > @@ -382,7 +382,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)) { > @@ -462,7 +462,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; > _ >