Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp732877pxy; Wed, 21 Apr 2021 13:39:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzG/aYbdStTlE4vugA73a46k1kQlx2/Q6Oo2q1ybWTM2iMFCxh/2PUYlIYpCnDX39vBu0Yo X-Received: by 2002:a05:6402:781:: with SMTP id d1mr18780673edy.32.1619037585527; Wed, 21 Apr 2021 13:39:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619037585; cv=none; d=google.com; s=arc-20160816; b=Uy95NEMGcT4ErGsDQKMIussFC3K8y6i+Rb2ZQN/CNG2QAnGq6e1Qu4e1tbGD5aV2GQ JVZchMfTb3j6ipOOJL7EJxoxHedCruZLofXULEwBeFAqO4mA8JG/1Zh9YOYWa25Ucv/k YGeQ4hDEeQzXSeFSUaBu6eHlf11IIticFlsy2vFFvPoWh7xtV8ZMWTTBcHDFDkaPAQ9w 6MJOl25Wro5rw/je9+UcsMpVv8wnIyczva1SIhR0jkHLsCgi+WCFdywK9TAfn8YkZ8hI 86gL5FBWAJ1IS7XptSCQeaJEu4VKHoA1EuKIYanSUjHBXACzs/NO6QTlXkXnu8YoHwUw ufvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=pColakFL/oD6K5w+4xc6suN1o6M2SKI7M9jsjcF6vq0=; b=ep3zueDQh2+7HWLMmDKPxGPc2ivWs3A/5S2G0Dwh4HdOstWBnGwp5gs4MQH+5saULJ HlSm52vz/8uIAtLU20kPJRPqgc8W/3MI9ZD9hzRsmNXdovDytU69vYwfSPzre2ivmNRz YTobO2G8OFKAuwNMQi2Ml80X/TS5yQ3WGve1CzlA0LYTfwiMg8QWQ+C7cZYU97o6adc1 ycr1fptnFstmu7aHJtuJbHeOLAOOE0El1YtVbhosXt4C3lc843wrnT1f9OXY2sovl7Ny L59eFI0mBidEs1vqB+Ph0r1fbLSuozmLTLS3xeX3ZEiGgXMOr/f9ClPiItSb6Fh76nzq xZtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=fAbQ2AqO; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp26si290128ejc.209.2021.04.21.13.39.22; Wed, 21 Apr 2021 13:39:45 -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=@rasmusvillemoes.dk header.s=google header.b=fAbQ2AqO; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243669AbhDUOvJ (ORCPT + 99 others); Wed, 21 Apr 2021 10:51:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243648AbhDUOvH (ORCPT ); Wed, 21 Apr 2021 10:51:07 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2FB9C06174A for ; Wed, 21 Apr 2021 07:50:33 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id u17so63966391ejk.2 for ; Wed, 21 Apr 2021 07:50:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=pColakFL/oD6K5w+4xc6suN1o6M2SKI7M9jsjcF6vq0=; b=fAbQ2AqOrYqvKXyGWn9XD5FfGB7HkD07jpWKW4+MtWRrotpDkK7HIF6Ws0AW7uxiIW VVnG7IElrZskcVceebo/ZYeLNkBtRln4j4h08fME/SPlnpPsgFQc+BeaNeaV8FtyFota ZaHkw9qHtE8HDZEtrgZ5S5YfS0LVWDv+EbgoI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=pColakFL/oD6K5w+4xc6suN1o6M2SKI7M9jsjcF6vq0=; b=XF5u0HtmPAaicT2dty2/aCTGjMIos7Z02vMTUCBYdaaSegb2LzCfmNAgFhBF3mtftH nM61sW8Nsvu9lU5DY/Ap+woMzxjDk3mjxN6Qlp3kXlLPlWTL4Qf4D+p0ULS3oSb8XD7/ 02KdD/XHxoUyWp3XbEdiC8Wbec0OWOq+TaS6U+FqX3N5UQJ3jCerTS+v6K/eXMmWi2BO lsrJB8vLZL6zlrrNbzfcOwBZXMEuNd6iDPgZXT5rQqjoS5OhlKFpwaU2DiXz9Di55WPk iouRJAdo3XlMF283bwkKE4sFVrNr+z0PPVk1xxRruHnW7UCLhlVtFP/vCI5+iP3gHuoZ wZ6A== X-Gm-Message-State: AOAM530tSdQMRQmGznyqef6Phg7KS82crdtP0eCmsDdWj2KMO7+JmMYo HudPBNt2QrrySny3ShsLI7akzg== X-Received: by 2002:a17:906:3f88:: with SMTP id b8mr33884788ejj.36.1619016632659; Wed, 21 Apr 2021 07:50:32 -0700 (PDT) Received: from [192.168.1.149] ([80.208.71.248]) by smtp.gmail.com with ESMTPSA id f19sm2790726ejc.54.2021.04.21.07.50.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 21 Apr 2021 07:50:32 -0700 (PDT) Subject: Re: [PATCH][RFC] tracing: Enable tracepoints via module parameters To: Steven Rostedt Cc: Dan Williams , "fweisbec@gmail.com" , "jeyu@kernel.org" , "mathieu.desnoyers@efficios.com" , "linux-kernel@vger.kernel.org" , "mingo@elte.hu" , "chris@chris-wilson.co.uk" , "yuanhan.liu@linux.intel.com" , "Grumbach, Emmanuel" References: <1299622684.20306.77.camel@gandalf.stny.rr.com> <877hc64klm.fsf@rustcorp.com.au> <20130813111442.632f3421@gandalf.local.home> <87siybk8yl.fsf@rustcorp.com.au> <20130814233228.778f25d0@gandalf.local.home> <77a6e40b57df092d1bd8967305906a210f286111.camel@intel.com> <20210419181111.5eb582e8@gandalf.local.home> <20210420085532.4062b15e@gandalf.local.home> <20210420163243.45293c9a@gandalf.local.home> <5d191e26-bd00-c338-e366-b4855ac08053@rasmusvillemoes.dk> <20210421102008.411af7c5@gandalf.local.home> From: Rasmus Villemoes Message-ID: <7d971eef-72bc-db32-e6a3-26e94b1b4236@rasmusvillemoes.dk> Date: Wed, 21 Apr 2021 16:50:30 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210421102008.411af7c5@gandalf.local.home> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21/04/2021 16.20, Steven Rostedt wrote: > On Wed, 21 Apr 2021 09:30:01 +0200 > Rasmus Villemoes wrote: > >> On 20/04/2021 22.32, Steven Rostedt wrote: >>> /* vsnprintf() will not append null for zero-length strings */ >>> if (ret == 0) >>> buf[0] = '\0'; >> >> Wrong. snprintf(buf, 16, "") will work just fine and cause a '\0' to be >> written to buf[0]. As will snprintf(buf, 16, "%s", ""), and any other >> case where there ends up being no characters printed. > > I just cut and pasted the bpf_trace_printk() code and modified it for here. OK, thanks for the pointer, lemme go write a patch to remove that bogosity before it gets cargo-culted further. > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/trace/bpf_trace.c#n404 > >>> >>> #define dev_dbg(dev, fmt, ...) \ >>> do { \ >>> if (trace_dev_dbg_printk_enabled()) \ >>> __dev_dbg(dev, fmt, ##__VA_ARGS__); \ >>> } while (0) >>> >>> Note, the "trace_dev_dbg_printk_enabled()" is a static branch, which means >>> it is a nop when the dev_dbg_printk tracepoint is not enabled, and is a jmp >>> to the __dev_dbg() logic when it is enabled. It's not a conditional branch. >> >> dynamic_debug has been implemented in terms of static_keys for a long >> time. And that's a per-dev_dbg invocation static key. IIUC, the above >> would cause every single dev_dbg in the kernel to pass through the "grab >> a raw spin lock and do the snprintf" thing even when one is just >> interested in the dev_dbgs inside a single driver or function. > > If you want to make it per device, I'm sure three's a way. Or allocate a > per-cpu buffer for the sprintf storage, and then you only need to disable > interrupts. And if you make the storage 4 levels deep per CPU (like > trace_printk does), then you only need to disable preemption and not even > interrupts. > > The above wasn't a patch submission. It was a proof of concept. Everything > you brought up can be trivially dealt with. I don't "want" anything. I just fail to see what advantage that proof of concept would bring over the current dev_dbg implementation. Rasmus