Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp1162255rdb; Fri, 22 Dec 2023 17:54:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvUug0lv3jpB63Po3whXNW11KuthTK7WMREY13Lxf0H852u3YnlXxjGTnOyx92rqQTByrP X-Received: by 2002:a17:90a:ba0a:b0:28b:d27e:f4a6 with SMTP id s10-20020a17090aba0a00b0028bd27ef4a6mr1498483pjr.38.1703296467089; Fri, 22 Dec 2023 17:54:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703296467; cv=none; d=google.com; s=arc-20160816; b=jW1w780Rusr9W42dZYIzeArPSTTtPQrpFGTDYiWFHo9jhPIMGKLz2Jn/oiMDqb/Tud HILMiwWo5xSDKLHSYtA4slcAJ/wjBazpKftm6RGI0FS4J57lAXGisKNCGi+xP72f1CKJ x1lv+dxWLf+cbyOrS3IZdVtDSr5MUupp8bcXeWZ76nkYhpy5zbD9TZCfwLxnXI/BU0he YJE/cLCd8pdpWwbHBHUHf/QFoQBWzJX8KE3fGRyckRdpX0iCscNpxMyPaB8RwpYtm9om CXDTScxN9LZTZuvA4pf8F6xQozpthShkD8mWRIHOpgEgHxlpeDvSh2xlZYmOEN81nYZa jVJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=57pqwApzCkOiEG2Ugf+nH1exjoE9SPHxB+wBjTutXCY=; fh=pC62+Xzu9rWxP3EwkFQHy3M37dHcdVo9RRC56IjE3s4=; b=hDigwj9cL7w0uo57sVlg4U7iBdqV7X6+2txyAB6Maaa2HDz2H1OWY4xeBpK8WY07v5 KVh0h7qPufwkUSl7MJV+PGx3r2DXCrFj9JCN+37mNfdCr+mqlBq/wowbaK7wH77SBKON XGMMEnT78dllwU23nAheEoz7cAZe61EkeSI1i9dOOPjGTDh2a63pk7FQKhaTJav4xFZK 2hVCQ1/uJO4z0SsrIgj3rkoWEfXiiKRZuCnTydYDSup2ou3KJlxQY8BBwyAMLMa6wedb o1n6X5i0AJAXssBG6C069FYkJWs0fGTXU5i+oPt09fI+zb68xwLay966r6cgpmvEcVCp cr7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=lRpY6c0f; spf=pass (google.com: domain of linux-kernel+bounces-10169-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10169-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=semihalf.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id n2-20020a170902e54200b001d43a6da077si109396plf.608.2023.12.22.17.54.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 17:54:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10169-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=lRpY6c0f; spf=pass (google.com: domain of linux-kernel+bounces-10169-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10169-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=semihalf.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 088AF28254A for ; Sat, 23 Dec 2023 01:54:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00708D2F8; Sat, 23 Dec 2023 01:52:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=semihalf.com header.i=@semihalf.com header.b="lRpY6c0f" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A119FD2E9 for ; Sat, 23 Dec 2023 01:52:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=semihalf.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=semihalf.com Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-55322dbabf6so2522411a12.0 for ; Fri, 22 Dec 2023 17:52:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; t=1703296326; x=1703901126; 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=57pqwApzCkOiEG2Ugf+nH1exjoE9SPHxB+wBjTutXCY=; b=lRpY6c0f+dXrhN5Tv21ZDX/TSvFBMIX2Ec4iBMZCCRAcGjwvcMmUK0doJJ+n6JE5uz H24XUSBlF9eXXL7dNwCD4yg0TKeVF7hmOy0VnGCjF9guSB4RkoruFyfuZZCGhW6fj759 fKwWkCL8CAs4V1p8V5VqMtJ47iEkMSKDpqDcbFK4xWpYGNOuARpz7U0fEBPINRvH39s+ 02/NDFV0bpDYjFP7mMjDksSMf4jc2n9nPx7kvWDMX1/Abzbany2N6It2kGhDFhWvzzee KS/XLrIdqBu/u6LS3jKLDGLHS9SViM1a8Be+eDtB3M/brIJYa/mq/31GpHe2lCtJJnlt dwpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703296326; x=1703901126; 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=57pqwApzCkOiEG2Ugf+nH1exjoE9SPHxB+wBjTutXCY=; b=Qp1x4CcJ9jLifSJEUIzhfr6uMnffsg9wi7iflPLBw0tnsnObVBZ1VpzOck5p6Ile4G 8BdAIY0mXFm1LN8dDO14farNV+fB6bXNAr4W5Dudo8j3h5puJJ5Ik5dWPWrFFwpqmJhq HKwgLCPQvy60XiT9myhIATLdDEPzBvWJHs4oa+1L5K3IjgoS5vmQqWEjRJCs4TgI11SP aVaLLO8S3LNow79VxvbpLSCvIzH++55/n8ww2s5hXlZNNdGygpE0p2sy2xsGcqNje/hj T8f3nsNSByMre5DKn0cMR74qruzLCUXcSOuQefcQ+A89F+eUOFFPRdeYRh2V8Fhn8uc8 6NDQ== X-Gm-Message-State: AOJu0Yz+kViOnloVtT2vdCVS+AnXkRKS/FyOvU1syCmJ58AiHI037Rpk fwk6OKv7xhAU/t8HpPz5F8sVs26ZNoU1 X-Received: by 2002:a50:cd95:0:b0:551:da9f:38c2 with SMTP id p21-20020a50cd95000000b00551da9f38c2mr1105775edi.71.1703296326031; Fri, 22 Dec 2023 17:52:06 -0800 (PST) Received: from ukaszb-l.semihalf.net (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id h2-20020a0564020e8200b005532a337d51sm3288494eda.44.2023.12.22.17.52.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 17:52:05 -0800 (PST) From: =?UTF-8?q?=C5=81ukasz=20Bartosik?= To: Jason Baron , Jim Cromie , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v3 09/22] dyndbg: add trace destination field to _ddebug Date: Sat, 23 Dec 2023 02:51:18 +0100 Message-ID: <20231223015131.2836090-10-lb@semihalf.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231223015131.2836090-1-lb@semihalf.com> References: <20231223015131.2836090-1-lb@semihalf.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The trace destination field is used to determine output of debug logs when +T is set. Setting trace_dst value to 0 enables output to prdbg and devdbg trace events. Setting trace_dst value to a value in range of [1..63] enables output to trace instance. Signed-off-by: Ɓukasz Bartosik --- include/linux/dynamic_debug.h | 13 +++++++++++-- lib/dynamic_debug.c | 28 +++++++++++++++++++--------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index a551b2967cb8..dc10c7535f13 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -60,9 +60,18 @@ struct _ddebug { #else #define _DPRINTK_FLAGS_DEFAULT 0 #endif - struct { + struct dd_ctrl { unsigned int flags:8; - unsigned unused:24; + /* + * The trace destination field is used to determine output of debug + * logs when +T is set. Setting trace_dst value to 0 enables output + * to prdbg and devdbg trace events. Setting trace_dst value to a + * value in range of [1..63] enables output to trace instance. + */ +#define TRACE_DST_BITS 6 + unsigned int trace_dst:TRACE_DST_BITS; +#define TRACE_DST_LAST (1 << TRACE_DST_BITS) + unsigned unused:18; } ctrl; } __attribute__((aligned(8))); diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index f47cb76e0e3d..0dc9ec76b867 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -80,14 +80,24 @@ module_param(verbose, int, 0644); MODULE_PARM_DESC(verbose, " dynamic_debug/control processing " "( 0 = off (default), 1 = module add/rm, 2 = >control summary, 3 = parsing, 4 = per-site changes)"); +static inline struct dd_ctrl *get_ctrl(struct _ddebug *desc) +{ + return &desc->ctrl; +} + +static inline void set_ctrl(struct _ddebug *desc, struct dd_ctrl *ctrl) +{ + desc->ctrl = *ctrl; +} + static inline unsigned int get_flags(const struct _ddebug *desc) { return desc->ctrl.flags; } -static inline void set_flags(struct _ddebug *desc, unsigned int val) +static inline unsigned int get_trace_dst(const struct _ddebug *desc) { - desc->ctrl.flags = val; + return desc->ctrl.trace_dst; } /* Return the path relative to source root */ @@ -190,8 +200,8 @@ static int ddebug_change(const struct ddebug_query *query, { int i; struct ddebug_table *dt; - unsigned int newflags; unsigned int nfound = 0; + struct dd_ctrl nctrl = {0}; struct flagsbuf fbuf, nbuf; struct ddebug_class_map *map = NULL; int __outvar valid_class; @@ -257,14 +267,14 @@ static int ddebug_change(const struct ddebug_query *query, nfound++; - newflags = (get_flags(dp) & modifiers->mask) | modifiers->flags; - if (newflags == get_flags(dp)) + nctrl.flags = (get_flags(dp) & modifiers->mask) | modifiers->flags; + if (!memcmp(&nctrl, get_ctrl(dp), sizeof(struct dd_ctrl))) continue; #ifdef CONFIG_JUMP_LABEL if (get_flags(dp) & _DPRINTK_FLAGS_ENABLED) { - if (!(newflags & _DPRINTK_FLAGS_ENABLED)) + if (!(nctrl.flags & _DPRINTK_FLAGS_ENABLED)) static_branch_disable(&dp->key.dd_key_true); - } else if (newflags & _DPRINTK_FLAGS_ENABLED) { + } else if (nctrl.flags & _DPRINTK_FLAGS_ENABLED) { static_branch_enable(&dp->key.dd_key_true); } #endif @@ -272,8 +282,8 @@ static int ddebug_change(const struct ddebug_query *query, trim_prefix(dp->filename), dp->lineno, dt->mod_name, dp->function, ddebug_describe_flags(get_flags(dp), &fbuf), - ddebug_describe_flags(newflags, &nbuf)); - set_flags(dp, newflags); + ddebug_describe_flags(nctrl.flags, &nbuf)); + set_ctrl(dp, &nctrl); } } mutex_unlock(&ddebug_lock); -- 2.43.0.472.g3155946c3a-goog