Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp295949pxb; Thu, 30 Sep 2021 06:19:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwVKJO97dgcOdZYw3kxE9va22faf6D3OG9yUG1xHzIH0RGu5VIjRD3Gnr2i7xaM/MLgIHP X-Received: by 2002:a17:90b:e08:: with SMTP id ge8mr11840949pjb.157.1633007975169; Thu, 30 Sep 2021 06:19:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633007975; cv=none; d=google.com; s=arc-20160816; b=b/q5GX+yYMunXTo98uEOJGCfU7BvLarvhFQ8CJBc9nV8lLDI1il99zDdVMxQGdFVX8 03GEZ/c566L15ttOwUZXDDO7M2dvnAbzQpB+vQ6CmaVpNVaSSh6Veb4ls2QatxOI/EHW jdcoM121HzTiMDI5fhkThdukWGY37su2yxwMBmmZfeYwwjAg1tgOucb+teUQ61wVecCZ 9hy5EqMXA9zAFMwTGTRruoIPukVMcY6bzr6xtYzHk4Q34zGDOny5p6/s37VbJTRGKrjp MT7sgJWF0bPagz/h4y9H5f0kmx2tElKDntG8/vXYmN7ktLT5C2CqQsW2TYly7DrnAs0A ZqTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature:dkim-filter; bh=QTVmnlg4EXLgMNWGaqhRXsGICBaozUUHczJ1G+1ORRY=; b=XHPLHRUqn63aSsJBXzkB/w91JZU/XTn5f6hFyoogZWpGXw/1QJBzLkiX5BRM3l6leZ fCN8bFro9Q9W6KPbXA2X9SbB5nsVMX5NuvAenxTI7bj5qvzS+fNFTU+JOnp/wMHgUdxs +ApXlFGsn4GzDfJLJhfuuj1daCgDQbpCZVSQJISE83tlrDXL4OeL6BPQO7ynAhlreZeb bjlOSMvLAXnzHN4p+iC9TQG0cP0tVfUpB3m37DKsD0EiMPX2Ixo63jYMZkaF6SM2UPks iSJiGHmymqP6Ch5Z1eqCfd7vVEu8HIAx7EAvicdhVHrZdFE9ISXksaqH2cyS1YHjUI/r rJ4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=D33rLXJO; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p11si3574976pls.365.2021.09.30.06.19.17; Thu, 30 Sep 2021 06:19:35 -0700 (PDT) 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=@nifty.com header.s=dec2015msa header.b=D33rLXJO; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351078AbhI3Msl (ORCPT + 99 others); Thu, 30 Sep 2021 08:48:41 -0400 Received: from conssluserg-03.nifty.com ([210.131.2.82]:50937 "EHLO conssluserg-03.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349794AbhI3Msk (ORCPT ); Thu, 30 Sep 2021 08:48:40 -0400 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (authenticated) by conssluserg-03.nifty.com with ESMTP id 18UCkUsI031268; Thu, 30 Sep 2021 21:46:31 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-03.nifty.com 18UCkUsI031268 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1633005991; bh=QTVmnlg4EXLgMNWGaqhRXsGICBaozUUHczJ1G+1ORRY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=D33rLXJOw70Lqc/bx5R09SiHYnqukGKFFrxXGSdRtJ/9+Fn+kNo9ScxJrpyQcCVOM rH9wOhmGwe79sWJbRI4qX+A0RADYSsAviBlDz9UbOh+7K3qfJyeAHcSOMyaMwf1Cnz XQqevDoRbnKkP+7ts1DBHIuRyOuoUOYbCotYCoZ//3ZbxOSgQq20OjX5x4q2erkFgA Tpc2VhxBIyIBTCUNJ1nTkj4l/F4doW+KwGAy8wZZnkiWnR8NjstETbhLRXipCEEsVu XiMwiTNvn6DbseeelapnulpgJ1OPymLeCo4plhiaSSWVD4Gap0E36ddLW2Tpp7R9Ze IjXCYATtosEVg== X-Nifty-SrcIP: [209.85.214.175] Received: by mail-pl1-f175.google.com with SMTP id t4so3947641plo.0; Thu, 30 Sep 2021 05:46:31 -0700 (PDT) X-Gm-Message-State: AOAM533vg4etZygjbmuEvvhftMnrXu/ehjB5nVnBn0BO02GxtLN5mscc 5yq8EKopRd/KkAiFH+GkX2dYpSHms6scsHweuyY= X-Received: by 2002:a17:90a:4414:: with SMTP id s20mr6243842pjg.144.1633005990304; Thu, 30 Sep 2021 05:46:30 -0700 (PDT) MIME-Version: 1.0 References: <20210929225850.3889950-1-ndesaulniers@google.com> In-Reply-To: From: Masahiro Yamada Date: Thu, 30 Sep 2021 21:45:53 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] modpost: add allow list for llvm IPSCCP To: Nick Desaulniers Cc: Linus Torvalds , Arnd Bergmann , Kees Cook , Nathan Chancellor , Michal Marek , Linux Kbuild mailing list , Linux Kernel Mailing List , llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 30, 2021 at 9:19 AM Nick Desaulniers wrote: > > On Wed, Sep 29, 2021 at 4:28 PM Linus Torvalds > wrote: > > > > On Wed, Sep 29, 2021 at 3:59 PM Nick Desaulniers > > wrote: > > > > > > +static const struct secref_exception secref_allowlist[] = { > > > + { .fromsym = "__first_node", .tosym = "numa_nodes_parsed" }, > > > + { .fromsym = "__next_node", .tosym = "numa_nodes_parsed" }, > > > + { .fromsym = "__nodes_weight", .tosym = "numa_nodes_parsed" }, > > > + { .fromsym = "early_get_smp_config", .tosym = "x86_init" }, > > > + { .fromsym = "test_bit", .tosym = "numa_nodes_parsed" }, > > > +}; > > Thanks for your feedback. This has been a long-standing issue with no > clear path forward; I was looking forward to your input. > > > > > This list is basically made-up and random. > > Definitely brittle. And it contains checks that are specific to > basically one set of configs for one arch. It sucks to pay that cost > for unaffected architectures. > > > Why did those functions not get inlined? > > $ make LLVM=1 -j72 allmodconfig > $ make LLVM=1 -j72 arch/x86/mm/amdtopology.o KCFLAGS=-Rpass-missed=inline. > ... > arch/x86/mm/amdtopology.c:110:7: remark: 'test_bit' not inlined into > 'amd_numa_init' because too costly to inline (cost=115, threshold=45) > [-Rpass-missed=inline] > if (node_isset(nodeid, numa_nodes_parsed)) { > ^ > arch/x86/mm/amdtopology.c:157:7: remark: '__nodes_weight' not inlined > into 'amd_numa_init' because too costly to inline (cost=60, > threshold=45) [-Rpass-missed=inline] > if (!nodes_weight(numa_nodes_parsed)) > ^ > arch/x86/mm/amdtopology.c:171:2: remark: 'early_get_smp_config' not > inlined into 'amd_numa_init' because too costly to inline (cost=85, > threshold=45) [-Rpass-missed=inline] > early_get_smp_config(); > ^ > arch/x86/mm/amdtopology.c:178:2: remark: '__first_node' not inlined > into 'amd_numa_init' because too costly to inline (cost=70, > threshold=45) [-Rpass-missed=inline] > for_each_node_mask(i, numa_nodes_parsed) > ^ > arch/x86/mm/amdtopology.c:178:2: remark: '__next_node' not inlined > into 'amd_numa_init' because too costly to inline (cost=95, > threshold=45) [-Rpass-missed=inline] > > > ie. for allmodconfig, the sanitizers add too much instrumentation to > the callees that they become too large to be considered profitable to > inline by the cost model. Note that LLVM's inliner works bottom up, > not top down. > > Though for the defconfig case...somehow the cost is more than with the > sanitizers... > > arch/x86/mm/amdtopology.c:157:7: remark: '__nodes_weight' not inlined > into 'amd_numa_init' because too costly to inline (cost=930, > threshold=45) [-Rpass-missed=inline] > if (!nodes_weight(numa_nodes_parsed)) > ^ > > Looking at the output of `make LLVM=1 -j72 > arch/x86/mm/amdtopology.ll`, @__nodes_weight is just some inline asm > (.altinstructions). I wonder if I need to teach the cost model about > `asm inline`... > > For the allmodconfig build it looks like `__nodes_weight` calls > `__bitmap_weight` and the code coverage runtime hooks. > > > Wouldn't it be better to make > > them always-inline? > > Perhaps, see what that might look like: > https://github.com/ClangBuiltLinux/linux/issues/1302#issuecomment-807260475 > Does that look better? > > > Or, like in at least the early_get_smp_config() case, just make it be > > marked __init, so that if it doesn't get inlined it gets the right > > section? > > In the case of early_get_smp_config(), that's what Boris suggested: > https://lore.kernel.org/lkml/20210225114533.GA380@zn.tnic/ __init works particularly for early_get_smp_config(). For static line helpers that are called from __init and non-__init functions, maybe __ref will work. In my understanding, the .ref.text section is not free'd, but modpost bypasses the section mismatch checks. I am not sure what is a better approach for generic cases, __always_inline, __ref, or what else? I am not a big fan of this patch, at least... (The reason was already stated by Linus) -- Best Regards Masahiro Yamada