From patchwork Sun Feb 14 18:18:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dennis Zhou X-Patchwork-Id: 12087345 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=-17.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT 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 E0052C433DB for ; Sun, 14 Feb 2021 18:18:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5B97D61494 for ; Sun, 14 Feb 2021 18:18:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B97D61494 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 CA27B8D00D9; Sun, 14 Feb 2021 13:18:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C2CFF8D0060; Sun, 14 Feb 2021 13:18:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B1CE18D00D9; Sun, 14 Feb 2021 13:18:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0189.hostedemail.com [216.40.44.189]) by kanga.kvack.org (Postfix) with ESMTP id 9785D8D0060 for ; Sun, 14 Feb 2021 13:18:33 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 5BCD88149 for ; Sun, 14 Feb 2021 18:18:33 +0000 (UTC) X-FDA: 77817683706.26.yard70_250a9d627634 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id 3965C1804A311 for ; Sun, 14 Feb 2021 18:18:33 +0000 (UTC) X-HE-Tag: yard70_250a9d627634 X-Filterd-Recvd-Size: 5035 Received: from mail-io1-f46.google.com (mail-io1-f46.google.com [209.85.166.46]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Sun, 14 Feb 2021 18:18:32 +0000 (UTC) Received: by mail-io1-f46.google.com with SMTP id u20so4627307iot.9 for ; Sun, 14 Feb 2021 10:18:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Uhe7FNxfl3eAYbBDyrWuMB4meish9hrXfBwq41jpn7c=; b=RtdRt5C4ryjfNjWC/iY/bcho5U0FBxDIrYiBwphKKc9tkbVyLNtmX/0pDsxXeB7BnX DUsGAgubMA0+NaAVfA7bZ6opnBksXP/xdw4SiTgtmjZlcvYPkGl9dlymFqhIrvcH8IOj Np5QglHU7KblF/fkZ02K7Dk1wyvDGhn3ZLMPBOBWnBRM9xfO9djK32LKT1ybk0+MXpey 5qATeE9O1LMkgS3GDvNujNFUeyeeMHVnZzKtkirPD48VS2YvfW8i45Y/GHAP/Q6Icjws nGA7h/JOgwK6JH/VN2dOKIrM+u9qWlXWYibiUv0cJK29BG18OkeUiTXttMoWk6eT+r5e KVwg== X-Gm-Message-State: AOAM5311/AkVXpAfKm4Bild73ifJvzPb0TiM4271q6VTCLULamA8nUam HWJfA7+s05hd9jXXMsJ0n0s= X-Google-Smtp-Source: ABdhPJyHercrGg7WtnXSrJyU2wld6jg06HYiCyVQMWpDOJXDcmd/dvKQR5YvHnMBL/uDyRLnl4+bUA== X-Received: by 2002:a6b:c913:: with SMTP id z19mr10240609iof.60.1613326712269; Sun, 14 Feb 2021 10:18:32 -0800 (PST) Received: from abasin.c.googlers.com.com (243.199.238.35.bc.googleusercontent.com. [35.238.199.243]) by smtp.gmail.com with ESMTPSA id r9sm8309575ill.72.2021.02.14.10.18.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Feb 2021 10:18:31 -0800 (PST) From: Dennis Zhou To: Tejun Heo , Christoph Lameter , Arnd Bergmann Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dennis Zhou , kernel test robot , Nick Desaulniers Subject: [PATCH] percpu: fix clang modpost section mismatch Date: Sun, 14 Feb 2021 18:18:02 +0000 Message-Id: <20210214181802.896248-1-dennis@kernel.org> X-Mailer: git-send-email 2.30.0.478.g8a0d178c01-goog MIME-Version: 1.0 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: pcpu_build_alloc_info() is an __init function that makes a call to cpumask_clear_cpu(). With CONFIG_GCOV_PROFILE_ALL enabled, the inline heuristics are modified and such cpumask_clear_cpu() which is marked inline doesn't get inlined. Because it works on mask in __initdata, modpost throws a section mismatch error. Arnd sent a patch with the flatten attribute as an alternative [2]. I've added it to compiler_attributes.h. modpost complaint: WARNING: modpost: vmlinux.o(.text+0x735425): Section mismatch in reference from the function cpumask_clear_cpu() to the variable .init.data:pcpu_build_alloc_info.mask The function cpumask_clear_cpu() references the variable __initdata pcpu_build_alloc_info.mask. This is often because cpumask_clear_cpu lacks a __initdata annotation or the annotation of pcpu_build_alloc_info.mask is wrong. clang output: mm/percpu.c:2724:5: remark: cpumask_clear_cpu not inlined into pcpu_build_alloc_info because too costly to inline (cost=725, threshold=325) [-Rpass-missed=inline] [1] https://lore.kernel.org/linux-mm/202012220454.9F6Bkz9q-lkp@intel.com/ [2] https://lore.kernel.org/lkml/CAK8P3a2ZWfNeXKSm8K_SUhhwkor17jFo3xApLXjzfPqX0eUDUA@mail.gmail.com/ Reported-by: kernel test robot Cc: Arnd Bergmann Cc: Nick Desaulniers Signed-off-by: Dennis Zhou --- include/linux/compiler_attributes.h | 6 ++++++ mm/percpu.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h index ea5e04e75845..c043b8d2b17b 100644 --- a/include/linux/compiler_attributes.h +++ b/include/linux/compiler_attributes.h @@ -210,6 +210,12 @@ # define fallthrough do {} while (0) /* fallthrough */ #endif +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes + * clang: https://clang.llvm.org/docs/AttributeReference.html#flatten + */ +# define __flatten __attribute__((flatten)) + /* * Note the missing underscores. * diff --git a/mm/percpu.c b/mm/percpu.c index 80f8f885a990..6596a0a4286e 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -2663,7 +2663,7 @@ early_param("percpu_alloc", percpu_alloc_setup); * On success, pointer to the new allocation_info is returned. On * failure, ERR_PTR value is returned. */ -static struct pcpu_alloc_info * __init pcpu_build_alloc_info( +static struct pcpu_alloc_info * __init __flatten pcpu_build_alloc_info( size_t reserved_size, size_t dyn_size, size_t atom_size, pcpu_fc_cpu_distance_fn_t cpu_distance_fn)