Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1775381ybd; Thu, 27 Jun 2019 01:11:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBwz16J8qP9vicyg7knQ2GQi3X2GeWOtDImbhHHKMmNpAP7CoqF4MJD/XhNfMSIkWlxXA3 X-Received: by 2002:a17:902:30a3:: with SMTP id v32mr3197461plb.6.1561623099373; Thu, 27 Jun 2019 01:11:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561623099; cv=none; d=google.com; s=arc-20160816; b=BOfFIDU6j2W6ahNAyk7hpHW0yngWmGeC1+H/VEYsw586wz4RTrGds/NnSj9gdbWuwj KQkEu8oCImxzcyEKE1BZW+gEbI5MdgLAOPUv7nFNaIUnjnFJDldRmVSkr/sshot4SA0G pSadpSk27IMFITu3LepSKSXuufRdkDZvacYEC+rIPYHuJKrj5bM/p/BKgzXP9C9/EHGQ MiBZtTcOK0o4fYzyca5oMBuk3+Jqwq3azzdKjmNJWMZcxboS/MJy62kPuUQS8ES4TmOg 0WoGOpEkWPOlHZZ5Pk5KY1Fd71eghSSDkDwg6tAn5deRIZUliVRhQY9wiRGlTK5zk0FZ /xhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=OvkpaT13+U9RC+12hlu8+eTrBlFQ6hiinJeT+5oS8VA=; b=mXIAokoN/S6K+9m5c7BVLh2YQQ/Mkh7AZ96G3HQd0bILCZEzF+NSl59ND4d7YW3htV 7tcoUCaXvW+MGhCTJQXhyZRTe3OdjUZ9ASf7P2ocyIXWD2E/0ncLW6zZ2wbJtSX69zq8 02tSAQYolh/WDcCg8g8SvXe17EPEMgRFHtQY2Srf0kcy9gRYaJi3YWscxHKgHX1kBPS8 GzipMu62oT0GBUUenZrhmPyKFXMSF1re5YZ54NRIBm9MQReX16f6hHfDxnF0jHm7o+zj EfcvTaG2lJcHdQ2Y9GqruGtaH9AS8Z14jhX22lcYFJpyNsbG7+CuBPl5NMU/qzq0PpYX NAzA== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bg10si581739plb.160.2019.06.27.01.11.20; Thu, 27 Jun 2019 01:11:39 -0700 (PDT) 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726480AbfF0IKc (ORCPT + 99 others); Thu, 27 Jun 2019 04:10:32 -0400 Received: from mx2.suse.de ([195.135.220.15]:44610 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726293AbfF0IKc (ORCPT ); Thu, 27 Jun 2019 04:10:32 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CEFC3AF3E; Thu, 27 Jun 2019 08:10:30 +0000 (UTC) Date: Thu, 27 Jun 2019 10:10:29 +0200 From: Michal Hocko To: Alastair D'Silva Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Andrew Morton , Pavel Tatashin , Oscar Salvador , Mike Rapoport , Baoquan He , Wei Yang , Logan Gunthorpe , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2 1/3] mm: Trigger bug on if a section is not found in __section_nr Message-ID: <20190627080724.GK17798@dhcp22.suse.cz> References: <20190626061124.16013-1-alastair@au1.ibm.com> <20190626061124.16013-2-alastair@au1.ibm.com> <20190626062113.GF17798@dhcp22.suse.cz> <20190626065751.GK17798@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 27-06-19 10:50:57, Alastair D'Silva wrote: > On Wed, 2019-06-26 at 08:57 +0200, Michal Hocko wrote: > > On Wed 26-06-19 16:27:30, Alastair D'Silva wrote: > > > On Wed, 2019-06-26 at 08:21 +0200, Michal Hocko wrote: > > > > On Wed 26-06-19 16:11:21, Alastair D'Silva wrote: > > > > > From: Alastair D'Silva > > > > > > > > > > If a memory section comes in where the physical address is > > > > > greater > > > > > than > > > > > that which is managed by the kernel, this function would not > > > > > trigger the > > > > > bug and instead return a bogus section number. > > > > > > > > > > This patch tracks whether the section was actually found, and > > > > > triggers the > > > > > bug if not. > > > > > > > > Why do we want/need that? In other words the changelog should > > > > contina > > > > WHY and WHAT. This one contains only the later one. > > > > > > > > > > Thanks, I'll update the comment. > > > > > > During driver development, I tried adding peristent memory at a > > > memory > > > address that exceeded the maximum permissable address for the > > > platform. > > > > > > This caused __section_nr to silently return bogus section numbers, > > > rather than complaining. > > > > OK, I see, but is an additional code worth it for the non-development > > case? I mean why should we be testing for something that shouldn't > > happen normally? Is it too easy to get things wrong or what is the > > underlying reason to change it now? > > > > It took me a while to identify what the problem was - having the BUG_ON > would have saved me a few hours. > > I'm happy to just have the BUG_ON 'nd drop the new error return (I > added that in response to Mike Rapoport's comment that the original > patch would still return a bogus section number). Well, BUG_ON is about the worst way to handle an incorrect input. You really do not want to put a production environment down just because there is a bug in a driver, right? There are still many {VM_}BUG_ONs in the tree and there is a general trend to get rid of many of them rather than adding new ones. Now back to your patch. You are adding an error handling where we simply do not expect invalid data. This is often the case for the core kernel functionality because we do expect consumers of the code to do the right thing. E.g. __section_nr already takes a pointer to struct section which assumes that this core data structure is already valid. Adding a check here adds an unnecessary overhead so this doesn't really sound like a good idea to me. -- Michal Hocko SUSE Labs