Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1257358rdg; Fri, 13 Oct 2023 15:50:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF0xvFMFwuxZ5evbNKbuOO8n8T4vv2UfhpZFC4vFcVu2QnK0YMSYX6pnI11qonm4MW6ZYOQ X-Received: by 2002:a17:902:d4c9:b0:1c7:8345:f377 with SMTP id o9-20020a170902d4c900b001c78345f377mr29487999plg.29.1697237440504; Fri, 13 Oct 2023 15:50:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697237440; cv=none; d=google.com; s=arc-20160816; b=DdkcR9hpZrHf+cMjscKOOESI7ZFobR6LsZ3HIsXP9Hn20PpGS9VLj4p/X7HYzY6sQG MBc0XqUF0660BOAAozpKgigVDBeQuRC8z2d6m9sACgR9utUd1cr1tqqbtCx7Gv3xmMEh A2PzNnP2EIEUXORklOJBWzMf4VqPw2v9YlJf9ppc0JhNFlZFL4CPZIlDYbvVcM5UGPb5 D5e3iMlkhE6aiPmAIHFcruC47aSd0DKQUGU6hLNevjlhp1hDFnlldJVSNkedMEMTYf7l jkPteeWgmEjY4ahZ0fEltR/dXMylnz1O/0MuqvuGbWcXQLgy3no4dlOK2tHqWpcic9Mm K4xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=F7BOhkrkHITitY1j/kRDjansJLSo7hGc2Ealdbve1QE=; fh=z8A2UgI9Ozi/zM+meU3S7fSTeKB52ixSkA1q1cGr6xs=; b=MXYdJe+RkgV1y1MTFsO/FNrQiJbqiwbArecfea4BhSno3Jnd6dmMHBVKlPDvmO/xor 1Q+v8BT+PofP7mnvFcumGqepLwNeXq/bud0qCIMlR77cstSj/piA13+OyD5p20vQmjLw rf7npq0lGMJh7aqAtjulxkNWHmoM5FAIPloEc4pmwxJe7n86kPY0FXsDkEQ1e9y04xg/ ibxggk2vnFX59w0mIGOyGel8YjlO3WFdRaY8kpsNJQ7ZJWDyE8nC1EyzScbu24UwEr0L HJ1/tYgni8z16n8pyxIX0Yn0c+jD/UMqj4sB6gEbs2Q4HGghPa7Vi6jo3jF6gyWXr2Wq LPxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VJlRoAmU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id p11-20020a1709026b8b00b001bbb6f4cd6dsi5139103plk.334.2023.10.13.15.50.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 15:50:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VJlRoAmU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id A6FA083CCA58; Fri, 13 Oct 2023 15:50:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232647AbjJMWuL (ORCPT + 99 others); Fri, 13 Oct 2023 18:50:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232893AbjJMWti (ORCPT ); Fri, 13 Oct 2023 18:49:38 -0400 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54E6110DB; Fri, 13 Oct 2023 15:48:58 -0700 (PDT) Received: by mail-il1-x12d.google.com with SMTP id e9e14a558f8ab-35135b79b6aso9493165ab.0; Fri, 13 Oct 2023 15:48:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697237336; x=1697842136; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=F7BOhkrkHITitY1j/kRDjansJLSo7hGc2Ealdbve1QE=; b=VJlRoAmUB2NHCeDgw6hrA+8rl+t1G1pEKNxvMA2F6wOuEAqtJWKu/sQ5mnnXX3DLwj cpYglMg7aMmCzX7rwv7igWhbrjPgpsgpzUVtWDgpIN3nU2GkM8jo7kJ/O9CXyVy+AEy8 h8ZMNYdCmhzRgMtZPsNd6iJ322SfUzCanY3vML8AFFTJ5QH9x/NBvuIctELP+uH/hXIL DqjqI/LI32ujWeFONivAqFOt4XfLpnlChbtNbsLlBh2FszhwqSvEvoAF3vHS/6CmqP1b PH3Ds3ZiuYVPOBnhRrVcCDD6b7w3r+uoy+j5Cxjnh2vMzV8BCU7/OJI2iSX9G0EJ1GMY RZEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697237336; x=1697842136; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F7BOhkrkHITitY1j/kRDjansJLSo7hGc2Ealdbve1QE=; b=wM54W59ZPB2KaFwGr9vJBECzojc17K3kMFa1e3rJ72zLf1aKqfeMzxbiXKMOSxkpu9 H29tpprT5x2EL5Djj2tX/4jTK9nMx3EeB389HWlIvp+ZnELzhSQwhfMbbUv6hPwIs0tr Zb5vxezxFRoKZA0o4mlsoVWSpFqgGxKh9KzeNoPbP9zJnvVM2n9Q56f+r2vM8i5gHXwx /A8QYBh+Gt+xLw8DRrKfkHIX20l2ofLFp0X71j12SqqZQtuajanqI8n/Q/b7YYHwZCUn KRbWP1zKJJYhbrarxTiFWv3QXHXVhQaVmxwKfxUWRwvbB6mX8Tsf3swxIypER5qBgDaA vElw== X-Gm-Message-State: AOJu0YxT55INUtgcG891g2ROXoIS7OZLGSVVLX8yICrEgcKj0ynUmyI0 7eVBRyX8J+ftol5u64chwZoTQ9f7oqw+7w== X-Received: by 2002:a92:c56e:0:b0:351:50f1:1f98 with SMTP id b14-20020a92c56e000000b0035150f11f98mr31025480ilj.32.1697237335751; Fri, 13 Oct 2023 15:48:55 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id t10-20020a92dc0a000000b003512c3e8809sm1683071iln.71.2023.10.13.15.48.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 15:48:55 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: lb@semihalf.com, linux@rasmusvillemoes.dk, joe@perches.com, mcgrof@kernel.org, daniel.vetter@ffwll.ch, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, groeck@google.com, yanivt@google.com, bleung@google.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v7b 21/25] dyndbg: refactor *dynamic_emit_prefix Date: Fri, 13 Oct 2023 16:48:13 -0600 Message-ID: <20231013224818.3456409-22-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231013224818.3456409-1-jim.cromie@gmail.com> References: <20231013224818.3456409-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 13 Oct 2023 15:50:34 -0700 (PDT) Refactor the split of duties between outer & inner fns. The outer fn was previously just an inline unlikely forward to inner, which did all the work. Now, outer handles +t and +l flags itself, and calls inner only when _DPRINTK_FLAGS_INCL_LOOKUP is needed. No functional change. But it does make the results of the inner-fn more cache-friendly (fewer entries, reused more often): 1- no spurious [TID] or noise 2- no LINE-number to bloat the cache (avg 9 pr_debugs/fn) 3- only LOOKUP stuff Currently LOOKUPs are descriptor-field refs but could be replaced by accessor functions. This would allow the __dyndbg_sites section to be de-duplicated and reclaimed; currently module, filename fields are ~90% repeated. As the accessors get more expensive, the value of caching part of the prefix goes up. Also change inner-fn to return count of extra chars written to the buffer, and drop "inline" from outer, let the compiler decide. Maybe also change name accordingly. Signed-off-by: Jim Cromie --- fixup whitespace --- lib/dynamic_debug.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 17eefb35ac96..5825b58043a6 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -777,11 +777,28 @@ static int remaining(int wrote) return 0; } -static char *__dynamic_emit_prefix(const struct _ddebug *desc, char *buf) +static int __dynamic_emit_prefix(const struct _ddebug *desc, char *buf, int pos) +{ + if (desc->flags & _DPRINTK_FLAGS_INCL_MODNAME) + pos += snprintf(buf + pos, remaining(pos), "%s:", + desc->modname); + if (desc->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) + pos += snprintf(buf + pos, remaining(pos), "%s:", + desc->function); + if (desc->flags & _DPRINTK_FLAGS_INCL_SOURCENAME) + pos += snprintf(buf + pos, remaining(pos), "%s:", + trim_prefix(desc->filename)); + return pos; +} + +static char *dynamic_emit_prefix(struct _ddebug *desc, char *buf) { int pos_after_tid; int pos = 0; + if (likely(!(desc->flags & _DPRINTK_FLAGS_INCL_ANY))) + return buf; + if (desc->flags & _DPRINTK_FLAGS_INCL_TID) { if (in_interrupt()) pos += snprintf(buf + pos, remaining(pos), " "); @@ -790,15 +807,10 @@ static char *__dynamic_emit_prefix(const struct _ddebug *desc, char *buf) task_pid_vnr(current)); } pos_after_tid = pos; - if (desc->flags & _DPRINTK_FLAGS_INCL_MODNAME) - pos += snprintf(buf + pos, remaining(pos), "%s:", - desc->modname); - if (desc->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) - pos += snprintf(buf + pos, remaining(pos), "%s:", - desc->function); - if (desc->flags & _DPRINTK_FLAGS_INCL_SOURCENAME) - pos += snprintf(buf + pos, remaining(pos), "%s:", - trim_prefix(desc->filename)); + + if (unlikely(desc->flags & _DPRINTK_FLAGS_INCL_LOOKUP)) + pos += __dynamic_emit_prefix(desc, buf, pos); + if (desc->flags & _DPRINTK_FLAGS_INCL_LINENO) pos += snprintf(buf + pos, remaining(pos), "%d:", desc->lineno); @@ -810,13 +822,6 @@ static char *__dynamic_emit_prefix(const struct _ddebug *desc, char *buf) return buf; } -static inline char *dynamic_emit_prefix(struct _ddebug *desc, char *buf) -{ - if (unlikely(desc->flags & _DPRINTK_FLAGS_INCL_ANY)) - return __dynamic_emit_prefix(desc, buf); - return buf; -} - void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) { va_list args; -- 2.41.0