Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp467448rdf; Fri, 3 Nov 2023 06:12:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkJh87nU6KDtv6EtdhM+HHPOVMqnM2xnwMqIMp4p6GXEgA+K0quXV4D0W7ObW+4EerL0Lq X-Received: by 2002:a17:902:efc9:b0:1ca:20a0:7b08 with SMTP id ja9-20020a170902efc900b001ca20a07b08mr20109913plb.50.1699017143407; Fri, 03 Nov 2023 06:12:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699017143; cv=none; d=google.com; s=arc-20160816; b=jhrhqSySzJyMzkVmlvh6FYZ/jKONIjo1JZnozeLaRh/QVhP2hM8LoSjAKb4ED7esYN EQ0frfYlLannI6hi1g4+/wpDjbM3co9rfpycSi0SuBA2mqI8w94Mgb2y83YlXhpwtKWK Gxn2QyykkKTE0w12M//uU6opJ6Y7y6PtQApo8SruY3tDdyYrg63/qIi28l9zWa/6n4+n befpnEwP7JGva++EN20YwPkOuhJ7H2i3ubOyqmkq9WZ0dM35hRMQ8aJK/5tqmeT772N6 0PhTxMv7MpDFAjLsxQhrxwB1+jO+Om/ciTgh2l/SmBgBV3KCaU/Gms71ocFc02fHZvN6 VzUA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=RCmq6ecNHq9wQ5I/v/wW8k80iE2cJiNMS0glwgLSSUA=; fh=Xr9EZaLbYspLudo3lCz3I6iQD6BKril0MIzT5DobTXc=; b=rKogQHdbzw3uacFd+VLdjLs+lp74fLZwaeihMHoAJi5oHIRdfkRWVGUk6XPgoayxSj UtrcS0YB9/UPOHB8uofxbbmgQsznzRFYuGbq0o3Dh1157jCLHaQp21qg9l+7SQryuggP NFiKK9sDrdpPZ5H4I5gAgjau8CnKH8YnerlYWXJYomVVRM9lCiCg/Qm/rVuuJjwZ1Wvk pEufNRcL0FZCDpEZAOEM5F7tVC11K46Twc5Q+luWp+16iXXwdpPiDoBvA/ezQ9lS3BHG XEcM+xtOH+gmW2YtzfnbWu/Kv/XMajsaJzJeC27I95lutGukKAQptcFUMK3wSlBzjSNI wzNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=P5DXfnGm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id h17-20020a170902f55100b001c474ff2fdesi1510382plf.378.2023.11.03.06.12.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 06:12:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=P5DXfnGm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 1C5E48077FE7; Fri, 3 Nov 2023 06:10:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376427AbjKCNKZ (ORCPT + 99 others); Fri, 3 Nov 2023 09:10:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230115AbjKCNKX (ORCPT ); Fri, 3 Nov 2023 09:10:23 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D99083 for ; Fri, 3 Nov 2023 06:10:17 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-507a62d4788so2615770e87.0 for ; Fri, 03 Nov 2023 06:10:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; t=1699017015; x=1699621815; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=RCmq6ecNHq9wQ5I/v/wW8k80iE2cJiNMS0glwgLSSUA=; b=P5DXfnGm+1DVs0NFVjMhd+p12QhM6GUalIJ1voaVop6yGefr9ejiFlbQDpKvE3fxtr clIBovkRoyszm9wmvw/8RYfkCZky94GEGN7hdeCBXqBzLPrjMtJxZ28g14UDbbr1riu9 Ab9GCZFw29ih46mwtgNHicjdLHoISTRSs8tiCERnnRHMoCFWbPQZPl2MKZQwFPn+FsYg 6xAigz8tMb7zJtHF04AidTOzDCguR8G11YaJNRbepWoO22/HZKYHsEJBznxS5nIwVM8i /1XsoGXrKoAhzVoQU3PPlyGcSBvMQotlhTcu44cH2/YAmON1qBfgTm15u/eKuCOY/B09 CMtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699017015; x=1699621815; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RCmq6ecNHq9wQ5I/v/wW8k80iE2cJiNMS0glwgLSSUA=; b=n1tq+DqXseR/pajyuaAgjD6sxUnecaxasRW7eY7Tk8CtawEPKpD9hGrIejMljfbh2n 3xl6xcmLEhR1DqGLyvezEHu42uRgkMj7C5ygMoKA1IdT1ePfQ/KUQe0+Qx+SQyr+LZb/ nxpV/4Gg3VCEh8a9umdBAmnK+a/OU9NF64HtZkhISjDT0EymJ/zO7OGOZ2f88wHswvFN VZKPAvfBlkkSQebUF366k6qhWdu+713vB5roo06EoYRE7FNUcP+VA5wpzgZmuVkg88Np bNXRwfUszef/ugB0zN9Uyq2RzwCXejDUYFXQD02PhPdUOPgaWhGSWCpd7PZYR6UcuWcb 5Fbg== X-Gm-Message-State: AOJu0YzDHvbozoCcYKbfS1HhykOGpJU7u7KXxqGq4fMBHmyRBRbBXVKx 3eVzRfB1JuevSTC7m0uiN3mqBcc4cp91+Zzfp2hO X-Received: by 2002:ac2:4f8e:0:b0:503:1d46:6f29 with SMTP id z14-20020ac24f8e000000b005031d466f29mr14497523lfs.37.1699017015502; Fri, 03 Nov 2023 06:10:15 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 06:10:15 -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 00/12] dyndbg: add support for writing debug logs to trace Date: Fri, 3 Nov 2023 14:09:59 +0100 Message-Id: <20231103131011.1316396-1-lb@semihalf.com> X-Mailer: git-send-email 2.38.3 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 03 Nov 2023 06:10:46 -0700 (PDT) Add support for writing debug logs to trace events and trace instances. The rationale behing this feature is to be able to redirect debug logs (per each callsite indivdually) to trace to aid in debugging. The debug logs output to trace can be enabled with T flag. Additionally trace destination can be provided to the T flag after ":". The trace destination field is used to determine where debug logs will be written. Setting trace destination value to 0 (default) enables output to prdbg and devdbg trace events. Setting trace destination value to a value in range of [1..255] enables output to trace instance identified by trace destination value. For example when trace destination value is 2 then debug logs will be written to /tracing/instances/dyndbg_inst_2 instance. Usage examples: localhost ~ # echo "module thunderbolt =pT:7" > /dynamic_debug/control This will enable output of debug logs to trace instance /tracing/instances/dyndbg_inst_7 and debug logs will be written to the syslog also because p flag is set. localhost ~ # echo "module thunderbolt =pT:7,l" > /dynamic_debug/control When trace destination is followed by another flag then trace destination has to be followed by ",". localhost ~ # echo "module thunderbolt =pTl" > /dynamic_debug/control When trace destination is not provided explicitly then its value defaults to 0. In this case debug logs will be written to the prdbg and devdbg trace events. localhost ~ # echo "module thunderbolt =T:25" > /dynamic_debug/control This will enable output of debug logs to trace instance /tracing/instances/dyndbg_inst_25 with debug logs output to syslog disabled. Given trace instance will not be initialized until debug logs are requested to be written to it and afer init it will persist until reboot. Please note that output of debug logs to syslog (p flag) and trace (T flag) can be independently enabled/disabled for each callsite. Jim I took the liberty and based my work on your patches you pointed me to https://github.com/jimc/linux/tree/dd-kitchen-sink. I picked up the commits relevant to trace from the dd-kitchen-sink branch. The only changes I introduced in your commits were related to checkpatch complains. There are two errors still left: 1) ERROR: need consistent spacing around '*' (ctx:WxV) 140: FILE: lib/dynamic_debug.c:1070: + va_list *args) Which seems to be a false positive to me. 2) ERROR: Macros with complex values should be enclosed in parentheses 62: FILE: include/trace/stages/stage3_trace_output.h:12: +#define TP_printk_no_nl(fmt, args...) fmt, args I have not figured out how to fix it. Changes: V1) Major rework after receiving feedback in https://lore.kernel.org/all/20230915154856.1896062-1-lb@semihalf.com/ Jim Cromie (7): dyndbg: add _DPRINTK_FLAGS_ENABLED dyndbg: add _DPRINTK_FLAGS_TRACE dyndbg: add write-events-to-tracefs code dyndbg: add 2 trace-events: pr_debug, dev_dbg tracefs: add TP_printk_no_nl - RFC trace: use TP_printk_no_nl in dyndbg:prdbg,devdbg dyndbg: repack struct _ddebug Ɓukasz Bartosik (5): dyndbg: move flags field to a new structure dyndbg: add trace destination field to _ddebug dyndbg: add processing of T(race) flag argument dyndbg: write debug logs to trace instance dyndbg: add trace support for hexdump .../admin-guide/dynamic-debug-howto.rst | 5 +- MAINTAINERS | 1 + include/linux/dynamic_debug.h | 57 ++- include/trace/events/dyndbg.h | 54 +++ include/trace/stages/stage3_trace_output.h | 3 + include/trace/stages/stage7_class_define.h | 3 + lib/Kconfig.debug | 1 + lib/dynamic_debug.c | 414 +++++++++++++++--- 8 files changed, 465 insertions(+), 73 deletions(-) create mode 100644 include/trace/events/dyndbg.h -- 2.42.0.869.gea05f2083d-goog