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.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,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 0659FC433E4 for ; Wed, 15 Jul 2020 12:32:13 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C504A206E9 for ; Wed, 15 Jul 2020 12:32:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hci2ehJE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C504A206E9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=w0zl1sw/EJ3ySh9Dkehlrpd8bPVo+6C4lff7jj/Pi+s=; b=hci2ehJE46GBrG2YRT7pvyswn e0KF8siaffWMxoS0qtpoXaSN7R831VSmK+6TPXOmhtWXtlwJfJnke3UDiK9pw70T5cVtvIYr7PziZ cC5zcD17XxYC4azlRE0a3E7KFiLWMIr1K7H8flZieHGCoWE0ddDdNUrbyu1+UDR5a1xZ1PU1jZ+bW A9hqTSHj162/UI9S0IR+vZQqm6cRRFoN+Ws06lhw7L6QAPqmKU6FxORzWE9/9/4TrKjo1eQ+ekl9a 1BTNC9oUap/2GA+qPoWQuDEXqdKaLP+0Nn2Sc8JuvZje+6rYWXlVWrZEusaFyNYP7I0wP7jr/Otd/ tUgfMFX+A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvgYf-0000xk-Sh; Wed, 15 Jul 2020 12:30:45 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvgYd-0000w9-CB for linux-arm-kernel@lists.infradead.org; Wed, 15 Jul 2020 12:30:44 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 10B5130E; Wed, 15 Jul 2020 05:30:40 -0700 (PDT) Received: from [10.57.32.45] (unknown [10.57.32.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 847AC3F66E; Wed, 15 Jul 2020 05:30:38 -0700 (PDT) Subject: Re: [PATCH 09/13] cpufreq: acpi-cpufreq: Remove unused ID structs To: Lee Jones , "Rafael J. Wysocki" References: <20200714145049.2496163-10-lee.jones@linaro.org> <20200714210340.GJ1398296@dell> <20200715032442.gh2cliiddhv35fdj@vireshk-i7> <20200715032718.2zlo2eurhkpoayya@vireshk-i7> <20200715113433.GB3165313@dell> <20200715115029.GC3165313@dell> <20200715121657.GE3165313@dell> From: Robin Murphy Message-ID: <4ba45e6b-7c49-7a7b-ae76-12d912629e4d@arm.com> Date: Wed, 15 Jul 2020 13:30:36 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200715121657.GE3165313@dell> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200715_083043_528448_17C34137 X-CRM114-Status: GOOD ( 29.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Denis Sadykov , Linux PM , Viresh Kumar , "Rafael J. Wysocki" , Linux Kernel Mailing List , Paul Diefenbaugh , Linux ARM , Dominik Brodowski Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2020-07-15 13:16, Lee Jones wrote: > On Wed, 15 Jul 2020, Rafael J. Wysocki wrote: > >> On Wed, Jul 15, 2020 at 1:50 PM Lee Jones wrote: >>> >>> On Wed, 15 Jul 2020, Rafael J. Wysocki wrote: >>> >>>> On Wed, Jul 15, 2020 at 1:34 PM Lee Jones wrote: >>>>> >>>>> On Wed, 15 Jul 2020, Rafael J. Wysocki wrote: >>>>> >>>>>> On Wed, Jul 15, 2020 at 5:27 AM Viresh Kumar wrote: >>>>>>> >>>>>>> On 15-07-20, 08:54, Viresh Kumar wrote: >>>>>>>> On 14-07-20, 22:03, Lee Jones wrote: >>>>>>>>> On Tue, 14 Jul 2020, Rafael J. Wysocki wrote: >>>>>>>>> >>>>>>>>>> On Tue, Jul 14, 2020 at 4:51 PM Lee Jones wrote: >>>>>>>>>>> >>>>>>>>>>> Can't see them being used anywhere and the compiler doesn't complain >>>>>>>>>>> that they're missing, so ... >>>>>>>>>> >>>>>>>>>> Aren't they needed for automatic module loading in certain configurations? >>>>>>>>> >>>>>>>>> Any idea how that works, or where the code is for that? >>>>>>>> >>>>>>>> The MODULE_DEVICE_TABLE() thingy creates a map of vendor-id, >>>>>>>> product-id that the kernel keeps after boot (and so there is no static >>>>>>>> reference of it for the compiler), later when a device is hotplugged >>>>>>>> into the kernel it refers to the map to find the related driver for it >>>>>>>> and loads it if it isn't already loaded. >>>>>>>> >>>>>>>> This has some of it, search for MODULE_DEVICE_TABLE() in it. >>>>>>>> Documentation/driver-api/usb/hotplug.rst >>>>>>> >>>>>>> And you just need to add __maybe_unused to them to suppress the >>>>>>> warning. >>>>>> >>>>>> Wouldn't that cause the compiler to optimize them away if it doesn't >>>>>> see any users? >>>>> >>>>> It looks like they're only unused when !MODULE, >>>> >>>> OK >>>> >>>>> in which case optimising them away would be the correct thing to do, no? >>> >>> It would be good if someone with a little more knowledge could provide >>> a second opinion though. I would think (hope) that the compiler would >>> be smart enough to see when its actually in use. After all, it is the >>> compiler that places the information into the device table. >>> >> If that is not the case, then the MODULE_DEVICE_TABLE() magic is >>> broken and will need fixing. >> >> I'm not sure why that would be the case? > > Nor me. In fact, take a look at my latest email. I think I just > proved out that it's not broken. The warning is valid and > MODULE_DEVICE_TABLE() appears to work just as it should. I won't claim to be an expert at all, but... For !MODULE, MODULE_DEVICE_TABLE() expands to nothing, so after preprocessing the static variable is literally unreferenced. Otherwise, MODULE_DEVICE_TABLE() emits an extern declaration of another variable which is defined via the "alias" attribute to refer to the symbol of the static variable. Thus the compiler presumably has to treat it as potentially accessible from other compilation units such that it can't be optimised away. >>> Removing boiler-plate is good, but not at the expense of obfuscation. >> >> I'm not following you here to be honest. > > Never mind. It's no longer important. > >> BTW, I'm wondering if removing the "static" modifier from the >> definitions of the structures in question makes the warnings you want >> to get rid of go away. > > I'm sure that it would. But that just alludes to the fact that the > tables may be in use elsewhere, which in the case of !MODULE is > untrue. That's probably more of a hack than using __maybe_unused. Right, that just ends up with someone sending another patch changing it back to shut up "variable foo was not declared, should it be static?" warnings from Sparse ;) Robin. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel