Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA2D9C432C0 for ; Thu, 28 Nov 2019 12:01:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A2AB32084D for ; Thu, 28 Nov 2019 12:01:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2AB32084D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3B9466B0525; Thu, 28 Nov 2019 07:01:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 36A056B0526; Thu, 28 Nov 2019 07:01:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A7126B0527; Thu, 28 Nov 2019 07:01:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0061.hostedemail.com [216.40.44.61]) by kanga.kvack.org (Postfix) with ESMTP id 1286B6B0525 for ; Thu, 28 Nov 2019 07:01:26 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id BEF152476 for ; Thu, 28 Nov 2019 12:01:25 +0000 (UTC) X-FDA: 76205546130.03.unit02_469f9e4aabd29 X-HE-Tag: unit02_469f9e4aabd29 X-Filterd-Recvd-Size: 4878 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Thu, 28 Nov 2019 12:01:25 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id s14so4576780wmh.4 for ; Thu, 28 Nov 2019 04:01:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=x+ZPcKqtkDfuCFJU9X4A+4eWzs0Y9EwU+RIvA4jfhmI=; b=Oc4dpt5zAPJ0lqcoiQllokKj/nIILClNxfguIFsJRInUEfiZPywDPHAaIbeZZ7f6n4 2mpAhE9acQX9GziGzGqXDRQ64ZzEN1t5tkJV0iH+bsaGw4jAV8BkYoYMvA1HW4WLuUAb FZsVzAw3amJljaCHFw51QWea3Oe5dwJknJtTm+IjoItwFRyNAdM/+zCoampq+QHHCz/g /ORiRdEX/rhwH/qX94/57KvWIhjNbxrdgkXRvtpAUZvZngxLeqXGPlC+/SNEBWNHBWWV lE2ZA9pfZF/LqA7egmCIFq+ZbiQjDU9uJscz7dJt13YY/G0kHaYdBARItwrVHN0NnSEN UttQ== X-Gm-Message-State: APjAAAX74YKoauGWRBwxgUtbR7R5JLwWYPJsml5k83zTcpb1jvzTB/9r E/q0FX9CjTbstudAQaUNDbE= X-Google-Smtp-Source: APXvYqwlSTr1gJjZOtmXNwoyOTPrCKLdd89moEKk18AxOv5EqnRPkYNyia2krUAaIi5brv5PrIcOLw== X-Received: by 2002:a1c:610b:: with SMTP id v11mr9082613wmb.156.1574942483551; Thu, 28 Nov 2019 04:01:23 -0800 (PST) Received: from localhost (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id m9sm22149062wro.66.2019.11.28.04.01.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 04:01:22 -0800 (PST) Date: Thu, 28 Nov 2019 13:01:21 +0100 From: Michal Hocko To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Greg Kroah-Hartman , "Rafael J. Wysocki" , Oscar Salvador , Andrew Morton Subject: Re: [PATCH v1] drivers/base/node.c: get rid of get_nid_for_pfn() Message-ID: <20191128120121.GL26807@dhcp22.suse.cz> References: <20191128102051.GI26807@dhcp22.suse.cz> <5E2F5866-0605-4DD2-9AEA-4B1C44E57D9F@redhat.com> <20191128115021.GJ26807@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) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu 28-11-19 12:52:16, David Hildenbrand wrote: > On 28.11.19 12:50, Michal Hocko wrote: > > On Thu 28-11-19 12:23:08, David Hildenbrand wrote: > > [...] > >> >From fc13fd540a1702592e389e821f6266098e41e2bd Mon Sep 17 00:00:00 2001 > >> From: David Hildenbrand > >> Date: Wed, 27 Nov 2019 16:18:42 +0100 > >> Subject: [PATCH] drivers/base/node.c: optimize get_nid_for_pfn() > >> > >> Since commit d84f2f5a7552 ("drivers/base/node.c: simplify > >> unregister_memory_block_under_nodes()") we only have a single user of > >> get_nid_for_pfn(). The remaining user calls this function when booting - > >> where all added memory is online. > >> > >> Make it clearer that this function should only be used during boot ( > >> e.g., calling it on offline memory would be bad) by renaming the > >> function to something meaningful, optimize out the ifdef and the additional > >> system_state check, and add a comment why CONFIG_DEFERRED_STRUCT_PAGE_INIT > >> handling is in place at all. > >> > >> Also, optimize the call site. There is no need to check against > >> page_nid < 0 - it will never match the nid (nid >= 0). > >> > >> Cc: Greg Kroah-Hartman > >> Cc: "Rafael J. Wysocki" > >> Cc: Michal Hocko > >> Cc: Oscar Salvador > >> Cc: Andrew Morton > >> Signed-off-by: David Hildenbrand > > > > Yes this looks much better! I am not sure this will pass all weird > > config combinations because IS_ENABLED will not hide early_pfn_to_nid > > from the early compiler stages so it might complain. But if this passes > > 0day compile scrutiny then this is much much better. If not then we just > > have to use ifdef which is a minor thing. > > The compiler should optimize out > > if (0) > code > > and therefore never link to early_pfn_to_nid. You are right, but there is a catch. The optimization phase is much later than the syntactic check so if the code doesn't make sense for the syntactic point of view then it will complain. This is a notable difference to #ifdef which just removes the whole block in the preprocessor phase. -- Michal Hocko SUSE Labs