Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp132980pxj; Thu, 13 May 2021 23:31:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwClvaosbouc7/6xeoKo6wfNm2tRKeUEJ2lKdFoq5NAoLVJUvRwyZ3K2zEeD2FFnknbMuuT X-Received: by 2002:a17:906:e294:: with SMTP id gg20mr8340246ejb.227.1620973882189; Thu, 13 May 2021 23:31:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620973882; cv=none; d=google.com; s=arc-20160816; b=jy7uoTGi06NWNmgIzD041AkqtkqI6zYUQlAcsB9ItlCEHXHBp9kl8MpYCmjiXypNtP XwXsy9L3rWt+RcFi7Bq4tXizxolorTG+9DZrY0Q65qyJ9BLoEmz0uVBD9icCBik+R0mO Jnp36SW4ukINSS5DadtQP6tYFP+/Dz4m8HWCbXZDJtC4TD4HSBqdjc0ePX7fJoHEjgMH GUH5DOPKdDBSvpyT74qNRNTP5nd3LbqYquVtMwnpLYkZ0EsRdIlDdaE4BviNTpLvUpkY MoOAWymrLE250mhC75BZzeK9maSdtA1LdVEhbflmI0ctEOMgpCO1C3uTwpEhH48B2zQ1 ub3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=OwwTQhJmis135h2e/5tJ0deA8bG2iYui/m7Amblho9s=; b=eydalu4LoorWWOl8DUY8mUmpXDesy+i/fEbTXXI2u5SXaAo1oRNLLlRc8z0+L4M2Jn OX/1cLau8w/FD/vKWdlMcc59my8hFt+7uQaajhSLr2CfD3f/oZfgeBnbEwg/0nZv57hQ akU6wl7Eg6OoHgpI5op/Hfc+r2m7SCSi8bO6B/qXzNaXRNiXEzIbQ09ym6HK8mkdTb2f JZ0DQWlmeagVzgl90GJPoK5H+eyKbZ3kUTY888KBZUKHvj/oMWCnl56hbSYEhyqt0Oyh yEweVnmQ8aE+dIOJhQIrUH32hlOUhJRh7+HwVWkQhRFcNa7BOMXlRHIzrPNAPEJ7j8gb xsKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="rGBA/HAp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si5476047edq.129.2021.05.13.23.30.46; Thu, 13 May 2021 23:31:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="rGBA/HAp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231567AbhEMSnI (ORCPT + 99 others); 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