Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp467125rdf; Fri, 3 Nov 2023 06:11:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzov1qtsRB3FrSbFkkbVg6gCVG/9gYQ6E7UMG172k0pioDYDw9DKUZxJbmnE3tLsFIID+3 X-Received: by 2002:a92:c5a3:0:b0:359:398d:7c42 with SMTP id r3-20020a92c5a3000000b00359398d7c42mr8435961ilt.14.1699017116499; Fri, 03 Nov 2023 06:11:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699017116; cv=none; d=google.com; s=arc-20160816; b=cp768uXxN5WLMVTpHOlBSC0ffkS5ySn1Fv/cVXlYGlw+mUW8TCtDh/NZV7kfFGKbPP F9xSZigZZlvjbokTSfGo6Iha8WAjdPCwWp28MK2kePeZccwkta8101/B0eLGlJ33NdLn RGrNdYssh/B9f7eGXO4VkRHakfBrtl5QmE7AKeZ65dSYjqgIGozNVcPzdGRmi3YWf3gT 3pK8jEukTsJGwhE90Kuu7RgWevh0c6XzMEjUkfHqusF7HRFLnT5YccZoJO9ML7v3RuyR I3Krun6GDii8p+rdHBa0izYUMoU0U2cxXmnIOWKjpRGrL1jGdMACqOn4awcdVGpcZTOv TJ/A== 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=eiFe3xfWVVRbB+dZemjysAJsSe+YWOJENxzGnSzBt3U=; fh=Xr9EZaLbYspLudo3lCz3I6iQD6BKril0MIzT5DobTXc=; b=Q1FyKn9bbMMe+y6IvWTUZAzJQRHV52rTTOOV333KoJSibeaYStak6VI2O5nmCzJ31I OoU0DyU1Hk38HPCZWEOlvu8KTAhTI+CAcGhT5zy8NAP8FOgfVurSQnEINlJQv58TJPr+ 3qXvesPe4WeR2iBVNQHlSft9QcWKSuD3I+8i/xYZky8jJ4Xpukj8OSco3IIvAmDYnyeY cw3ivHdgOTGTnE58F88nIB0DBGW9Pr/HKxE9ApRvskuhOGS6OlqNHVlTN03r3A9ktVqg xh5Cxlhrj7QrTFqrB1wiTvyfPqVZJLVSJdpViizPZS2Y+MqATwIjRio93Iy20JsQlaCV Gkwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=UqjsreWO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=semihalf.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id h62-20020a638341000000b005bd2b87d75fsi1443291pge.669.2023.11.03.06.11.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 06:11:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=UqjsreWO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=semihalf.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id BC0C5826FAAF; Fri, 3 Nov 2023 06:11:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377656AbjKCNKt (ORCPT + 99 others); Fri, 3 Nov 2023 09:10:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233470AbjKCNKc (ORCPT ); Fri, 3 Nov 2023 09:10:32 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EA0FD4D for ; Fri, 3 Nov 2023 06:10:26 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-507f1c29f25so2508194e87.1 for ; Fri, 03 Nov 2023 06:10:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; t=1699017024; x=1699621824; 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=eiFe3xfWVVRbB+dZemjysAJsSe+YWOJENxzGnSzBt3U=; b=UqjsreWOp46SPecv+RRcXLnXAAjAliU6huwoRB6jf+NLbf5a/HEilZ+xrAx+tni9/x BuLSDwKhTuMihmj/Zgm14sNqSOMAEJj0vjDuYr/wRg1OLLof+HcW15ctqsQsTZhjcM3c K2MFvrRt8kMzARRRXY6cpisgFt0CcHOGS3/oohyivjdLPvKUwjDENWUskh0WR5rcdxGN hcsmCQvfd12p15ty48O3MAdmB5dottuzh6hbGqGO+vXzNw3o7T9HXE+p4/ZmFIzjVx6v f9nzo+VSBOPs3zkcO9ifv518SFHIng2/tCHVZ/yJnSD5iRttcR8uCA4KRfkxFOXY2WV/ D0aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699017024; x=1699621824; 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=eiFe3xfWVVRbB+dZemjysAJsSe+YWOJENxzGnSzBt3U=; b=t+FCbVr7CrFs1SCpExtv0QNwewN+kkIs6h79PFSnkp0EGYULfsTfG3VKxcmnqj4j9q 9LnmG7wkxSb+VqMGv2eQvUlbKOdUFc+UnePEVB6K0phAMbf2m0uC014RVnwnQmPEAFpg bUfcKnjJZtEn4FhWwPcpGQ0lIiDP1DS8ia8qOldu9IHh+nkqcXZBY6zYpds8mRLm3op6 oeE7Wkc550pFpLXwlwcq7NVz4Kmm4sg8qhkLYELd6hHv7BP6rh8MT2jKk79J0aXoX+Nj kUubltG0RMmckekjVsyh/FctD68PtPJI7JeR6fC1YrBwLHs1ZVpa977KNjMh1lQug2gM dEYA== X-Gm-Message-State: AOJu0Ywh95EgIWu/8u+oR6PKNW8FpXrTM5cJnkweDAXud7GVRZuJBsZh KSTKzRETWBJStIkD3CBEbEiz X-Received: by 2002:a05:6512:10c7:b0:509:1227:ca71 with SMTP id k7-20020a05651210c700b005091227ca71mr16819209lfg.17.1699017024656; Fri, 03 Nov 2023 06:10:24 -0700 (PDT) Received: from ukaszb-l.wifi.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id f21-20020ac25335000000b00507a69a4799sm216336lfh.270.2023.11.03.06.10.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 06:10:24 -0700 (PDT) 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 , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v1 09/12] dyndbg: add trace destination field to _ddebug Date: Fri, 3 Nov 2023 14:10:08 +0100 Message-Id: <20231103131011.1316396-10-lb@semihalf.com> X-Mailer: git-send-email 2.38.3 In-Reply-To: <20231103131011.1316396-1-lb@semihalf.com> References: <20231103131011.1316396-1-lb@semihalf.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Fri, 03 Nov 2023 06:11:40 -0700 (PDT) Add trace destination field (trace_dst) to the _ddebug structure. The trace destination field is used to determine output of debug logs when +T is set. Setting trace_dst value to 0 (default) enables output to prdbg and devdbg trace events. Setting trace_dst value to a value in range of [1..255] 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 684766289bfc..3084302876b4 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 (default) enables + * output to prdbg and devdbg trace events. Setting trace_dst value to + * a value in range of [1..255] enables output to trace instance. + */ +#define TRACE_DST_BITS 8 + unsigned int trace_dst:TRACE_DST_BITS; +#define TRACE_DST_MAX ((1 << TRACE_DST_BITS) - 1) + unsigned unused:16; } ctrl; } __attribute__((aligned(8))); diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index ca87adf327df..3218ab078a76 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.42.0.869.gea05f2083d-goog