lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191128120121.GL26807@dhcp22.suse.cz>
Date:   Thu, 28 Nov 2019 13:01:21 +0100
From:   Michal Hocko <mhocko@...nel.org>
To:     David Hildenbrand <david@...hat.com>
Cc:     linux-kernel@...r.kernel.org, linux-mm@...ck.org,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "Rafael J. Wysocki" <rafael@...nel.org>,
        Oscar Salvador <osalvador@...e.de>,
        Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH v1] drivers/base/node.c: get rid of get_nid_for_pfn()

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 <david@...hat.com>
> >> 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 <gregkh@...uxfoundation.org>
> >> Cc: "Rafael J. Wysocki" <rafael@...nel.org>
> >> Cc: Michal Hocko <mhocko@...nel.org>
> >> Cc: Oscar Salvador <osalvador@...e.de>
> >> Cc: Andrew Morton <akpm@...ux-foundation.org>
> >> Signed-off-by: David Hildenbrand <david@...hat.com>
> > 
> > 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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ