Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp7054957ybf; Fri, 6 Mar 2020 09:28:48 -0800 (PST) X-Google-Smtp-Source: ADFU+vvzNYfimDrG/pzkJgfA0NfoTmvNUGS4CEiApd97ozX2WXMfr+PyD/zmbfdkEbpOwRChW/97 X-Received: by 2002:a9d:443:: with SMTP id 61mr3119747otc.357.1583515728059; Fri, 06 Mar 2020 09:28:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583515728; cv=none; d=google.com; s=arc-20160816; b=lnvd8/+PbxjoWeFQ06vD5O+wkwysthC6L71P8C7pAyWAg8w1qDGe1xuAzcg8dHt9Y/ FVOJ+Q1fcQNPp/Vz0pQrZpW1MsDFxUlxPwTKz0wasJZOW/Yv1yXI98ApKTTNO+nxrgdk js9I42qwMJ3Fe6u1rIFPHiP0mkn2iNcjI7OTaJkiFGCuYU8eLCde67YpbPI4ozQE8Pv1 apKuDNG4Ul7+L7hvLhK7G6oaZDn2UI/liAWyebk7571HzqbDKrM+0u4fMQFjAU/n6hHk BKAc8scbP8mmf1YiQ33+1F2WTom+zPDSi7wbkFIR/XYU9P7FYiZfanMt/yHVBPy+mCP1 Pa6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=/C1NA7fdflpuC9P015wS8x7xj/wZzw6IwsoP22v5Bgg=; b=JlVMUCIGHBHt3m4gN+QSnpqXTgVrndOgxyb44+phKJFMjEMgwi3Oos2Bq/1fEAWRGR wkXSwKTDqWIRtjkzLim1eGhQCUP3CudogdisJJYbKBWXJ2KmPCpyelq0ssOlUBcspCA7 +jLmUb4Byw8EiWVuvCNiMKmy5VBlJrvZRfyHj2E3c4CMRZUPKcx1walEQsmNmeyokJai NxaGmVURlu8o3aSYmQ0UvjhLzg/3Xesi9srKkrUyqKpPJcsZ+DTold1/LwKp9ywUyaQc L94gZWW0If87oMtyvdf+UWJGqF++e9tX7nqa52z+BC3sqIJLmaiRMFDp8a7M+wKf3wUC J9RQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l23si1783696otj.144.2020.03.06.09.28.35; Fri, 06 Mar 2020 09:28:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726171AbgCFR1H (ORCPT + 99 others); Fri, 6 Mar 2020 12:27:07 -0500 Received: from smtprelay0133.hostedemail.com ([216.40.44.133]:60088 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725873AbgCFR1H (ORCPT ); Fri, 6 Mar 2020 12:27:07 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay04.hostedemail.com (Postfix) with ESMTP id 5A66D1802929C; Fri, 6 Mar 2020 17:27:06 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,,RULES_HIT:41:355:379:599:800:960:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2693:2828:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:4321:5007:7808:7903:8660:10004:10400:10848:11026:11232:11473:11658:11914:12043:12297:12438:12663:12740:12760:12895:13148:13230:13439:14096:14097:14181:14659:14721:21080:21433:21450:21451:21627:21660:21939:30054:30070:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: iron26_5add7c5902505 X-Filterd-Recvd-Size: 3551 Received: from XPS-9350.home (unknown [47.151.143.254]) (Authenticated sender: joe@perches.com) by omf06.hostedemail.com (Postfix) with ESMTPA; Fri, 6 Mar 2020 17:27:04 +0000 (UTC) Message-ID: Subject: Re: [PATCH] sched/cputime: silence a -Wunused-function warning From: Joe Perches To: Nick Desaulniers , Qian Cai Cc: Peter Zijlstra , Ingo Molnar , juri.lelli@redhat.com, Vincent Guittot , dietmar.eggemann@arm.com, Steven Rostedt , bsegall@google.com, mgorman@suse.de, LKML , clang-built-linux Date: Fri, 06 Mar 2020 09:25:29 -0800 In-Reply-To: References: <1583509304-28508-1-git-send-email-cai@lca.pw> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.34.1-2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2020-03-06 at 09:13 -0800, Nick Desaulniers wrote: > On Fri, Mar 6, 2020 at 7:42 AM Qian Cai wrote: > > account_other_time() is only used when CONFIG_IRQ_TIME_ACCOUNTING=y (in > > irqtime_account_process_tick()) or CONFIG_VIRT_CPU_ACCOUNTING_GEN=y (in > > get_vtime_delta()). When both are off, it will generate a compilation > > warning from Clang, > > > > kernel/sched/cputime.c:255:19: warning: unused function > > 'account_other_time' [-Wunused-function] > > static inline u64 account_other_time(u64 max) > > > > Rather than wrapping around this function with a macro expression, > > > > if defined(CONFIG_IRQ_TIME_ACCOUNTING) || \ > > defined(CONFIG_VIRT_CPU_ACCOUNTING_GEN) > > > > just use __maybe_unused for this small function which seems like a good > > trade-off. > > Generally, I'm not a fan of __maybe_unused. It is a tool in the > toolbox for solving this issue, but it's my least favorite. Should > the call sites be eliminated, this may mask an unused and entirely > dead function from being removed. Preprocessor guards based on config > give more context into *why* a particular function may be unused. > > So let's take a look at the call sites of account_other_time(). Looks > like irqtime_account_process_tick() (guarded by > CONFIG_IRQ_TIME_ACCOUNTING) and get_vtime_delta() (guarded by > CONFIG_VIRT_CPU_ACCOUNTING_GEN). If it were one config guard, then I > would prefer to move the definition to be within the same guard, just > before the function definition that calls it, but we have a more > complicated case here. > > The next thing I'd check to see is if there's a dependency between > configs. In this case, both CONFIG_IRQ_TIME_ACCOUNTING and > CONFIG_VIRT_CPU_ACCOUNTING_GEN are defined in init/Kconfig. In this > case there's also no dependency between configs, so specifying one > doesn't imply the other; so guarding on one of the two configs is also > not an option. > > So, as much as I'm not a fan of __maybe_unused, it is indeed the > simplest option. Though, I'd still prefer the ifdef you describe > instead, maybe the maintainers can provide guidance/preference? Another option might be to move static inline functions where possible to an #include file (like sched.h) but the same possible dead function issue would still exist.