Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3944057rdg; Wed, 18 Oct 2023 10:09:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+9QNp+dRYp+MmNyM72JkfMpPcKHRU5c6PQUETcVO797DnPzSqUjbINndT23kYqSwYLwJI X-Received: by 2002:a17:902:82cc:b0:1c0:774d:9342 with SMTP id u12-20020a17090282cc00b001c0774d9342mr5667144plz.25.1697648941384; Wed, 18 Oct 2023 10:09:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697648941; cv=none; d=google.com; s=arc-20160816; b=PB02JlBdrNJo4Hi133mpb6VHrobe6m76rwNSOGevrjRxHOmXlQ6pgGXhAiPnOglqqt qmcpEVaIp8kLf4XDr4Lc1EpbAjQnuzLscFgLnAxj1h8prI++1qN+fThRnF4KZw5KENjr 3cN8F4qFbxqmn9jZU1V6Yb2Ph0aDKskQ+K4GAClxJFFUKaBedFNy52Mc9LC+sfxG2iAn QQS+wOtBEsSn/MgT+0AJxPi0Y9/ZMmiFyp1Cc27XMmX9Py5ryFBMC3VVrQX0YjGW+hGf b8hZTjUZWvCEFa67O/NDHtULYBNN5mxzT21Zns0hZF3rvGjQCaKUc4A9sw/BtlyVwWgi Bo7Q== 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=m1uXLDmoVzvN2oJUe3cXywX9ZoHLJ5owNDwFWfeTZCY=; fh=dD4hpA3+YqlszWEwFTO+ADczjyhU7P27niWnWgZXhCU=; b=kdgL90/Kf5/F4SJ3/2JRTMl/Xbix+B7tMwbobP1GcsVG7sdakhbaK4B/sV+yr0tXIx XDT8m0542ZToKRyUXgw1qBT82JhOryrqg6V9bgJxW1cZQQfJHZIvIEM2gHsWaXvDWd4x zjddtZH93//GbPQnyA3D0s3QwGjibNWfxZ/jPva1EpVtuCPhPWxEsz/BIMhKJQXN99Zl /ogOD8nIeJILkdaOXXA4w4+N1+rrnnc15//ZsRq1Bs/RXuVD5m85G2OTwRZYtnq/ySuG potfqdPNV/fQhfvmO9nsHwQgVdj8rOJ2sWIMMEuvZgHCqYeIsAXXiYwLVZ1/w3eijlui Md4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VlaYJLnC; 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 f13-20020a170902684d00b001c589ba4a1bsi298222pln.83.2023.10.18.10.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 10:09:01 -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=VlaYJLnC; 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 9166E80DBE33; Wed, 18 Oct 2023 10:08: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 S232038AbjJRRHb (ORCPT + 99 others); Wed, 18 Oct 2023 13:07:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229924AbjJRRHK (ORCPT ); Wed, 18 Oct 2023 13:07:10 -0400 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C73E9D42; Wed, 18 Oct 2023 10:06:34 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id ca18e2360f4ac-7a669a4ec51so44276139f.3; Wed, 18 Oct 2023 10:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697648794; x=1698253594; 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=m1uXLDmoVzvN2oJUe3cXywX9ZoHLJ5owNDwFWfeTZCY=; b=VlaYJLnCOpR5XRya/+d70l3ukQOPIcjLjsZNDYuVJHuqaEkGZ0Gky4KdmhIvVlHyjU KQBv4w76AD3WVIsAEsLjoH0HGt4zzirogOFFOYKX+vd8OE8PCkBtjH/n94kGkIcYas50 B7fWRgAJ+acWqHLNy9KY5GbmRyFb3Lv7ZcMq5SPK4/69XA5dlOt3VAGKtvO598mzL/vm rS0nEZMNRn/IkrjSyF9rlupDeoMby5T5iXdxIaAVJZ8FS2t67xbM1qHnh3LrHRWkvMPi BmK00FJ1MAh9OtnFIsUEZ69K14nD9BIOavceZr7mMvShYbkNpDD5beekM/ftHPtsEl8s t4PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697648794; x=1698253594; 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=m1uXLDmoVzvN2oJUe3cXywX9ZoHLJ5owNDwFWfeTZCY=; b=SmAAzzEhmt6r/1CsOCT7nHnRbPq2yQ8g0D0gysWVCmMxq62S9OoJTu+9YPEI2IOCDy J6Hs4oiHJ87/4Eq5sJoqsa3hpBT389VVSxtkdpc41DhOMET6rzFbDGrTpalhZRrxd1oU c2RnYXkWSG+cn9LPSFDsPSmi1jXZMXnAA4YaJWBFn0CSliA50iB9McXaean6qg9ylRil S0bE5QL954BgaPp0v5DlJAaXorOl/bff679Wj9LZFmdwRZQjdoKCu3hW9cT9DKJlBFRG ZCMhPwNf8XRZrRfS1aqnjL+9Mk6BLqnDTlLYEIj5ac9XtMLNjpt8lkGzMn2toS5BLOpQ HAWQ== X-Gm-Message-State: AOJu0Yz+yzx5FCQp083XkBmAkPe99p+e3q/xxMhnjBV7h5kJB/hSms37 seK6WpuCJg9BqTSfBM2qPckvzLPe8ZaCOw== X-Received: by 2002:a05:6602:48e:b0:79f:9eb4:3ea1 with SMTP id y14-20020a056602048e00b0079f9eb43ea1mr8307541iov.3.1697648793755; Wed, 18 Oct 2023 10:06:33 -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 n4-20020a5d8244000000b0079fa1a7cd36sm1228944ioo.30.2023.10.18.10.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 10:06:33 -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, rostedt@goodmis.org, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v7c 20/24] dyndbg: refactor *dynamic_emit_prefix Date: Wed, 18 Oct 2023 11:06:00 -0600 Message-ID: <20231018170604.569042-21-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018170604.569042-1-jim.cromie@gmail.com> References: <20231018170604.569042-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]); Wed, 18 Oct 2023 10:08: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 a6ee142668bf..9db797a0cf82 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -774,11 +774,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), " "); @@ -787,15 +804,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); @@ -807,13 +819,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