From mboxrd@z Thu Jan 1 00:00:00 1970 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.0 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no 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 4AE35C00A89 for ; Tue, 3 Nov 2020 00:59:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9C05322275 for ; Tue, 3 Nov 2020 00:59:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Q4JfR/lH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C05322275 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B60AC6B005C; Mon, 2 Nov 2020 19:59:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B10F46B005D; Mon, 2 Nov 2020 19:59:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A021B6B0068; Mon, 2 Nov 2020 19:59:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0161.hostedemail.com [216.40.44.161]) by kanga.kvack.org (Postfix) with ESMTP id 73F166B005C for ; Mon, 2 Nov 2020 19:59:47 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 1189B362A for ; Tue, 3 Nov 2020 00:59:47 +0000 (UTC) X-FDA: 77441299614.10.chain50_24175bf272b4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id D344A16A4AD for ; Tue, 3 Nov 2020 00:59:46 +0000 (UTC) X-HE-Tag: chain50_24175bf272b4 X-Filterd-Recvd-Size: 4278 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Tue, 3 Nov 2020 00:59:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description; bh=JODZqgf7epPmRUkZJ3AczglKxk8wx5PqqY64iJeRXts=; b=Q4JfR/lHX1plng3aJrFExSJ0ul c1cUnjoSTa+dxSLQySbKpEKMwTg1THmEvphmJ7OE9XCQnUVToV4Efofzo1P5fUCFX0eaWztVZIoUA H3RJwAZAVu8UXFLLWVWKkhEDyksVcnLdjutqpOTwhb7QrA0cDmbekvz6zw5UtOeFTzcc9NlBs/ruo +RX4T4+kfs0DpyRc2eYoLqIqm0ckeyRYs8ovz2ZCUECFffQ3z1R14I+W2+uokWDiM4W8ECuVQ+LSv sase/9WU4PPQiggWrvCuwnScMoE5VVhkEilJaE5D6Ow0mbUAg+bgITzX/qW8OoUF7lqvaboQen3Ne WovzHE7A==; Received: from [2601:1c0:6280:3f0::60d5] by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZkfg-0002hy-Sv; Tue, 03 Nov 2020 00:59:37 +0000 Subject: Re: [PATCH] x86/mm: Fix phys_to_target_node() export To: Dan Williams , Christoph Hellwig Cc: Andrew Morton , Thomas Gleixner , kernel test robot , Joao Martins , X86 ML , Linux MM , linux-nvdimm References: <160402498564.4173389.2743697400148832021.stgit@dwillia2-desk3.amr.corp.intel.com> <20201031091012.GA27844@infradead.org> From: Randy Dunlap Message-ID: <5b7fbe34-225f-4265-a368-5336ad5a16c1@infradead.org> Date: Mon, 2 Nov 2020 16:59:31 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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 11/2/20 3:52 PM, Dan Williams wrote: > On Sat, Oct 31, 2020 at 2:10 AM Christoph Hellwig wrote: >> >> On Thu, Oct 29, 2020 at 07:29:45PM -0700, Dan Williams wrote: >>> The core-mm has a default __weak implementation of phys_to_target_node() >>> when the architecture does not override it. That symbol is exported >>> for modules. However, while the export in mm/memory_hotplug.c exported >>> the symbol in the configuration cases of: >> >> Which just means that we should never export weak symbols. So instead >> of hacking around this introduce a symbol that indicates that the >> architecture impements phys_to_target_node, and don't defined it at all >> in common code for that case. > > So I agree with this, but it made me realize that the way > memory_add_physaddr_to_nid() was defined as an exported weak symbol is > similarly broken. > >>> --- a/mm/memory_hotplug.c >>> +++ b/mm/memory_hotplug.c >>> @@ -365,9 +365,14 @@ int __weak phys_to_target_node(u64 start) >>> start); >>> return 0; >>> } >>> + >>> +/* If the arch did not export a strong symbol, export the weak one. */ >>> +#ifndef CONFIG_NUMA_KEEP_MEMINFO >>> EXPORT_SYMBOL_GPL(phys_to_target_node); >>> #endif >>> >>> +#endif >> >> i.e. move the ifdef to include the actual phys_to_target_node >> definition, and remove the __weak from it here. > > The trick is finding an arch common way to pick up the presence of the > phys_to_target_node() override, and it still has the wart of ifdefery > in C code. > > I went a bit deeper and moved all the fallback routines to > linux/numa.h and the overrides in all archs that care to > asm/sparsemem.h. Note that asm/sparsemem.h was not my first choice, > but it happened to be where powerpc was already defining its > phys-addr-to-node-id infrastructure, and my first choice header, > asm/numa.h, is not universally available. > > The attached patch is going through some kbuild-robot exposure to make > sure I did not break anything else. > Works for me. Thanks. Acked-by: Randy Dunlap # build-tested -- ~Randy