From patchwork Wed Nov 1 00:26:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 13442444 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 D4B7DC4167B for ; Wed, 1 Nov 2023 00:29:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KtowqPJPiM1ma2sD/3Qn6GppHNrCYFFiG+OWxit1cjw=; b=CAvayoUGFDoFkc VFZm1E1SDouOQVf1oSF5WeWBmiHrioPR7vDe9baVCSWTpdkAudZdyT5VC83EkgNQG/d5PVE2q7Sv+ /gBm4xzUVVzY1IYYwFA7FNxyTzaUdUWiPgmWiCI7/vcfRwVAO3QO71i0I1Z1R6zHLGPYVDFbcd/do fj8ruWWct+8gwzdUexjndoJsSosjk9fo00mJuehHeO590Ko1B+0M/ArGdLKpG5ux4Qwm9JwpvSCUw /3/zJ/SbPMWpdtG6fXWcV71g0MVSt5tLZbxwFrTpUdyJ3BGwlKs4vCxL6MTIojYgvs1ee3xGEKBYT WvCydjH9pJZOPy2N54MQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qxz6W-006Q1y-1X; Wed, 01 Nov 2023 00:29:04 +0000 Received: from mail-il1-x12a.google.com ([2607:f8b0:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qxz4I-006OeH-0q for linux-arm-kernel@lists.infradead.org; Wed, 01 Nov 2023 00:26:51 +0000 Received: by mail-il1-x12a.google.com with SMTP id e9e14a558f8ab-357cf6725acso21763985ab.3 for ; Tue, 31 Oct 2023 17:26:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698798405; x=1699403205; darn=lists.infradead.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=tEqBwr5bmlsUliJRNMs53J4oxL88HwMAGezbxgrXL5M=; b=Uesua9/1vLoKkRkLG35/2iEO9TSKAJznqNIt3em8l68fIREb+NjtZx8hGUIDUGEe01 ms989CDVficXtruGux75Hh+8KjluRlACPuqiZ/dztDrlNQHYpBpGLyqU080gTt3UAqbq LU15RzKprf1TtdqsEgpwUmVei4d0bX5Na5iVmtyn1DXKPvOxsWI9ZrdnkTWNo86/N5P9 36gKh+uqmrJ244Tg7So/pcC/zgdfT/hxIn/AWbDXlhQzIgUOSpc51ptE/zLcEpROTAUc jE//7LYSgGuGEb0HBpBeDgEvtLAN+bB3GV4BVnd4N+TYNYX50qFnAp07mrax/J8f9a9y x16Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698798405; x=1699403205; 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=tEqBwr5bmlsUliJRNMs53J4oxL88HwMAGezbxgrXL5M=; b=EST8TNmIw+nyCEvRWYSJis3HEI8YcxquPxEbhqlUFWKUvquEjU+vxROWcRU5dW0UMN //Fk5evwbHt9yeu5mcgjpt9tE3B/tfmADjfIOSxVqB3TJPUuGn5oS3Vt91V6Iozr7o5B ZIwA9sfBcdA5UMZMJ1zrF1w6fNc+/FfJooLtPaBHO7lqkcnfjhigwML0cIxeZMmrp1Jc NgD2kb5srbVYuqOgsWc7EWiqV5LSLGxMXAlb41GDRYkLiXQa6Z3rueGEaZGYm+g2/5NA YFFXi/ip4Pm2p8iYIxU4TIBZj42VTcLBY56AOuA3QxbivzhBqGLmkPnelvySZgy25W5T MB3w== X-Gm-Message-State: AOJu0YzJAIv4V20rNRak898sOshOuxV/lmT92dd/1atmT99SwQmHY2nj 4q/xXoCwRDcrSWsHkqtATAU= X-Google-Smtp-Source: AGHT+IGkWEhH/sTMgZAoCvqDsHJ9MiwzmTfgqH8FCsVszlSzvBBjofFDFFpQzS5/UrGCR45izJ6Y7g== X-Received: by 2002:a05:6e02:1ba1:b0:357:a08b:566d with SMTP id n1-20020a056e021ba100b00357a08b566dmr19451120ili.29.1698798405690; Tue, 31 Oct 2023 17:26:45 -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 t1-20020a92c901000000b00357cc8df1d5sm141701ilp.68.2023.10.31.17.26.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 17:26:45 -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, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v7d 20/23] dyndbg: refactor *dynamic_emit_prefix Date: Tue, 31 Oct 2023 18:26:06 -0600 Message-ID: <20231101002609.3533731-21-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231101002609.3533731-1-jim.cromie@gmail.com> References: <20231101002609.3533731-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231031_172646_305540_5CED4F82 X-CRM114-Status: GOOD ( 16.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 f878a6f09fc8..213110ec1e9c 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;