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=-2.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 85CFAC1B0D9 for ; Sat, 12 Dec 2020 13:23:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E62C22D04 for ; Sat, 12 Dec 2020 13:23:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437051AbgLLNXN (ORCPT ); Sat, 12 Dec 2020 08:23:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405486AbgLLNXM (ORCPT ); Sat, 12 Dec 2020 08:23:12 -0500 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9548BC0613CF; Sat, 12 Dec 2020 05:22:31 -0800 (PST) Received: by mail-pg1-x534.google.com with SMTP id e2so9243934pgi.5; Sat, 12 Dec 2020 05:22:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=VTZpp0n/Om/Jf11Mz+DqRKpiaIjN4mJ897+taVy59Ug=; b=gs+DafSa6tm6ZhcmtOMAV2zOpZsgVdlfnJO3Cc8h6uZ7zEIkJ//kiGJiG610YJYd9c hi7RAK/gnCn0RzWdwMYCDo5iWNdBQbtvJKYrsQI5ZcoVP15/FlhWsHbcStHoxRpLv5K2 7tZggztOJ5OrWHKSc7C0B5gdsPwG3Jh4XQNGDZzJ5uC91i9eb/FOwSgLNZwxuhvbJlm1 NZRNGWscN+BvdnS2hdE/2kf8TIOM+A9TYoTVx3z4X0kR366gEuSlj/jqKKPOYQFh4Kj3 5afdtXgK8N3xa39LgKIpCZwsKgk5qgska42v8wTbiGBbB+guXeCE2Frkke6P3b+dq3Ir zifA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VTZpp0n/Om/Jf11Mz+DqRKpiaIjN4mJ897+taVy59Ug=; b=pY/+WAanhS/D2gAgGcR3GdmyLEtanMI1ofX81rIjiO5itib6Igqi+GYh2YCVafjMvB KAA4TMxqifgoSyzaKIwzvWK20KePSLT3LdqHKmcmhUuTV5nCkvWS88y02w+jpHCJCEEJ dnGi/VaLM85BOjREX0tDR4pVtzHIBJ36Nd6zcalYq/JPWrVnnMpT5jhsyO/rgvlseWcD Mm0pxRK89U34sdao1QUcClRD4gGKmFk6d07U8qi9Ax7UxwqPW6ftfPiHH2UyOcnwiYYv 4yNU9Tpb78BtqNWijRElZGiLzU7W50i1adnsxGE4SNKhyT7eUiuQqg4Ez0Go8u7Mp51p cZxQ== X-Gm-Message-State: AOAM530rAyNTuQBGBmDiNJyJaBunFOnxRCjtAcIaPhkXibM51y+jm7r0 5Mjix1V4MBfcnYRzsJYLc5qhf4DNC5zMBkS/MaeVfYbxnN89suRR X-Google-Smtp-Source: ABdhPJz6qkGZaIbcK80z8oNTbmCmaNucZ+fxbrx52JjiY59cFl32wS2FAI0NK0C4i2f9nCp4IxJVJq78J8uiblnFRTg= X-Received: by 2002:a05:6a00:170a:b029:19d:afca:4704 with SMTP id h10-20020a056a00170ab029019dafca4704mr15887538pfc.7.1607779350726; Sat, 12 Dec 2020 05:22:30 -0800 (PST) MIME-Version: 1.0 References: <20201210192536.118432146@linutronix.de> <20201210194042.860029489@linutronix.de> <87h7osgifc.fsf@nanos.tec.linutronix.de> <87360cgfol.fsf@nanos.tec.linutronix.de> In-Reply-To: <87360cgfol.fsf@nanos.tec.linutronix.de> From: Andy Shevchenko Date: Sat, 12 Dec 2020 15:22:14 +0200 Message-ID: Subject: Re: [patch 03/30] genirq: Move irq_set_lockdep_class() to core To: Thomas Gleixner Cc: LKML , Peter Zijlstra , Marc Zyngier , "James E.J. Bottomley" , Helge Deller , afzal mohammed , linux-parisc@vger.kernel.org, Russell King , linux-arm Mailing List , Mark Rutland , Catalin Marinas , Will Deacon , Christian Borntraeger , Heiko Carstens , linux-s390@vger.kernel.org, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , Pankaj Bharadiya , Chris Wilson , Wambui Karuga , intel-gfx , dri-devel , Tvrtko Ursulin , Linus Walleij , "open list:GPIO SUBSYSTEM" , Lee Jones , Jon Mason , Dave Jiang , Allen Hubbe , linux-ntb@googlegroups.com, Lorenzo Pieralisi , Rob Herring , Bjorn Helgaas , Michal Simek , linux-pci , Karthikeyan Mitran , Hou Zhiqiang , Tariq Toukan , "David S. Miller" , Jakub Kicinski , netdev , "open list:HFI1 DRIVER" , Saeed Mahameed , Leon Romanovsky , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , xen-devel@lists.xenproject.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Dec 12, 2020 at 12:07 AM Thomas Gleixner wrote: > > On Fri, Dec 11 2020 at 22:08, Thomas Gleixner wrote: > > > On Fri, Dec 11 2020 at 19:53, Andy Shevchenko wrote: > > > >> On Thu, Dec 10, 2020 at 10:14 PM Thomas Gleixner wrote: > >>> > >>> irq_set_lockdep_class() is used from modules and requires irq_to_desc() to > >>> be exported. Move it into the core code which lifts another requirement for > >>> the export. > >> > >> ... > >> > >>> + if (IS_ENABLED(CONFIG_LOCKDEP)) > >>> + __irq_set_lockdep_class(irq, lock_class, request_class); > > > > You are right. Let me fix that. > > No. I have to correct myself. You're wrong. > > The inline is evaluated in the compilation units which include that > header and because the function declaration is unconditional it is > happy. > > Now the optimizer stage makes the whole thing a NOOP if CONFIG_LOCKDEP=n > and thereby drops the reference to the function which makes it not > required for linking. > > So in the file where the function is implemented: > > #ifdef CONFIG_LOCKDEP > void __irq_set_lockdep_class(....) > { > } > #endif > > The whole block is either discarded because CONFIG_LOCKDEP is not > defined or compile if it is defined which makes it available for the > linker. > > And in the latter case the optimizer keeps the call in the inline (it > optimizes the condition away because it's always true). > > So in both cases the compiler and the linker are happy and everything > works as expected. > > It would fail if the header file had the following: > > #ifdef CONFIG_LOCKDEP > void __irq_set_lockdep_class(....); > #endif > > Because then it would complain about the missing function prototype when > it evaluates the inline. I understand that (that's why I put "if even no warning") and what I'm talking about is the purpose of IS_ENABLED(). It's usually good for compile testing !CONFIG_FOO cases. But here it seems inconsistent. The pattern I usually see in the cases like this is #ifdef CONFIG_LOCKDEP void __irq_set_lockdep_class(....); #else static inline void ... {} #endif and call it directly in the caller. It's not a big deal, so up to you. -- With Best Regards, Andy Shevchenko