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=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 B4491C433B4 for ; Thu, 13 May 2021 18:42:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 79D166100C for ; Thu, 13 May 2021 18:42:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231593AbhEMSnI (ORCPT ); Thu, 13 May 2021 14:43:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:38770 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231326AbhEMSnH (ORCPT ); Thu, 13 May 2021 14:43:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1C96E6100C; Thu, 13 May 2021 18:41:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620931316; bh=5LLelLIQygK+U6IAj1y8uyQ90yjIXf4BkwkxKjJGayI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rGBA/HAp+QKbShTL0cZPYwlAVfh3PAhdtEBd92G2pxGJnvMO3kQR3DuZUaM9Igo/d It5dGilVhp7yMHn4tQ5kJMkJhEp+E+ITWYNDI9/KrlTmi2Pcg9EkxvMnFiB/oPAyqh XHwJGF0/dmtUtZZH1x+JmMxMNzEMuYXzUNS/k2P0= Date: Thu, 13 May 2021 20:41:54 +0200 From: Greg Kroah-Hartman To: Rasmus Villemoes Cc: "Rafael J. Wysocki" , Andrzej Hajda , linux-kernel@vger.kernel.org Subject: Re: [PATCH] driver core: make device_set_deferred_probe_reason a no-op when !CONFIG_DEBUG_FS Message-ID: References: <20210419104256.1709253-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210419104256.1709253-1-linux@rasmusvillemoes.dk> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 19, 2021 at 12:42:56PM +0200, Rasmus Villemoes wrote: > When debugfs is not enabled, the deferred_probe_reason string is never > read. So there's no reason to spend time and memory on recording it. > > There's still a bunch of redundant kfree(NULL) calls and NULL > assignments, but this gives most of the benefit (avoiding two > vsnprintf() and a kmalloc()) for the minimal amount of ifdeffery. > > Signed-off-by: Rasmus Villemoes > --- > drivers/base/dd.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/base/dd.c b/drivers/base/dd.c > index 37a5e5f8b221..6a197336c6a4 100644 > --- a/drivers/base/dd.c > +++ b/drivers/base/dd.c > @@ -216,9 +216,13 @@ void device_unblock_probing(void) > * device_set_deferred_probe_reason() - Set defer probe reason message for device > * @dev: the pointer to the struct device > * @vaf: the pointer to va_format structure with message > + * > + * The ->deferred_probe_reason string is only ever read when debugfs > + * is enabled, so this is a no-op for !CONFIG_DEBUG_FS. > */ > void device_set_deferred_probe_reason(const struct device *dev, struct va_format *vaf) > { > +#ifdef CONFIG_DEBUG_FS > const char *drv = dev_driver_string(dev); > > mutex_lock(&deferred_probe_mutex); > @@ -227,6 +231,7 @@ void device_set_deferred_probe_reason(const struct device *dev, struct va_format > dev->p->deferred_probe_reason = kasprintf(GFP_KERNEL, "%s: %pV", drv, vaf); > > mutex_unlock(&deferred_probe_mutex); > +#endif Can you move the #ifdef to a .h file and do this properly instead of cutting up the function like this? thanks, greg k-h