From patchwork Wed Oct 18 17:05:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 13427472 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E7527CDB489 for ; Wed, 18 Oct 2023 17:07:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E2BD610E429; Wed, 18 Oct 2023 17:06:36 +0000 (UTC) Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6EFFB10E43A; Wed, 18 Oct 2023 17:06:33 +0000 (UTC) Received: by mail-il1-x135.google.com with SMTP id e9e14a558f8ab-3515deaa7c1so28915355ab.2; Wed, 18 Oct 2023 10:06:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697648792; x=1698253592; darn=lists.freedesktop.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=PdhZKvxYwXdkWkdLVl73JQfyJJ5FbxfJO6rydQUwjqs=; b=isJZJE7aCaX10hkr7sriWOFWtDMcz7dGSnnWArvp1v/WRx/xmOr5aFXS279tfxkZ+3 lZm7TY5W9SrvAyardEbZhEdfdgUV3kRwfvR0V69mCkr/nfaMbrFEZ2AcKblNNsSwwHRh OwNJRPNodsN8oG1OUSbLs/tg4uYsKDEDq7N0pH2UtVPqUgmDVdmwfTNpXJVuF1w/YxjQ RTIbR0VuAABybPuH/1kQPYd2qwDuuRQAaQckMGWJO3Ze1txSpzuItVTKEGqaxJqRffyJ LdUnw5cUBWHYUA9wKJkKLR5KEz2BwRQd6hToWBXZZQg2dJjYHlW+kTpi9KVYc+WJ9L+y 9lLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697648792; x=1698253592; 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=PdhZKvxYwXdkWkdLVl73JQfyJJ5FbxfJO6rydQUwjqs=; b=IYhIDRdPwXs1L1+OzEJCtDcLzeYoY1og8k512Z6UozK7SFto+TvpX2X+MvYbkK47C6 mX9kUTdxsiLt4sGMD8UNmGdsm39dYw1kQZEUlFGm1HC5e8KBDjndoviYvX+sDVyOTtRF zkBX4sfyj3QpIR3Cx955aSV5QLj93zZ1KSeBauBqfoq1eR88Y1SWCYbQV6m5IwYVYxQy a8B+OTjaqgJGq1fQC09vzUYFW6CNOjzDW+6g71XZWo0oim/hikV1IFNf7F1drM87lx32 xvA4dhnZE1SrKgKKB/3xfy4g7MmioqRTFj4Rz04zmHKD4r70bP8QBoo677Wvm+3NgtKK TFNw== X-Gm-Message-State: AOJu0Yy/3vF+h8HXTo8fZNuCkB4ZDeUQTtR9Ct12xfpD/nN6Q4ap+Sy1 zATvEJrNn0g9aQAg76h4vLY= X-Google-Smtp-Source: AGHT+IHYIKuc7v3Gyr8+p8LkqL6z+dzzReQJCVJIrBuhwNb1SlpPH8WoKoGFfvuTEXJo5vKv8yvKPw== X-Received: by 2002:a05:6602:2c0e:b0:7a6:6d0e:af6e with SMTP id w14-20020a0566022c0e00b007a66d0eaf6emr3211428iov.10.1697648792635; Wed, 18 Oct 2023 10:06:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 10:06:32 -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 Subject: [PATCH v7c 19/24] dyndbg: add _DPRINTK_FLAGS_INCL_LOOKUP Date: Wed, 18 Oct 2023 11:05:59 -0600 Message-ID: <20231018170604.569042-20-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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lb@semihalf.com, groeck@google.com, linux-doc@vger.kernel.org, jani.nikula@intel.com, daniel.vetter@ffwll.ch, linux@rasmusvillemoes.dk, rostedt@goodmis.org, mcgrof@kernel.org, seanpaul@chromium.org, joe@perches.com, bleung@google.com, yanivt@google.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" dyndbg's dynamic prefixing (by +tmfsl flags) is needlessly expensive. When an enabled (with +p) pr_debug is called, _DPRINTK_FLAGS_INCL_ANY prefix decorations are sprintf'd into stack-mem for every call. This string (or part of it) could be cached once its 1st generated, and retrieved thereafter, as long as its deleted any time the callsite's flags are changed afterwards. So consider the prefix/decoration flags: 'tmfsl', and what should be in the cache: -t thread-id. not part of the "callsite" info, derived from current. doesn't belong in the cache. it would be wrong. can be done in outer: dynamic_emit_prefix() -l line number this could be part of the prefix, but would bloat the cache can also be done in outer: dynamic_emit_prefix() -mfs module, function, source-file we cache these, composed into a sub-string. they are "lookups", currently to descriptor fields, could be accessor macros to "compressed" tables. cache saves more access work. All enabled together, they compose a prefix string like: # outer -----inner---------- outer "[tid] module:function:sourcfile:line: " So this patch extracts _DPRINTK_FLAGS_INCL_LOOKUP macro out of _DPRINTK_FLAGS_INCL_ANY macro, then redefs latter. Next re-refactor dynamic_emit_prefix inner/outer fns accordingly. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 927cb14f24e0..2237d454bc19 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -40,10 +40,12 @@ struct _ddebug { #define _DPRINTK_FLAGS_INCL_SOURCENAME (1<<5) #define _DPRINTK_FLAGS_PREFIX_CACHED (1<<7) -#define _DPRINTK_FLAGS_INCL_ANY \ - (_DPRINTK_FLAGS_INCL_MODNAME | _DPRINTK_FLAGS_INCL_FUNCNAME |\ - _DPRINTK_FLAGS_INCL_LINENO | _DPRINTK_FLAGS_INCL_TID |\ +#define _DPRINTK_FLAGS_INCL_LOOKUP \ + (_DPRINTK_FLAGS_INCL_MODNAME | _DPRINTK_FLAGS_INCL_FUNCNAME | \ _DPRINTK_FLAGS_INCL_SOURCENAME) +#define _DPRINTK_FLAGS_INCL_ANY \ + (_DPRINTK_FLAGS_INCL_LINENO | _DPRINTK_FLAGS_INCL_TID | \ + _DPRINTK_FLAGS_INCL_LOOKUP) #if defined DEBUG #define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINT