Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1702847pxb; Fri, 26 Feb 2021 19:45:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJzpa4OnVOF5nEGpyQ8V2zCCEwOjPH+H4lwAtBvNAMyg1C92jpbdmz4snN3eJmEyJgYc/Nqz X-Received: by 2002:a17:906:2ed7:: with SMTP id s23mr73493eji.363.1614397534074; Fri, 26 Feb 2021 19:45:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614397534; cv=none; d=google.com; s=arc-20160816; b=ZSx9IaUIorYncqH3ZEIpS8Q4imuhRU+BItwD0emWqxdcF10JddZ/H5XEoWHK+0K44X 2EzK7BCL4Eyc5Yiw9r0c1A6V5UApr+Ac9FtOKib0X8a7IYVY/cbAZpOdwasYa8jyi9Vf wMcWkh/ov6YkNiek970MpmF/KCpekOk3XPsHGyL01f+Oy28tpFauT35F3+B7mQGcHr4s ZX8qI5VAp7HvQtht5HQm2alHaYtGxZhSO2u/hxC+QQlSRejc9zRD4xkMyJ0HjRjuyD0t 3Yyw3yYLFWfvbmE+tNA4jJJ/HyzEilJz6w0mY0Vw+i8LsZyoLY1fagqljnT5ryQjMRSR hEIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=keonSni5KzT7UNGp5t1reqV6Ec+MJb82Tsofpm8Ddmo=; b=KrW7u9O8UVfCfKM5wobROe919yxSFEfgSgPtJInn5XG08Uh0DawcDAJ0fP6Yixj5nV wrijX98JXOnL36REr687wNOY2LBcMwhgSjZoWxJRq7Ng525fgcBRDoiqQPGJXT0ju37N xyQgpGHkqdlsJlnfKuekoyUsHfNB0d05Gl3BkLtrT+jOh731+BU01OlrAu+fjVvsQf3x AanaGjsQcyszpYZXRNV+Om+PsanMwlMJLdrBii1LO8Nhxg+mkHptBiQLJVyykUH9mdu0 yvzUBbk8peY/MqYtK2x06RSzzJHGrrHKLW+SdbaVVIrjwSim2Lli0fO69NUqJDQgP5/9 pH8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="o/Oi/OZE"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y14si4914929edt.78.2021.02.26.19.45.11; Fri, 26 Feb 2021 19:45:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="o/Oi/OZE"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230132AbhB0Dml (ORCPT + 99 others); Fri, 26 Feb 2021 22:42:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229863AbhB0Dmj (ORCPT ); Fri, 26 Feb 2021 22:42:39 -0500 Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B7B8C06174A for ; Fri, 26 Feb 2021 19:41:59 -0800 (PST) Received: by mail-oi1-x234.google.com with SMTP id f3so11902253oiw.13 for ; Fri, 26 Feb 2021 19:41:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=keonSni5KzT7UNGp5t1reqV6Ec+MJb82Tsofpm8Ddmo=; b=o/Oi/OZEBr1wYPbH//Ig77KhLPp5QbU8WPaaEyV1jEXkPBLklDV9wudeAACSsML3VW NL1TUtXJGBQw05mVwdpt306XdlVoj8R3WOJo3W0X3thuq6F2PiLN2UpgzAurfFUFp0AF bepBCcfur/l7TOwB9XXEIJeYNj5/ogzm6asRR1NJ7q2a1UerZDIU9BmDxyqXztUUfF8/ LwN0pPFcRIP+L70MVy2VgyPtxNOCqAcx0Ubl+U2qmxeGwh7yaV6obb6p6bM39424pCxg C+ayptOfbpUaQKYldAKFRcfCEmdfpbQVv0x8NQMB2A+sLHxlEZtT2vKnLgfUaaSst9WM rPSw== 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:in-reply-to:message-id :references:user-agent:mime-version; bh=keonSni5KzT7UNGp5t1reqV6Ec+MJb82Tsofpm8Ddmo=; b=cxBZ5KwJpmnV9M/besOpAo8/2yZKV6IUOJg7/yGSzIFaPr80PDMSdgXSZ4M5lZFDrq 4CMrajuzHWq6aGCPbsJiZVcZPveAsv0VhyLgWQTLETqoOwoUUWzaUzwt/fiYoCJE6zqH kReT0dlWvoo2W5Do5CpGoJJ74sAiUDa60PiQJsrLbsBOHoa0jOh17kvQAPjZEjB1NC+s QxhsIpcY3vUZESJ/26nAe/Da/MLj72jJrDVxSfTO4A+t+xMHdytirPYEm7rHLxYYh+jA 72wSKHCb7tJoFA9/HbXKBrps78JsIqjucHA9RzxwXzd56WDR6RgtDq5vTfoBIhpnSpx+ mHIA== X-Gm-Message-State: AOAM531/mXaEkx1vZYQVxJBgINtyqDcPBul3Ia4tJpufLeO5yuYnCAcb 63ahNC1HvBEArJai9cla2McyAg== X-Received: by 2002:aca:b655:: with SMTP id g82mr4457116oif.91.1614397318187; Fri, 26 Feb 2021 19:41:58 -0800 (PST) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id u190sm513434oif.40.2021.02.26.19.41.56 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Fri, 26 Feb 2021 19:41:57 -0800 (PST) Date: Fri, 26 Feb 2021 19:41:40 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Palmer Dabbelt cc: hughd@google.com, akpm@linux-foundation.org, atishp@atishpatra.org, peterz@infradead.org, srikar@linux.vnet.ibm.com, valentin.schneider@arm.com, vbabka@suse.cz, mpe@ellerman.id.au, linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel-team@android.com, kirill.shutemov@linux.intel.com Subject: Re: [PATCH 1/2] mm: Guard a use of node_reclaim_distance with CONFIFG_NUMA In-Reply-To: Message-ID: References: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 26 Feb 2021, Palmer Dabbelt wrote: > On Fri, 26 Feb 2021 17:31:40 PST (-0800), hughd@google.com wrote: > > On Fri, 26 Feb 2021, Andrew Morton wrote: > > > On Fri, 26 Feb 2021 12:17:20 -0800 Palmer Dabbelt > > > wrote: > > > > From: Palmer Dabbelt > > > > > > > > This is only useful under CONFIG_NUMA. IIUC skipping the check is the > > > > right thing to do here, as without CONFIG_NUMA there will never be any > > > > large node distances on non-NUMA systems. > > > > > > > > I expected this to manifest as a link failure under (!CONFIG_NUMA && > > > > CONFIG_TRANSPARENT_HUGE_PAGES), but I'm not actually seeing that. I > > > > think the reference is just getting pruned before it's checked, but I > > > > didn't get that from reading the code so I'm worried I'm missing > > > > something. > > > > > > > > Either way, this is necessary to guard the definition of > > > > node_reclaim_distance with CONFIG_NUMA. > > > > > > > > Signed-off-by: Palmer Dabbelt > > > > --- > > > > mm/khugepaged.c | 2 ++ > > > > 1 file changed, 2 insertions(+) > > > > > > > > diff --git a/mm/khugepaged.c b/mm/khugepaged.c > > > > index a7d6cb912b05..b1bf191c3a54 100644 > > > > --- a/mm/khugepaged.c > > > > +++ b/mm/khugepaged.c > > > > @@ -819,8 +819,10 @@ static bool khugepaged_scan_abort(int nid) > > > > for (i = 0; i < MAX_NUMNODES; i++) { > > > > if (!khugepaged_node_load[i]) > > > > continue; > > > > +#ifdef CONFIG_NUMA > > > > if (node_distance(nid, i) > node_reclaim_distance) > > > > return true; > > > > +#endif > > > > } > > > > return false; > > > > } > > > > > > This makes the entire loop a no-op. Perhaps Kirill can help take a > > > look at removing unnecessary code in khugepaged.c when CONFIG_NUMA=n? > > > > First lines of khugepaged_scan_abort() say > > if (!node_reclaim_mode) > > return false; > > > > And include/linux/swap.h says > > #ifdef CONFIG_NUMA > > extern int node_reclaim_mode; > > extern int sysctl_min_unmapped_ratio; > > extern int sysctl_min_slab_ratio; > > #else > > #define node_reclaim_mode 0 > > #endif > > > > So, no need for an #ifdef CONFIG_NUMA inside khugepaged_scan_abort(). > > Ah, thanks, I hadn't seen that. That certainly explains the lack of an > undefined reference. > > That said: do we generally rely on DCE to prune references to undefined > symbols? This particular one seems like it'd get reliably deleted, but it > seems like a fragile thing to do in general. This kind of stuff would > certainly make some code easier to write, though. Yes, the kernel build very much depends on the optimizer eliminating dead code, in many many places. We do prefer to keep the #ifdefs to the header files as much as possible. > > I don't really care all that much, though, as I was just sending this along > due to some build failure report from a user that I couldn't reproduce. It > looked like they had some out-of-tree stuff, so in this case I'm fine on > fixing this being their problem. I didn't see your 2/2 at the time; but wouldn't be surprised if that needs 1/2, to avoid an error on undeclared node_reclaim_distance before the optimizer comes into play. If so, best just to drop 2/2 too. Hugh