Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2361357pxb; Mon, 19 Apr 2021 04:05:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwX16okMgk939Ve2FTSLJxwIQqDlwXziqlEx1IlvIjjk4sedGl4WMBLyWpyyjKKSTIB8B+/ X-Received: by 2002:a17:906:f41:: with SMTP id h1mr11624365ejj.399.1618830315077; Mon, 19 Apr 2021 04:05:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618830315; cv=none; d=google.com; s=arc-20160816; b=gn8h6M+/CMo6D4O9XRxhDIDrdExCIZnx2Iq9t/t0o8hT7vXkSvnII3CU9SEiKXNNvt Tz01m7Xoln2JVtDz7POlPwG5YG/mwfQr/zgTHyAjjbn/23p+EDGdmQ2a7M9TAG1smaRz kDsOwmIhKGzcahKGo7nAh3Z2OO8tiKZyhqycp/zxu0mXqeJjpPl5X/LRnoMC0wuaQm/Z WOBJ1IrbOYf+ESM2JiXXiyq3h+wW2MEzZBr5stzKCd4gJi1fdFsSvaoRkk467cTe+oNT n6DSW/T6DWcUA9jmIm3PVnl7EXM+bjPeRer6DXt5j8/QzKw0Fixh8oylCp3m2ELfGpLR WY2w== 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=PRVUsXJtxCSGU79myj+xSUaHJi7bhbn6ukYw6HlHFfc=; b=Bmtki+Hl9Q48Mk8466YJy//SWJrQoJ67LYNA50u6Iky3qwWjxbxrUFzxN+lzkq1vdI /LdF6WILIXAQ5GdMOfBUldBmP8RgPVsoukd6w1cdmvcC2sEMSPpl5s7g8zU/70YLf3qr Csd8gqPNyf+UTx2Crs8KSbc4IMa3zsgkAlpKNKDkB7x5u9Ohv4EjGIk6j2vmClnIxJIM dV7DDUr2ISkMfVFx8fW2Hf2vae6RO+zScaHb6UmcKQOcv+INZ1qYZTEmKzgv5tJJSeqr 3pfUIdOF35zbpC0mRECS6JlBxtmjIzfAu2xJa4c+ldOYory3U31kXyZ3bYNJIRhzuSMc Onig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IsU1wXQU; 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 v5si10552944ejq.224.2021.04.19.04.04.50; Mon, 19 Apr 2021 04:05:15 -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=IsU1wXQU; 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 S238589AbhDSLDl (ORCPT + 99 others); Mon, 19 Apr 2021 07:03:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:34676 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238312AbhDSLDe (ORCPT ); Mon, 19 Apr 2021 07:03:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6065861166; Mon, 19 Apr 2021 11:03:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618830185; bh=RV0J+qJN63RF1LfXGiWFf495q6N3XeBEcmKUPqxeYX8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IsU1wXQUTVtxIem2KUCCuXbCA/uWxFum4SiPeorW5cCpXigY/FeHXBRuD4IdXavS9 9LpCrbX89bgbFi8aTyw17BScWjf7O+EJTA87wqbb/6BumGZ08byhectiWljoXsyNuk OKI2TD/dL7OlySH4eqlsje4dVBHycN5F+cSgnfq0= Date: Mon, 19 Apr 2021 13:03:02 +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. How much time and memory is 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 I really don't like #ifdef in .c files. Any way to put this in the .h file instead like should be done properly? thanks, greg k-h