From patchwork Wed Oct 27 04:36:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12586357 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9CA4C4332F for ; Wed, 27 Oct 2021 04:38:03 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id ACB32610A0 for ; Wed, 27 Oct 2021 04:38:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org ACB32610A0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 930BE892A0; Wed, 27 Oct 2021 04:37:24 +0000 (UTC) Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by gabe.freedesktop.org (Postfix) with ESMTPS id B74546E520; Wed, 27 Oct 2021 04:37:18 +0000 (UTC) Received: by mail-il1-x132.google.com with SMTP id j10so1641837ilu.2; Tue, 26 Oct 2021 21:37:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o+whlX412ns7Y6ku6OCfF8ilTGQnTI3FHyyW4SpYgR0=; b=AxPoMl2gtzmhRnBl9k5THYtOV3nvDL4/dLq23yhgBKycu8ETCiI+/H9/ALQnsfSXaR rDiMaCRJR7i4aH2eKlgdOv5mRbkHoXps2XLeZdNwSo8B9Al5A3gFP5KfRKNmlf8n/RJ7 /TChanG/0PZJv4XScjk4Ed+G72VcHTOwOO+57IQDIWUYX3NjoEkQW7rWIL3cqBBzTGFH d8+T40KsCinqKkQKpGYlADqXubBsph+wxdWZpjlRUIlxHU1EkAnjcm9pSH9IxSJNI9it BM7YXRqG3a03xvJZAPhUpp8eki0UM3iDZaN50GLgiUMcdlhHEntkaTEojACs2G7ZN6wa UkpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o+whlX412ns7Y6ku6OCfF8ilTGQnTI3FHyyW4SpYgR0=; b=FL1R3XZ1dDBTqQ0T8BB2NYdGOKC65j/bHslR0I+PnzbHiZN/SN81nVlOV4KCt5GP9R OsNFa9NlrX5beaarBmGR77KK0Z0EPhK2KzXakR/ZmyFek+U9w53eQHa2FuIleuV1awiv thKZBdtNPgJ+yusuTYq7zSKzQKTlD6X3EzJ6vXQfK6gbMDGQ+z16sz8JxdIP8lRkfqwr Dn2tfKla7bp52GC5dxsygkxSmFO3zy98WTqNdH0ZpD6BcVvRRP/tMF3hBj1sxxGJeEzk rhrq7C0wyCUsv8/gtjFZxBbenZxEZub527Di8IiAs9l5RN4qSOWeGGPmWIZ1WfZ/TNOV 4Maw== X-Gm-Message-State: AOAM532fvgKnUX3TvYX6Ro1c69c8Rt+Eq+c0smcAeH9aB1hvo0GbO1Dp 2vELe/Vw68Rby3viD83dt2Q= X-Google-Smtp-Source: ABdhPJy7rC/9+8A/ODpxwktWX/Zo3dG1FP7VMw+H/WEGlKBV2sTrmacm45zUy0uBWydHCHtXJJ8Pgw== X-Received: by 2002:a92:cd8d:: with SMTP id r13mr12255334ilb.5.1635309438010; Tue, 26 Oct 2021 21:37:18 -0700 (PDT) Received: from samwise.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id a15sm2030404ilj.81.2021.10.26.21.37.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 21:37:16 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk, daniel.vetter@ffwll.ch, seanpaul@chromium.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Date: Tue, 26 Oct 2021 22:36:36 -0600 Message-Id: <20211027043645.153133-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211027043645.153133-1-jim.cromie@gmail.com> References: <20211027043645.153133-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v9 01/10] dyndbg: add DEFINE_DYNAMIC_DEBUG_CATEGORIES macro and callbacks X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" DEFINE_DYNAMIC_DEBUG_CATEGORIES(fsname, var, bitmap_desc, @bit_descs) allows users to create a drm.debug style (bitmap) sysfs interface, mapping each bit to a pr_debug "category". Unlike drm, dyndbg has no coding of "category", but it can select a set of pr_debugs with a substr match on their formats. Since many pr_debug users have systematized format prefixes, dyndbg can en/disable those existing groupings as sets/categories. Those categories can (already) be manipulated like so: echo "format $category +p" >control This macro merely maps the categories to bits of a sysfs interface, by wiring the callbacks to it. DEFINE_DYNAMIC_DEBUG_CATEGORIES(debug_gvt, __gvt_debug, "i915/gvt bitmap desc", /* map each bit to a format match string */ [0] = { "gvt:cmd:" }, [1] = { "gvt:core:" }, [2] = { "gvt:dpy:" }, [3] = { "gvt:el:" }, [4] = { "gvt:irq:" }, [5] = { "gvt:mm:" }, [6] = { "gvt:mmio:" }, [7] = { "gvt:render:" }, [8] = { "gvt:sched:" }); - int param_set_dyndbg() - int param_get_dyndbg() - struct kernel_param_ops param_ops_dyndbg Following the model of kernel/params.c STANDARD_PARAM_DEFS, these are non-static and exported. get/set use an augmented kernel_param; the arg refs a new struct dyndbg_bitmap_param containing: A- the map of "categories", an array of struct dyndbg_bitdescs, indexed by bitpos, defining the match against pr_debug formats. B- a pointer to the user module's ulong holding the bits/state. By sharing state, we coordinate with code that still uses it directly. This allows drm-debug api to be converted incrementally, while still using __drm_debug & drm_debug_enabled() in other parts. param_set_dyndbg() compares new vs old bits, and only updates prdbgs on changes. This maximally preserves the underlying state, which may have been customized via later `echo $cmd >control`. So if a user really wants to know that all prdbgs are set precisely, they must pre-clear then set. dynamic_debug.h: Add DEFINE_DYNAMIC_DEBUG_CATEGORIES() described above, and a stub throwing a BUILD_BUG (RFC) when used without DYNAMIC_DEBUG support. Add structs dyndbg_bitdesc, dyndbg_bitmap_param to support the main macro, and several helper macros wrapping the given categories with ^prefix and ' ' suffix. This way the callback can be more broadly used, by using the right helper macro. Also externs the struct kernel_param param_ops_dyndbg symbol, as is done in moduleparams.h for all the STANDARD params. USAGE NOTES: Using dyndbg to query on "format $str" requires that $str must be present in the compiled-in format string. Searching on "%s" does not define a useful set of callsites. Using DEFINE_DYNAMIC_DEBUG_CATEGORIES wo support gets a BUILD_BUG. ISTM there is already action at a declarative distance, nobody needs mystery as to why the /sysfs thingy didn't appear. Dyndbg is agnostic wrt the categorization scheme used, in order to play well with any prefix convention already in use in the codebase. In fact, "prefix" is not strictly accurate without ^ anchor. Ad-hoc categories and sub-categories are implicitly allowed, author discipline and review is expected. Hierarchical classes/categories are natural: "^drm::" is used in a later commit "^drm:::" is a natural extension. "^drm:atomic:fail:" has been proposed, sounds directly useful RFC: in a real sense we abandon enum strictures here, and lose some compiler help, on spelling errs for example. Obviously "drm:" != "DRM:". Some properties of a hierarchical category deserve explication: Trailing spaces matter ! With 1..3-space ("drm: ", "drm:atomic: ", "drm:atomic:fail: "), the ":" doesn't terminate the search-space, the trailing space does. So a "drm:" search spec will match all DRM categories & subcategories, and will not be useful in an interface where all categories are already controlled together. That said, "drm:atomic:" & "drm:atomic: " are different, and both are useful in cases. Ad-Hoc categories & sub-categories: Ad-hoc categories are those format-prefixes already in use; both amdgpu and i915 have numerous (120,~1800) pr_debugs, most of these use a system, a small set (9,13) of prefixes, to categorize the output. Dyndbg already works on these, this patch just allows adding a new bitmap knob to control them. Ad-hoc sub-categories are slightly trickier. since drm_dbg_atomic("fail: ...") is a macro: pr_debug("drm:atomic:" " " format,...) // cpp-paste in a trailing space We get "drm:atomic: fail:", with that undesirable embedded space; obviously not ideal wrt clear and simple prefixes. a possible fix: drm_dbg_atomic_("fail: ..."); // trailing _ for ad-hoc subcat Summarizing: - "drm:kms: " & "drm:kms:" are different - "drm:kms" also different - includes drm:kms2: - "drm:kms:\t" also different - could be troublesome - "drm:kms:*" doesn't work, no wildcard on format atm. Order matters in DEFINE_DYNAMIC_DEBUG_CATEGORIES(... @bit_descs) Since bits are/will-stay applied 0-N, the later bits can countermand the earlier ones, but it is tricky - consider; DD_CATs(... "drm:atomic:", "drm:atomic:fail:" ) // misleading The 1st search-term is misleading, because it includes (modifies) subcategories, but then 2nd overrides it. So don't do that. Signed-off-by: Jim Cromie --- v5: . rename to DEFINE_DYNAMIC_DEBUG_CATEGORIES from DEFINE_DYNDBG_BITMAP . in set_dyndbg, replace hardcoded "i915" w kp->mod->name . static inline the stubs . const *str in structs, const array. - Emil . dyndbg: add do-nothing DEFINE_DYNAMIC_DEBUG_CATEGORIES if !DD_CORE . call MOD_PARM_DESC(name, "$desc") for users . simplify callback, remove bit-change detection . config errs reported by v6: . return rc, bitmap->, snprintf, ws - Andy Shevchenko . s/chgct/matches/ - old varname is misleading . move code off file bottom to a "better" place . change ##fsname to ##var for less generic varname (ie: not "debug") . add KP_MOD_NAME workaround for !CONFIG_MODULES . move forward decl down to where its needed v7: . use kp->arg, dont need kp->data or previous patch-1 - jbaron . use client's ulong for bits, share state . throw BUILD_BUG if DEFINE_DYNAMIC_DEBUG_CATEGORIES used wo support v8: . drop help field from dyndbg_bitdesc . move ^ constraint from callback to helper macro: _DD_cat_ . add other helper macros v10: . drop all helper macros, [N] = { "foo" } is clear. --- include/linux/dynamic_debug.h | 52 ++++++++++++++++++++++++ lib/dynamic_debug.c | 76 +++++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index dce631e678dd..a9787544aef0 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -181,6 +181,10 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, KERN_DEBUG, prefix_str, prefix_type, \ rowsize, groupsize, buf, len, ascii) +struct kernel_param; +int param_set_dyndbg(const char *instr, const struct kernel_param *kp); +int param_get_dyndbg(char *buffer, const struct kernel_param *kp); + #else /* !CONFIG_DYNAMIC_DEBUG_CORE */ #include @@ -227,6 +231,54 @@ static inline int dynamic_debug_exec_queries(const char *query, const char *modn return 0; } +struct kernel_param; +static inline int param_set_dyndbg(const char *instr, const struct kernel_param *kp) +{ return 0; } +static inline int param_get_dyndbg(char *buffer, const struct kernel_param *kp) +{ return 0; } + #endif /* !CONFIG_DYNAMIC_DEBUG_CORE */ +struct dyndbg_bitdesc { + const char *match; /* search format for this substr */ +}; + +struct dyndbg_bitmap_param { + unsigned long *bits; /* ref to shared state */ + struct dyndbg_bitdesc map[]; /* indexed by bitpos */ +}; + +#if defined(CONFIG_DYNAMIC_DEBUG) || \ + (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE)) +/** + * DEFINE_DYNAMIC_DEBUG_CATEGORIES() - bitmap control of categorized pr_debugs + * @fsname: parameter basename under /sys + * @_var: C-identifier holding bitmap + * @desc: string summarizing the controls provided + * @...: list of struct dyndbg_bitdesc initializations + * + * Intended for modules with a systematic use of "categorized" + * pr_debug's (a set of prefixes in the format strings), this allows + * modules calling pr_debugs to control them in groups according to + * those prefixes, and map them to bits 0-N of a sysfs control point. + */ +#define DEFINE_DYNAMIC_DEBUG_CATEGORIES(fsname, _var, desc, ...) \ + MODULE_PARM_DESC(fsname, desc); \ + static struct dyndbg_bitmap_param ddcats_##_var = \ + { .bits = &(_var), .map = { __VA_ARGS__, { .match = NULL }}}; \ + module_param_cb(fsname, ¶m_ops_dyndbg, &ddcats_##_var, 0644) + +extern const struct kernel_param_ops param_ops_dyndbg; + +#else /* no dyndbg configured, throw error on macro use */ + +#if (defined(CONFIG_DYNAMIC_DEBUG_CORE) && !defined(DYNAMIC_DEBUG_MODULE)) +#define DEFINE_DYNAMIC_DEBUG_CATEGORIES(fsname, var, bitmap_desc, ...) \ + BUILD_BUG_ON_MSG(1, "you need -DDYNAMIC_DEBUG_MODULE in compile") +#else +#define DEFINE_DYNAMIC_DEBUG_CATEGORIES(fsname, var, bitmap_desc, ...) \ + BUILD_BUG_ON_MSG(1, "CONFIG_DYNAMIC_DEBUG needed to use this macro: " #var) +#endif +#endif + #endif diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index cb5abb42c16a..54a6a872106d 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -577,6 +577,82 @@ int dynamic_debug_exec_queries(const char *query, const char *modname) } EXPORT_SYMBOL_GPL(dynamic_debug_exec_queries); +#ifdef CONFIG_MODULES +#define KP_MOD_NAME kp->mod->name +#else +#define KP_MOD_NAME NULL /* wildcard */ +#endif +#define FMT_QUERY_SIZE 128 /* typically need <40 */ +/** + * param_set_dyndbg - bits => categories >control setter + * @instr: string echo>d to sysfs + * @kp: kp->arg has state: bits, map + * + * Enable/disable prdbgs by their "category", as specified in + * DEFINE_DYNAMIC_DEBUG_CATEGORIES arguments. + * + * Returns: 0 or <0 if error. + */ +int param_set_dyndbg(const char *instr, const struct kernel_param *kp) +{ + unsigned long inbits; + int rc, i, matches = 0, totct = 0; + char query[FMT_QUERY_SIZE]; + const struct dyndbg_bitmap_param *p = kp->arg; + const struct dyndbg_bitdesc *map = p->map; + + if (!map) { + pr_err("set_dyndbg: no bits=>queries map\n"); + return -EINVAL; + } + rc = kstrtoul(instr, 0, &inbits); + if (rc) { + pr_err("set_dyndbg: expecting unsigned int\n"); + return rc; + } + vpr_info("set_dyndbg: new 0x%lx old 0x%lx\n", inbits, *p->bits); + + for (i = 0; map->match && i < BITS_PER_LONG; map++, i++) { + if (test_bit(i, &inbits) == test_bit(i, p->bits)) + continue; + snprintf(query, FMT_QUERY_SIZE, "format '%s' %cp", map->match, + test_bit(i, &inbits) ? '+' : '-'); + + matches = ddebug_exec_queries(query, KP_MOD_NAME); + + v2pr_info("bit-%d: %d matches on format <%s>\n", i, + matches, map->match); + totct += matches; + } + *p->bits = inbits; + vpr_info("total matches: %d\n", totct); + return 0; +} +EXPORT_SYMBOL(param_set_dyndbg); + +/** + * param_get_dyndbg - bitmap reader + * @buffer: receives string rep of bitmap + * @kp: kp->arg has state: bits, map + * + * Reads last written bits, underlying prdbg state may have changed since. + * Returns: #chars written + */ +int param_get_dyndbg(char *buffer, const struct kernel_param *kp) +{ + const struct dyndbg_bitmap_param *p = kp->arg; + unsigned long val = *p->bits; + + return scnprintf(buffer, PAGE_SIZE, "0x%lx\n", val); +} +EXPORT_SYMBOL(param_get_dyndbg); + +const struct kernel_param_ops param_ops_dyndbg = { + .set = param_set_dyndbg, + .get = param_get_dyndbg, +}; +EXPORT_SYMBOL(param_ops_dyndbg); + #define PREFIX_SIZE 64 static int remaining(int wrote) From patchwork Wed Oct 27 04:36:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12586355 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07E1AC433F5 for ; Wed, 27 Oct 2021 04:38:03 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id CB5DC610E5 for ; Wed, 27 Oct 2021 04:38:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CB5DC610E5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BCECB89312; Wed, 27 Oct 2021 04:37:25 +0000 (UTC) Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by gabe.freedesktop.org (Postfix) with ESMTPS id A86F26E520; Wed, 27 Oct 2021 04:37:19 +0000 (UTC) Received: by mail-il1-x12b.google.com with SMTP id j6so1648096ila.1; Tue, 26 Oct 2021 21:37:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Mbanz3Hfm4S/C9DnDL7HTgcmeqSrMpcM5u5NhVQnBuE=; b=Z/MaaooGp7lzUsGLHzuh2gY0APQLsFpOF8gA2aeDSPAaRs9W7u7HuQM7JpCUorWKYs L9owXMrWUAQ9tUulXc81Do4d+/ZkiFmNLxHm3palrm9RVy3bIAdX8HZ014oLzTAIinZa 2Iv2r0dH3Ch2WIP0V6PgsEp43lMxfWwTIHI9/bnSdIgKUKGopiIqjMz+Iro8XN6O1opC jvtkCkDoBpFKjlUqXZIyH4d6FsPmLEleinkbnbwSupZgZchrCKnb2Ie+VWqPg2G+WA/a rofPic+6gng8QebgbST0YhM5fRKtPEstfpscWEA/I8Mz0SqBqXaHrs9SgoTKQJiPhml/ E3cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mbanz3Hfm4S/C9DnDL7HTgcmeqSrMpcM5u5NhVQnBuE=; b=OGKohC6PJID/suc4qvn1o7stcrvU+4SHZ/0on9C/iPRvjVLzCykcQKuJlrEVnRnufs Gw0CNwz0b0K9fD7PIUtYjUXEK34/DZkqV05WfnfbHTjJw0KcBtOyARePnw+rpjoKqQVP Coc3gVbSiv1KSqNLv315eIHWyg6gF1WhBT0eYsjZAxavRC+WpJI+egUvUlrqqFNDPEwa dS1t6SS7BBUWJ7k1ZPp9BOu/q5BHgGL8okh6pcrumaVqq7w38FAFicqBfpo6JX470WJv /sSv+GRLeK59Bu8yB7EmtuoXAGMd6YezAZmyFwn+OhDjnSUNFpi/CZO3fkwZZeHdeY+K 6Elg== X-Gm-Message-State: AOAM5336X4Oz27nqsfp+m48tJGwG9xsacQGxYETdq2x+2LHnosgnoWDm qlOHu7/FVMUKfp4XZnfg77U= X-Google-Smtp-Source: ABdhPJzCjWJBO6TwyGKAzlLbv9h8AD95jezLmysBiRrJ7HXztnBlPBjVYeiF2M8DYLy9h9ZbJ7F8zA== X-Received: by 2002:a92:ad0c:: with SMTP id w12mr16778504ilh.20.1635309439031; Tue, 26 Oct 2021 21:37:19 -0700 (PDT) Received: from samwise.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id a15sm2030404ilj.81.2021.10.26.21.37.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 21:37:18 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk, daniel.vetter@ffwll.ch, seanpaul@chromium.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Date: Tue, 26 Oct 2021 22:36:37 -0600 Message-Id: <20211027043645.153133-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211027043645.153133-1-jim.cromie@gmail.com> References: <20211027043645.153133-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v9 02/10] drm: fix doc grammar X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" allocates and initializes ... Signed-off-by: Jim Cromie --- include/drm/drm_drv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h index 0cd95953cdf5..4b29261c4537 100644 --- a/include/drm/drm_drv.h +++ b/include/drm/drm_drv.h @@ -486,7 +486,7 @@ void *__devm_drm_dev_alloc(struct device *parent, * @type: the type of the struct which contains struct &drm_device * @member: the name of the &drm_device within @type. * - * This allocates and initialize a new DRM device. No device registration is done. + * This allocates and initializes a new DRM device. No device registration is done. * Call drm_dev_register() to advertice the device to user space and register it * with other core subsystems. This should be done last in the device * initialization sequence to make sure userspace can't access an inconsistent From patchwork Wed Oct 27 04:36:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12586353 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA797C18E0D for ; Wed, 27 Oct 2021 04:37:52 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6EDA760F70 for ; Wed, 27 Oct 2021 04:37:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6EDA760F70 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A6DBC891BE; Wed, 27 Oct 2021 04:37:23 +0000 (UTC) Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by gabe.freedesktop.org (Postfix) with ESMTPS id B43E36E520; Wed, 27 Oct 2021 04:37:20 +0000 (UTC) Received: by mail-il1-x130.google.com with SMTP id 3so1598854ilq.7; Tue, 26 Oct 2021 21:37:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RJ9lw29NNoHoUgxjgpM5Z3ZVWZtIWAaSNjc0Og+vuzw=; b=YOAEMYkJjgS1gBlRU8vCO7dIRKl5YayIZsHUaDyXXsdnXsjfRaxJ1U8ucMzx93lt0m l8YtxetASYq0F4wP5mEKE+s0h6zoTOEZDbLBZ4VtLkeoQnl5OETVpbNfH8Wi1Cz6ghio 2mJkfGnSqgpX8uTj5lm7NFFbXbmpfnVEZ/+xFfYw4BWE0kv7R4BWS9fKLrnt7/VNRMEk OsLwoBoUEcgdrgNPyYoze5Ie4bddC7JSpJk34nHGWLSxhqHNLMgjzBPQnkHJdvrcLGAD MG4gSo5ndt6Qup8BTuDa/3ydIaAcW4HVWUccpjICLAK2c+nHQb3u3ehNjmxonM08/r4f vGyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RJ9lw29NNoHoUgxjgpM5Z3ZVWZtIWAaSNjc0Og+vuzw=; b=W5tpJ0buS8MQcSSy26AvVCV7uUPpjtIJe9qsjK5NN1XSCRj4audkp6GUKh9SHRZQ34 E6E+ByDXs4erv/y6Xw8Ca7n52MFneaBjeX0CptS4NNS87A4OucmkGE4u7ma/PpAk1wmX 0ybHqvo4UdmnaGIsxwRNHJxhPFBuwVOP3E2icbUXeoFs7fGDBOGf1/GU2/MSvPj+sU78 OxqU9HpnPbSH3hICmAUzh079VOhYAmM0IzewtzFFtcLx28Gc3hCrve/ro12SrAK74CHd d4zMferVezchBUkhpDzRzo53D07Eq8E9zo9E5MVLXlqNBLJEWaDaAqWD9qxtzvUZWfV4 CT+A== X-Gm-Message-State: AOAM533f/RO4v6Qw8Q1gJSp6zgEktntQzpehccUAOqLqAjfHZ/pvKYUq /eLQtN9aM0IRXan2zn4ls0k= X-Google-Smtp-Source: ABdhPJzLcXpN5rm0lt9foWqbfPaTbUgfz73EYAXxjloUAgHBp2bUecYXQajekgWoXbOwV6yRzDdmuA== X-Received: by 2002:a05:6e02:1646:: with SMTP id v6mr3387552ilu.282.1635309440025; Tue, 26 Oct 2021 21:37:20 -0700 (PDT) Received: from samwise.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id a15sm2030404ilj.81.2021.10.26.21.37.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 21:37:19 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk, daniel.vetter@ffwll.ch, seanpaul@chromium.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Date: Tue, 26 Oct 2021 22:36:38 -0600 Message-Id: <20211027043645.153133-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211027043645.153133-1-jim.cromie@gmail.com> References: <20211027043645.153133-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v9 03/10] amdgpu: use dyndbg.CATEGORIES to control existing pr_dbgs X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" logger_types.h defines many DC_LOG_*() categorized debug wrappers. Most of these already use DRM debug API, so are controllable using drm.debug, but others use a bare pr_debug("$prefix: .."), with 1 of 13 different class-prefixes matching [:uppercase:] Use DEFINE_DYNAMIC_DEBUG_CATEGORIES to create a sysfs location which maps from bits to these 13 sets of categorized pr_debugs to en/disable. Makefile adds -DDYNAMIC_DEBUG_MODULE for CONFIG_DYNAMIC_DEBUG_CORE, otherwise BUILD_BUG_ON triggers (obvious errors on subtle misuse is better than mysterious ones). Signed-off-by: Jim Cromie --- drivers/gpu/drm/amd/amdgpu/Makefile | 2 + .../gpu/drm/amd/display/dc/core/dc_debug.c | 44 ++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile index 8d0748184a14..26d974edd5c1 100644 --- a/drivers/gpu/drm/amd/amdgpu/Makefile +++ b/drivers/gpu/drm/amd/amdgpu/Makefile @@ -38,6 +38,8 @@ ccflags-y := -I$(FULL_AMD_PATH)/include/asic_reg \ -I$(FULL_AMD_DISPLAY_PATH)/amdgpu_dm \ -I$(FULL_AMD_PATH)/amdkfd +ccflags-$(CONFIG_DYNAMIC_DEBUG_CORE) += -DYNAMIC_DEBUG_MODULE + amdgpu-y := amdgpu_drv.o # add KMS driver diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_debug.c b/drivers/gpu/drm/amd/display/dc/core/dc_debug.c index 21be2a684393..f08d9cf6c4b3 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_debug.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_debug.c @@ -36,8 +36,50 @@ #include "resource.h" -#define DC_LOGGER_INIT(logger) +#ifdef CONFIG_DRM_USE_DYNAMIC_DEBUG +/* define a drm.debug style dyndbg pr-debug control point */ +#include + +unsigned long __debug_dc; +EXPORT_SYMBOL(__debug_dc); + +#define help_(_N, _cat) "\t Bit-" #_N "\t" _cat "\n" + +#define DC_DYNDBG_BITMAP_DESC(name) \ + "Control pr_debugs via /sys/module/amdgpu/parameters/" #name \ + ", where each bit controls a debug category.\n" \ + help_(0, "[SURFACE]:") \ + help_(1, "[CURSOR]:") \ + help_(2, "[PFLIP]:") \ + help_(3, "[VBLANK]:") \ + help_(4, "[HW_LINK_TRAINING]:") \ + help_(5, "[HW_AUDIO]:") \ + help_(6, "[SCALER]:") \ + help_(7, "[BIOS]:") \ + help_(8, "[BANDWIDTH_CALCS]:") \ + help_(9, "[DML]:") \ + help_(10, "[IF_TRACE]:") \ + help_(11, "[GAMMA]:") \ + help_(12, "[SMU_MSG]:") + +DEFINE_DYNAMIC_DEBUG_CATEGORIES(debug_dc, __debug_dc, + DC_DYNDBG_BITMAP_DESC(debug_dc), + [0] = { "[CURSOR]:" }, + [1] = { "[PFLIP]:" }, + [2] = { "[VBLANK]:" }, + [3] = { "[HW_LINK_TRAINING]:" }, + [4] = { "[HW_AUDIO]:" }, + [5] = { "[SCALER]:" }, + [6] = { "[BIOS]:" }, + [7] = { "[BANDWIDTH_CALCS]:" }, + [8] = { "[DML]:" }, + [9] = { "[IF_TRACE]:" }, + [10] = { "[GAMMA]:" }, + [11] = { "[SMU_MSG]:" }); + +#endif +#define DC_LOGGER_INIT(logger) #define SURFACE_TRACE(...) do {\ if (dc->debug.surface_trace) \ From patchwork Wed Oct 27 04:36:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12586351 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74D43C4167D for ; Wed, 27 Oct 2021 04:37:51 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 40379610A0 for ; Wed, 27 Oct 2021 04:37:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 40379610A0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 33098891F4; Wed, 27 Oct 2021 04:37:24 +0000 (UTC) Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9956F89083; Wed, 27 Oct 2021 04:37:21 +0000 (UTC) Received: by mail-io1-xd2f.google.com with SMTP id z144so962159iof.0; Tue, 26 Oct 2021 21:37:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JnEv+1wiw5YTf5b+dk8jhOAFVorOFGekz7eDajaLDB4=; b=ljxP0s62mYkZ5IrRSrhEo5yUUYFJRSHIcDXt91KWM0roaqyofbb7eNcmIfrHhW5LHc uJqa5YVCTkiSFRWMpALVT8ZjoSRu8IxVkWiCURlRJuNXG9nlw57rho7LxLlR1c9cRvM7 TrwvuxWJMUlnUt1Mj7aycPoOgVEPriELhQxie6wRDwR6lHLpkoMsmRyprk4o7T9OK3x2 MzLptxLB3HPX+GphpsQ0Utf4/KZbnh9Er5BFcsTGN+7I/pQckj47e4tiphP6KgSDl8hC Wx2jZmffRXqQ039ughnGRhxre83eN3kmuwX88dcB91gZ211o95Zjjh1/FnueX+4+UQ2N MD9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JnEv+1wiw5YTf5b+dk8jhOAFVorOFGekz7eDajaLDB4=; b=zTZTHCuXDNQzMOFQyodg9J5Eq90Npx9tnFvpTH1L3MHNkTg9TnJpWv+HDbemwc1WfB +W8PAwUqKTpWKOeio0XmTwAOBaZDxLxzjDPpL+W3jK/IgbUuVkhuo4jq8ev9dM0ImEH7 Wun2UrInLUu4810y1WCuyyeH564JtUDacAwvdHB2XIHY4+fw1dz9Jpd1K2XDoz468L31 6AfdYDpwTxbpPxnmveO+UphDT8GyMJc40KEdooBCnO7k9VBA5jYntZw/+qRuc2bz6K32 6JHRR0eJ/xzp63vX6zK+7fRiqQD+sM7qvNkDu03E0uH/gQuOSy4u5mjD9mqYdgyApXvH Hlig== X-Gm-Message-State: AOAM531doDlHpkz5jR1MsIN/8hAzmfSk598nPku8vvvTp+tFevO0Rbgo qWUpLMazKX1S2KYHx84ZBgI= X-Google-Smtp-Source: ABdhPJwJ5+KFsDDo1Kh/8vs968qMEDlSxAlHN1y4Oaw8oXXsSQOtees/IkX4dKyyvPP+Z8bAEpqSBA== X-Received: by 2002:a05:6638:459:: with SMTP id r25mr11720480jap.2.1635309440927; Tue, 26 Oct 2021 21:37:20 -0700 (PDT) Received: from samwise.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id a15sm2030404ilj.81.2021.10.26.21.37.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 21:37:20 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk, daniel.vetter@ffwll.ch, seanpaul@chromium.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Date: Tue, 26 Oct 2021 22:36:39 -0600 Message-Id: <20211027043645.153133-5-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211027043645.153133-1-jim.cromie@gmail.com> References: <20211027043645.153133-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v9 04/10] i915/gvt: trim spaces from pr_debug "gvt: core:" prefixes X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Taking embedded spaces out of existing prefixes makes them better class-prefixes; simplifying the extra quoting needed otherwise: $> echo format "^gvt: core:" +p >control Dropping the internal spaces means any trailing space in a query will more clearly terminate the prefix being searched for. Consider a generic drm-debug example: # turn off ATOMIC reports echo format "^drm:atomic: " -p > control # turn off all ATOMIC:* reports, including any sub-categories echo format "^drm:atomic:" -p > control # turn on ATOMIC:FAIL: reports echo format "^drm:atomic:fail: " +p > control Removing embedded spaces in the class-prefixes simplifies the corresponding match-prefix. This means that "quoted" match-prefixes are only needed when the trailing space is desired, in order to exclude explicitly sub-categorized pr-debugs; in this example, "drm:atomic:fail:". Signed-off-by: Jim Cromie --- v8: . fix patchwork CI warning --- drivers/gpu/drm/i915/gvt/debug.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/i915/gvt/debug.h b/drivers/gpu/drm/i915/gvt/debug.h index c6027125c1ec..bbecc279e077 100644 --- a/drivers/gpu/drm/i915/gvt/debug.h +++ b/drivers/gpu/drm/i915/gvt/debug.h @@ -36,30 +36,30 @@ do { \ } while (0) #define gvt_dbg_core(fmt, args...) \ - pr_debug("gvt: core: "fmt, ##args) + pr_debug("gvt:core: " fmt, ##args) #define gvt_dbg_irq(fmt, args...) \ - pr_debug("gvt: irq: "fmt, ##args) + pr_debug("gvt:irq: " fmt, ##args) #define gvt_dbg_mm(fmt, args...) \ - pr_debug("gvt: mm: "fmt, ##args) + pr_debug("gvt:mm: " fmt, ##args) #define gvt_dbg_mmio(fmt, args...) \ - pr_debug("gvt: mmio: "fmt, ##args) + pr_debug("gvt:mmio: " fmt, ##args) #define gvt_dbg_dpy(fmt, args...) \ - pr_debug("gvt: dpy: "fmt, ##args) + pr_debug("gvt:dpy: " fmt, ##args) #define gvt_dbg_el(fmt, args...) \ - pr_debug("gvt: el: "fmt, ##args) + pr_debug("gvt:el: " fmt, ##args) #define gvt_dbg_sched(fmt, args...) \ - pr_debug("gvt: sched: "fmt, ##args) + pr_debug("gvt:sched: " fmt, ##args) #define gvt_dbg_render(fmt, args...) \ - pr_debug("gvt: render: "fmt, ##args) + pr_debug("gvt:render: " fmt, ##args) #define gvt_dbg_cmd(fmt, args...) \ - pr_debug("gvt: cmd: "fmt, ##args) + pr_debug("gvt:cmd: " fmt, ##args) #endif From patchwork Wed Oct 27 04:36:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12586349 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27E21C43217 for ; Wed, 27 Oct 2021 04:37:49 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id EB89B610A0 for ; Wed, 27 Oct 2021 04:37:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EB89B610A0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6B45D8918A; Wed, 27 Oct 2021 04:37:23 +0000 (UTC) Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by gabe.freedesktop.org (Postfix) with ESMTPS id A1D548911D; Wed, 27 Oct 2021 04:37:22 +0000 (UTC) Received: by mail-io1-xd31.google.com with SMTP id d63so2112589iof.4; Tue, 26 Oct 2021 21:37:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KTjPwmyEBDA02pYjzS52Ng2KLEEXB6xVb20R+Q4xkso=; b=oEgwprXWHlgD+HK8HYagY0h+ZLXfFM042go+IjfKy+XWxWgaVtKJHZCUD/vCVb5i/s qLbm0A7vZLuPlH2lVgYG7W4Oa8kCBQewYb8jTuhbGz9PqfeB4W2ty0BQXOg6sBGjuSZE 8zzzcx1FYupfJn7qNJnm18QluydqENoSfjq3gQ21tqn2ExdbsJojZrCpxqEsVXCXSKkq 0fev0HUHDHRwXgfeO2B4H/9JwYhL/u925NwbPv2Chjswz8Gh6QT9y39MaUAKWaISc1Zs Cv8NevjmO5uQlIkgD99cG42HjKvfyEET+zkfzoSul7ym9YFooZ3hMgjYWM4PiEQ5IRVX 8Uvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KTjPwmyEBDA02pYjzS52Ng2KLEEXB6xVb20R+Q4xkso=; b=vt+/D4/hHUvPs2qlFSyhr+54J6hSd2RjNY652+W4s4BMjK9w9docPFB9B79K0n8Rle KepdwE91Rd9qQjq+e5y0jATeB33VBSOhz+5SmUG53fpSrPW2EBVosC8g12hVvDwvC+Qv DvYy7FvCZ0izFJzDM7cDpBxJ+D2VgOpWY1UeJP/tsXFAqW2Kyqg6dZsqu+Iej1eNlfCq qgl5YI/wuYO0B7Qqu5pRxWP1waN+EQxV50TTpnXugl7gclg5xRmTWiY5/dYdHHMfSlMI u+v6b2bmt4xPWg3iGKjZVnrH+zEzmxyNya9NrYtez/jYhmd2oNLF/CeEJWxg298Sz8TC ck9w== X-Gm-Message-State: AOAM533ty4NqYgfuEDTRa31FubFRSfggIcyvf+t7n5CjH1TexCjU23TT WMcHkVgsp7iRKolHNwpNzug= X-Google-Smtp-Source: ABdhPJyA9UJpZHU3+9vlpcCwM3603b2gx+HQKti7AVP908D+jG4YTlduIdgVV7qe09OFCOTviYg44g== X-Received: by 2002:a05:6602:2d14:: with SMTP id c20mr17390975iow.95.1635309441933; Tue, 26 Oct 2021 21:37:21 -0700 (PDT) Received: from samwise.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id a15sm2030404ilj.81.2021.10.26.21.37.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 21:37:21 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk, daniel.vetter@ffwll.ch, seanpaul@chromium.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Date: Tue, 26 Oct 2021 22:36:40 -0600 Message-Id: <20211027043645.153133-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211027043645.153133-1-jim.cromie@gmail.com> References: <20211027043645.153133-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v9 05/10] i915/gvt: use dyndbg.CATEGORIES for existing pr_debugs X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The gvt component of this driver has ~120 pr_debugs, in 9 categories quite similar to those in DRM. Following the interface model of drm.debug, add a parameter to map bits to these categorizations. DEFINE_DYNAMIC_DEBUG_CATEGORIES(debug_gvt, __gvt_debug, "dyndbg bitmap desc", [0] = { "gvt:cmd:" }, [1] = { "gvt:core:" }, [2] = { "gvt:dpy:" }, [3] = { "gvt:el:" }, [4] = { "gvt:irq:" }, [5] = { "gvt:mm:" }, [6] = { "gvt:mmio:" }, [7] = { "gvt:render:" }, [8] = { "gvt:sched:" }); If CONFIG_DYNAMIC_DEBUG_CORE=y, then gvt/Makefile adds -DDYNAMIC_DEBUG_MODULE to cflags, which CONFIG_DYNAMIC_DEBUG=n (CORE-only) builds need. This is redone more comprehensively soon. Signed-off-by: Jim Cromie --- v5: . static decl of vector of bit->class descriptors - Emil.V . relocate gvt-makefile chunk from elsewhere v7: . move ccflags addition up to i915/Makefile from i915/gvt v8: . relocate DDD_CAT decl code into intel_gvt.c - Tvrtko cflags back to i915/Makefile . add -DDYNAMIC_DEBUG_MODULE to support DYNAMIC_DEBUG_CORE-only builds heres unchanged? footprint: bash-5.1# for m in i915 amdgpu nouveau; do modprobe $m; done dyndbg: 1 debug prints in module drm dyndbg: 2 debug prints in module ttm dyndbg: 8 debug prints in module video dyndbg: 167 debug prints in module i915 dyndbg: 2339 debug prints in module amdgpu [drm] amdgpu kernel modesetting enabled. amdgpu: CRAT table disabled by module option amdgpu: Virtual CRAT table created for CPU amdgpu: Topology: Add CPU node dyndbg: 3 debug prints in module wmi dyndbg: 3 debug prints in module nouveau --- drivers/gpu/drm/i915/Makefile | 2 ++ drivers/gpu/drm/i915/intel_gvt.c | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 335ba9f43d8f..a313e8a539f6 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -301,6 +301,8 @@ i915-y += intel_gvt.o include $(src)/gvt/Makefile endif +ccflags-$(CONFIG_DYNAMIC_DEBUG_CORE) += -DDYNAMIC_DEBUG_MODULE + obj-$(CONFIG_DRM_I915) += i915.o obj-$(CONFIG_DRM_I915_GVT_KVMGT) += gvt/kvmgt.o diff --git a/drivers/gpu/drm/i915/intel_gvt.c b/drivers/gpu/drm/i915/intel_gvt.c index 4e70c1a9ef2e..e53b41fa15e0 100644 --- a/drivers/gpu/drm/i915/intel_gvt.c +++ b/drivers/gpu/drm/i915/intel_gvt.c @@ -162,3 +162,37 @@ void intel_gvt_resume(struct drm_i915_private *dev_priv) if (intel_gvt_active(dev_priv)) intel_gvt_pm_resume(dev_priv->gvt); } + +#if defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) + +unsigned long __gvt_debug; +EXPORT_SYMBOL(__gvt_debug); + +#define help_(_N, _cat) "\t Bit-" #_N ":\t" _cat "\n" + +#define I915_GVT_CATEGORIES(name) \ + " Enable debug output via /sys/module/i915/parameters/" #name \ + ", where each bit enables a debug category.\n" \ + help_(0, "gvt:cmd:") \ + help_(1, "gvt:core:") \ + help_(2, "gvt:dpy:") \ + help_(3, "gvt:el:") \ + help_(4, "gvt:irq:") \ + help_(5, "gvt:mm:") \ + help_(6, "gvt:mmio:") \ + help_(7, "gvt:render:") \ + help_(8, "gvt:sched:") + +DEFINE_DYNAMIC_DEBUG_CATEGORIES(debug_gvt, __gvt_debug, + I915_GVT_CATEGORIES(debug_gvt), + [0] = { "gvt:cmd:" }, + [1] = { "gvt:core:" }, + [2] = { "gvt:dpy:" }, + [3] = { "gvt:el:" }, + [4] = { "gvt:irq:" }, + [5] = { "gvt:mm:" }, + [6] = { "gvt:mmio:" }, + [7] = { "gvt:render:" }, + [8] = { "gvt:sched:" }); + +#endif From patchwork Wed Oct 27 04:36:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12586387 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7DA4C433FE for ; Wed, 27 Oct 2021 04:38:20 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 8D40E610A0 for ; Wed, 27 Oct 2021 04:38:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8D40E610A0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 373B36E873; Wed, 27 Oct 2021 04:37:39 +0000 (UTC) Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 20848891E1; Wed, 27 Oct 2021 04:37:23 +0000 (UTC) Received: by mail-io1-xd31.google.com with SMTP id n67so2072043iod.9; Tue, 26 Oct 2021 21:37:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1RXwI5SVYypmUtSbPSRl6KiWXp851rWvatS5wFzSlvQ=; b=KIbiVaNwKNkzpGz5SBwivHp7WX2PdvSg15GfGuRic7hIheSBDmyRwXdVfW2DTYZpIv Ygxmv+XLFfjA4x4RQFtvb76MWPyz1wWfR8X1mws/WhoaVgNbevhP9Jp3nxZiO4YapWQo TQllG0OZlSsBy3WwBD0jMctYVYC09aPn9GQyvRSW4rsJce57g+I/EMtTijuXDOnKNRwU V2vPdYmYI2UmcF1YmuU+J3JJBwgyYqtM7Lr6DPO/Q7Q5gppSggosiJrf51HQPTCGpP/4 93hxrYIuUqHqJRFAGvOIsU7GRsMTvhyj6jrGXPHBO6qPhljy8tLq31hm+0Wn/ZAfBq3c YwGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1RXwI5SVYypmUtSbPSRl6KiWXp851rWvatS5wFzSlvQ=; b=RbbggIQZQQJpwrNLXUhD70cGrH0fG3+b5QU81kiSH5iViOKh+avzNvLzWfq84Uo9Ll SR289X9tNwJGkdtXY2qWvbkhDDejJHvWzcXlNQbFIALF5kfAx3IVblE37vv94rpXclQy 6qTow97VC3rYWtXugKsm9ZsKzbiY8rLXVkeBf+jTx1O2bGvEZIn9hPPFCW39/mmiJXaZ bc0R3plXhUaCFyNPzBB9ain2rINc+H0oUSFwiWZDkDFk2ACGF7LErxdwLPEE8d+cadX+ BH0uJmiES7C9iuZ3CW+ywjxVeo/87A3ALpYbXEdfUmSPzNlzEdgW3d0bibpzmOu0CefK pV+A== X-Gm-Message-State: AOAM532vcxRdufgOsjSNhiy9wT3dp3af0PrbH/aVP9g1i3p+0trj/qOI BLEVFcsTkGHzJwL4eQH+Xqc= X-Google-Smtp-Source: ABdhPJx+s23Mi0YSIP0UuKmXumbpoW7qMHTn/JAS+VDt6fLkPoyzSi4y4VEthN/FFFsVPZUxYBJ62g== X-Received: by 2002:a05:6638:2244:: with SMTP id m4mr15557822jas.27.1635309443031; Tue, 26 Oct 2021 21:37:23 -0700 (PDT) Received: from samwise.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id a15sm2030404ilj.81.2021.10.26.21.37.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 21:37:22 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk, daniel.vetter@ffwll.ch, seanpaul@chromium.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Date: Tue, 26 Oct 2021 22:36:41 -0600 Message-Id: <20211027043645.153133-7-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211027043645.153133-1-jim.cromie@gmail.com> References: <20211027043645.153133-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v9 06/10] drm_print: add choice to use dynamic debug in drm-debug X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" drm's debug system writes 10 distinct categories of messages to syslog using a small API[1]: drm_dbg*(10 names), DRM_DEV_DEBUG*(3 names), DRM_DEBUG*(8 names). There are thousands of these callsites, each categorized in this systematized way. These callsites can be enabled at runtime by their category, each controlled by a bit in drm.debug (/sys/modules/drm/parameter/debug). In the current "basic" implementation, drm_debug_enabled() tests these bits in __drm_debug each time an API[1] call is executed; while cheap individually, the costs accumulate with uptime. This patch uses dynamic-debug with (required) jump-label to patch enabled calls onto their respective NOOP slots, avoiding all runtime bit-checks of __drm_debug by drm_debug_enabled(). Dynamic debug has no concept of category, but we can emulate one by replacing enum categories with a set of prefix-strings; "drm:core:", "drm:kms:" "drm:driver:" etc, and prepend them (at compile time) to the given formats. Then we can use: `echo module drm format "^drm:core: " +p > control` to enable the whole category with one query. This conversion yields many new prdbg callsites: dyndbg: 207 debug prints in module drm_kms_helper dyndbg: 376 debug prints in module drm dyndbg: 1811 debug prints in module i915 dyndbg: 3917 debug prints in module amdgpu Each site costs 56 bytes of .data, which is a big increase for drm modules, so CONFIG_DRM_USE_DYNAMIC_DEBUG makes it optional. CONFIG_JUMP_LABEL is also required, to get the promised optimizations. The "basic" -> "dyndbg" switchover is layered into the macro scheme A. A "prefix" version of DRM_UT_ map, named DRM_DBG_CAT_ "basic": DRM_DBG_CAT_ <=== DRM_UT_. Identity map. "dyndbg": #define DRM_DBG_CAT_KMS "drm:kms: " #define DRM_DBG_CAT_PRIME "drm:prime: " #define DRM_DBG_CAT_ATOMIC "drm:atomic: " DRM_UT_* are preserved, since theyre used elsewhere. Since the callback maintains its state in __drm_debug, drm_debug_enabled() will stay synchronized, and continue to work. We can address them separately if they are called enough to be worth fixing. B. drm_dev_dbg() & drm_debug() are interposed with macros basic: forward to renamed fn, with args preserved enabled: redirect to pr_debug, dev_dbg, with CATEGORY format catenated This is where drm_debug_enabled() is avoided. The prefix is prepended at compile-time, no category at runtime. C. API[1] uses DRM_DBG_CAT_s The API already uses B, now it uses A too, instead of DRM_UT_, to get the correct token type for "basic" and "dyndbg" configs. D. use DEFINE_DYNAMIC_DEBUG_CATEGORIES() This defines the map using DRM_CAT_s, and creates the /sysfs bitmap to control those categories. CONFIG_DRM_USE_DYNAMIC_DEBUG is also used to adjust amdgpu, i915 makefiles to add -DDYNAMIC_DEBUG_MODULE; it includes the current CONFIG_DYNAMIC_DEBUG_CORE and is enabled by the user. LIMITATIONS: dev_dbg(etal) effectively prepends twice, category then driver-name, yielding format strings like so: bash-5.1# grep amdgpu: /proc/dynamic_debug/control | grep drm: | cut -d= -f2- _ "amdgpu: drm:core: fence driver on ring %s use gpu addr 0x%016llx\012" _ "amdgpu: drm:kms: Cannot create framebuffer from imported dma_buf\012" This means we cannot use anchored "^drm:kms: " to specify the category, a small loss of precision. Note that searching on "format ^amdgpu: " works, but this is less valuable, because the same can be done with "module amdgpu". NOTES: Because the dyndbg callback is keeping state in __drm_debug, it synchronizes with drm_debug_enabled() and its remaining users; the switchover should be transparent. Code Review is expected to catch the lack of correspondence between bit=>prefix definitions (the selector) and the prefixes used in the API[1] layer above pr_debug() I've coded the categories with trailing spaces. This excludes any sub-categories which might get added later. This convention protects any "drm:atomic:fail:" callsites from getting stomped on by `echo 0 > debug`. Other categories could differ, but we need some default. Dyndbg requires that the prefix be in the compiled-in format string; run-time prefixing evades callsite selection by category. pr_debug("%s: ...", __func__, ...) // not ideal Unfortunately __func__ is not a macro, and cannot be catenated at preprocess/compile time. If you want that, you might consider +mfl flags instead;) Signed-off-by: Jim Cromie --- v5: . use DEFINE_DYNAMIC_DEBUG_CATEGORIES in drm_print.c . s/DRM_DBG_CLASS_/DRM_DBG_CAT_/ - dont need another term . default=y in Kconfig entry - per @DanVet . move some commit-log prose to dyndbg commit . add-prototyes to (param_get/set)_dyndbg . more wrinkles found by . relocate ratelimit chunk from elsewhere v6: . add kernel doc . fix cpp paste, drop '#' v7: . change __drm_debug to long, to fit with DEFINE_DYNAMIC_DEBUG_CATEGORIES . add -DDYNAMIC_DEBUG_MODULE to ccflags if DRM_USE_DYNAMIC_DEBUG v8: . adapt to altered ^ insertion . add mem cost numbers to kconfig . kdoc improvements (I hope) --- drivers/gpu/drm/Kconfig | 26 ++++ drivers/gpu/drm/Makefile | 3 + drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/drm_print.c | 52 +++++--- drivers/gpu/drm/i915/Makefile | 2 +- include/drm/drm_print.h | 177 ++++++++++++++++++++++------ 6 files changed, 209 insertions(+), 53 deletions(-) diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index cea777ae7fb9..fe87dc12d2ab 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -62,6 +62,32 @@ config DRM_DEBUG_MM If in doubt, say "N". +config DRM_USE_DYNAMIC_DEBUG + bool "use dynamic debug to implement drm.debug" + default y + depends on DRM + depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE + depends on JUMP_LABEL + help + The "basic" drm.debug facility does a lot of unlikely + bit-field tests at runtime; while cheap individually, the + cost accumulates. DYNAMIC_DEBUG can patch pr_debug()s into + NOOP slots, in a running kernel, so avoids those bit-test + overheads, and is therefore recommended by default. + + DRM_USE_DYNAMIC_DEBUG converts "basic" to "dyndbg", this + creates many new dyndbg callsites (56 bytes each), which + significantly increases drm* module .data, so is optional. + On an x86-64 kernel, with a config derived from fedora, that + price is: + #prdbgs KiB #with DRM_USE_DYNAMIC_DEBUG=y + kernel 3079 166k + drm 1 .06k 376 21k + drm_kms_helper 207 12k + i915 167 9.3k 1811 101k + amdgpu 2339 130k 3917 220k + nouveau 3 .17k 105 ~60k + config DRM_DEBUG_SELFTEST tristate "kselftests for DRM" depends on DRM diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index ad1112154898..77ca1b37848b 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -20,6 +20,9 @@ drm-y := drm_aperture.o drm_auth.o drm_cache.o \ drm_client_modeset.o drm_atomic_uapi.o drm_hdcp.o \ drm_managed.o drm_vblank_work.o +#ifdef CONFIG_DRM_USE_DYNAMIC_DEBUG +ccflags-y += -DDYNAMIC_DEBUG_MODULE +#endif drm-$(CONFIG_DRM_LEGACY) += drm_agpsupport.o drm_bufs.o drm_context.o drm_dma.o \ drm_legacy_misc.o drm_lock.o drm_memory.o drm_scatter.o \ drm_vm.o diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile index 26d974edd5c1..1213852d2015 100644 --- a/drivers/gpu/drm/amd/amdgpu/Makefile +++ b/drivers/gpu/drm/amd/amdgpu/Makefile @@ -38,7 +38,7 @@ ccflags-y := -I$(FULL_AMD_PATH)/include/asic_reg \ -I$(FULL_AMD_DISPLAY_PATH)/amdgpu_dm \ -I$(FULL_AMD_PATH)/amdkfd -ccflags-$(CONFIG_DYNAMIC_DEBUG_CORE) += -DYNAMIC_DEBUG_MODULE +ccflags-$(CONFIG_DRM_USE_DYNAMIC_DEBUG) += -DYNAMIC_DEBUG_MODULE amdgpu-y := amdgpu_drv.o diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index f783d4963d4b..cad14b36d107 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -40,19 +41,38 @@ * __drm_debug: Enable debug output. * Bitmask of DRM_UT_x. See include/drm/drm_print.h for details. */ -unsigned int __drm_debug; +unsigned long __drm_debug; EXPORT_SYMBOL(__drm_debug); -MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug category.\n" -"\t\tBit 0 (0x01) will enable CORE messages (drm core code)\n" -"\t\tBit 1 (0x02) will enable DRIVER messages (drm controller code)\n" -"\t\tBit 2 (0x04) will enable KMS messages (modesetting code)\n" -"\t\tBit 3 (0x08) will enable PRIME messages (prime code)\n" -"\t\tBit 4 (0x10) will enable ATOMIC messages (atomic code)\n" -"\t\tBit 5 (0x20) will enable VBL messages (vblank code)\n" -"\t\tBit 7 (0x80) will enable LEASE messages (leasing code)\n" -"\t\tBit 8 (0x100) will enable DP messages (displayport code)"); -module_param_named(debug, __drm_debug, int, 0600); +#define DRM_DEBUG_DESC \ +"Enable debug output, where each bit enables a debug category.\n" \ +"\t\tBit 0 (0x01) will enable CORE messages (drm core code)\n" \ +"\t\tBit 1 (0x02) will enable DRIVER messages (drm controller code)\n" \ +"\t\tBit 2 (0x04) will enable KMS messages (modesetting code)\n" \ +"\t\tBit 3 (0x08) will enable PRIME messages (prime code)\n" \ +"\t\tBit 4 (0x10) will enable ATOMIC messages (atomic code)\n" \ +"\t\tBit 5 (0x20) will enable VBL messages (vblank code)\n" \ +"\t\tBit 7 (0x80) will enable LEASE messages (leasing code)\n" \ +"\t\tBit 8 (0x100) will enable DP messages (displayport code)." + +#if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) +MODULE_PARM_DESC(debug, DRM_DEBUG_DESC); +module_param_named(debug, __drm_debug, ulong, 0600); +#else +#include +DEFINE_DYNAMIC_DEBUG_CATEGORIES(debug, __drm_debug, + DRM_DEBUG_DESC, + [0] = { DRM_DBG_CAT_CORE }, + [1] = { DRM_DBG_CAT_DRIVER }, + [2] = { DRM_DBG_CAT_KMS }, + [3] = { DRM_DBG_CAT_PRIME }, + [4] = { DRM_DBG_CAT_ATOMIC }, + [5] = { DRM_DBG_CAT_VBL }, + [6] = { DRM_DBG_CAT_STATE }, + [7] = { DRM_DBG_CAT_LEASE }, + [8] = { DRM_DBG_CAT_DP }, + [9] = { DRM_DBG_CAT_DRMRES }); +#endif void __drm_puts_coredump(struct drm_printer *p, const char *str) { @@ -256,8 +276,8 @@ void drm_dev_printk(const struct device *dev, const char *level, } EXPORT_SYMBOL(drm_dev_printk); -void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, - const char *format, ...) +void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, + const char *format, ...) { struct va_format vaf; va_list args; @@ -278,9 +298,9 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, va_end(args); } -EXPORT_SYMBOL(drm_dev_dbg); +EXPORT_SYMBOL(__drm_dev_dbg); -void __drm_dbg(enum drm_debug_category category, const char *format, ...) +void ___drm_dbg(enum drm_debug_category category, const char *format, ...) { struct va_format vaf; va_list args; @@ -297,7 +317,7 @@ void __drm_dbg(enum drm_debug_category category, const char *format, ...) va_end(args); } -EXPORT_SYMBOL(__drm_dbg); +EXPORT_SYMBOL(___drm_dbg); void __drm_err(const char *format, ...) { diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index a313e8a539f6..42f241f4d594 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -301,7 +301,7 @@ i915-y += intel_gvt.o include $(src)/gvt/Makefile endif -ccflags-$(CONFIG_DYNAMIC_DEBUG_CORE) += -DDYNAMIC_DEBUG_MODULE +ccflags-$(CONFIG_DRM_USE_DYNAMIC_DEBUG) += -DDYNAMIC_DEBUG_MODULE obj-$(CONFIG_DRM_I915) += i915.o obj-$(CONFIG_DRM_I915_GVT_KVMGT) += gvt/kvmgt.o diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 15a089a87c22..cc853314f44a 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -35,7 +35,7 @@ #include /* Do *not* use outside of drm_print.[ch]! */ -extern unsigned int __drm_debug; +extern unsigned long __drm_debug; /** * DOC: print @@ -252,15 +252,15 @@ static inline struct drm_printer drm_err_printer(const char *prefix) /** * enum drm_debug_category - The DRM debug categories * - * Each of the DRM debug logging macros use a specific category, and the logging - * is filtered by the drm.debug module parameter. This enum specifies the values - * for the interface. + * The drm.debug logging API[1] has 10 enumerated categories of + * messages, issued by 3 families of macros: 10 drm_dbg_, 8 + * DRM_DEBUG_, and 3 DRM_DEV_DEBUG_. * * Each DRM_DEBUG_ macro logs to DRM_UT_ category, except * DRM_DEBUG() logs to DRM_UT_CORE. * - * Enabling verbose debug messages is done through the drm.debug parameter, each - * category being enabled by a bit: + * Enabling categories of debug messages is done through the drm.debug + * parameter, each category being enabled by a bit: * * - drm.debug=0x1 will enable CORE messages * - drm.debug=0x2 will enable DRIVER messages @@ -268,8 +268,8 @@ static inline struct drm_printer drm_err_printer(const char *prefix) * - ... * - drm.debug=0x1ff will enable all messages * - * An interesting feature is that it's possible to enable verbose logging at - * run-time by echoing the debug value in its sysfs node:: + * It's possible to enable drm.debug logging at run-time by echoing + * the debug value in its sysfs node:: * * # echo 0xf > /sys/module/drm/parameters/debug * @@ -319,6 +319,103 @@ enum drm_debug_category { DRM_UT_DRMRES = 0x200, }; +/** + * DOC: CONFIG_DRM_USE_DYNAMIC_DEBUG - using dyndbg in drm.debug + * + * In the "basic" drm.debug implementation outlined above, each time a + * drm-debug API[1] call is executed, drm_debug_enabled(cat) tests + * drm.debug vs cat before printing. + * + * DYNAMIC_DEBUG (aka: dyndbg) patches pr_debug()s in^out of the + * running kernel, so it can avoid drm_debug_enabled() and skip lots + * of unlikely bit tests. + * + * dyndbg has no concept of category, but we can prepend a + * class-prefix string: "drm:core: ", "drm:kms: ", "drm:driver: " etc, + * to pr_debug's format (at compile time). + * + * Then control the category:: + * + * # echo module drm format "^drm:core: " +p > control + * c: dynamic_debug_exec_queries("format '^drm:core: ' +p", "drm"); + * + * To do this for "basic" | "dyndbg", adaptation adds some macro indirection: + * + * 0. use dyndbg support to define the bits => prefixes map, and creates sysfs node:: + * + * DEFINE_DYNAMIC_DEBUG_CATEGORIES(debug, __drm_debug, + * "drm.debug - overview", + * { [0] = "^drm:core: " }, // note the ^anchor + * { [1] = "^drm:kms: " }, ...); + * + * 1. DRM_DBG_CAT_:: + * + * This set of symbols replaces DRM_UT_ inside the drm-debug API; + * for "basic" it is a copy of DRM_UT_, otherwise they are the set + * of class prefix strings used in pr_debugs (either directly or by + * macro wrappers). + * + * 2. drm_dev_dbg & drm_debug are called by drm.debug API + * + * These are now macros, either forwarding to renamed functions, or + * prepending the class string to the format, and invoking pr_debug + * directly. Since the API is all macros, dyndbg's pr_debug sees the + * actual (broad population of) callsites, and they're all + * individually controllable. + */ +#if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) + +#define __drm_dbg(cls, fmt, ...) \ + ___drm_dbg(cls, fmt, ##__VA_ARGS__) +#define drm_dev_dbg(dev, cls, fmt, ...) \ + __drm_dev_dbg(dev, cls, fmt, ##__VA_ARGS__) + +#define DRM_DBG_CAT_CORE DRM_UT_CORE +#define DRM_DBG_CAT_DRIVER DRM_UT_DRIVER +#define DRM_DBG_CAT_KMS DRM_UT_KMS +#define DRM_DBG_CAT_PRIME DRM_UT_PRIME +#define DRM_DBG_CAT_ATOMIC DRM_UT_ATOMIC +#define DRM_DBG_CAT_VBL DRM_UT_VBL +#define DRM_DBG_CAT_STATE DRM_UT_STATE +#define DRM_DBG_CAT_LEASE DRM_UT_LEASE +#define DRM_DBG_CAT_DP DRM_UT_DP +#define DRM_DBG_CAT_DRMRES DRM_UT_DRMRES + +#else /* CONFIG_DRM_USE_DYNAMIC_DEBUG */ + +/* join prefix + format in cpp so dyndbg can see it */ +#define __drm_dbg(pfx, fmt, ...) \ + pr_debug(pfx fmt, ##__VA_ARGS__) +#define drm_dev_dbg(dev, pfx, fmt, ...) \ + dev_dbg(dev, pfx fmt, ##__VA_ARGS__) + +/** + * enum-ish DRM_DBG_CAT_:: + * + * - DRM_DBG_CAT_CORE "drm:core: " + * - DRM_DBG_CAT_DRIVER "drm:drvr: " + * - DRM_DBG_CAT_KMS "drm:kms: " + * - DRM_DBG_CAT_PRIME "drm:prime: " + * - DRM_DBG_CAT_ATOMIC "drm:atomic: " + * - DRM_DBG_CAT_VBL "drm:vbl: " + * - DRM_DBG_CAT_STATE "drm:state: " + * - DRM_DBG_CAT_LEASE "drm:lease: " + * - DRM_DBG_CAT_DP "drm:dp: " + * - DRM_DBG_CAT_DRMRES "drm:res: " + */ +#define DRM_DBG_CAT_CORE "drm:core: " +#define DRM_DBG_CAT_DRIVER "drm:drvr: " +#define DRM_DBG_CAT_KMS "drm:kms: " +#define DRM_DBG_CAT_PRIME "drm:prime: " +#define DRM_DBG_CAT_ATOMIC "drm:atomic: " +#define DRM_DBG_CAT_VBL "drm:vbl: " +#define DRM_DBG_CAT_STATE "drm:state: " +#define DRM_DBG_CAT_LEASE "drm:lease: " +#define DRM_DBG_CAT_DP "drm:dp: " +#define DRM_DBG_CAT_DRMRES "drm:res: " + +#endif /* CONFIG_DRM_USE_DYNAMIC_DEBUG */ + static inline bool drm_debug_enabled(enum drm_debug_category category) { return unlikely(__drm_debug & category); @@ -334,8 +431,8 @@ __printf(3, 4) void drm_dev_printk(const struct device *dev, const char *level, const char *format, ...); __printf(3, 4) -void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, - const char *format, ...); +void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, + const char *format, ...); /** * DRM_DEV_ERROR() - Error output. @@ -376,6 +473,16 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, } \ }) +/** + * DRM debug API - library of macros to issue categorized syslog messages + * + * multiple flavors:: + * - DRM_DEV_DEBUG<,_DRIVER,_KMS> + * - drm_dbg_ + * - DRM_DEBUG_KMS_RATELIMITED + */ + /** * DRM_DEV_DEBUG() - Debug output for generic drm code * @@ -383,7 +490,7 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, * @fmt: printf() like format string. */ #define DRM_DEV_DEBUG(dev, fmt, ...) \ - drm_dev_dbg(dev, DRM_UT_CORE, fmt, ##__VA_ARGS__) + drm_dev_dbg(dev, DRM_DBG_CAT_CORE, fmt, ##__VA_ARGS__) /** * DRM_DEV_DEBUG_DRIVER() - Debug output for vendor specific part of the driver * @@ -391,7 +498,7 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, * @fmt: printf() like format string. */ #define DRM_DEV_DEBUG_DRIVER(dev, fmt, ...) \ - drm_dev_dbg(dev, DRM_UT_DRIVER, fmt, ##__VA_ARGS__) + drm_dev_dbg(dev, DRM_DBG_CAT_DRIVER, fmt, ##__VA_ARGS__) /** * DRM_DEV_DEBUG_KMS() - Debug output for modesetting code * @@ -399,7 +506,7 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, * @fmt: printf() like format string. */ #define DRM_DEV_DEBUG_KMS(dev, fmt, ...) \ - drm_dev_dbg(dev, DRM_UT_KMS, fmt, ##__VA_ARGS__) + drm_dev_dbg(dev, DRM_DBG_CAT_KMS, fmt, ##__VA_ARGS__) /* * struct drm_device based logging @@ -441,27 +548,26 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, #define drm_err_ratelimited(drm, fmt, ...) \ __drm_printk((drm), err, _ratelimited, "*ERROR* " fmt, ##__VA_ARGS__) - #define drm_dbg_core(drm, fmt, ...) \ - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_CORE, fmt, ##__VA_ARGS__) + drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CAT_CORE, fmt, ##__VA_ARGS__) #define drm_dbg(drm, fmt, ...) \ - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRIVER, fmt, ##__VA_ARGS__) + drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CAT_DRIVER, fmt, ##__VA_ARGS__) #define drm_dbg_kms(drm, fmt, ...) \ - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_KMS, fmt, ##__VA_ARGS__) + drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CAT_KMS, fmt, ##__VA_ARGS__) #define drm_dbg_prime(drm, fmt, ...) \ - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_PRIME, fmt, ##__VA_ARGS__) + drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CAT_PRIME, fmt, ##__VA_ARGS__) #define drm_dbg_atomic(drm, fmt, ...) \ - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__) + drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CAT_ATOMIC, fmt, ##__VA_ARGS__) #define drm_dbg_vbl(drm, fmt, ...) \ - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_VBL, fmt, ##__VA_ARGS__) + drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CAT_VBL, fmt, ##__VA_ARGS__) #define drm_dbg_state(drm, fmt, ...) \ - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_STATE, fmt, ##__VA_ARGS__) + drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CAT_STATE, fmt, ##__VA_ARGS__) #define drm_dbg_lease(drm, fmt, ...) \ - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_LEASE, fmt, ##__VA_ARGS__) + drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CAT_LEASE, fmt, ##__VA_ARGS__) #define drm_dbg_dp(drm, fmt, ...) \ - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DP, fmt, ##__VA_ARGS__) + drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CAT_DP, fmt, ##__VA_ARGS__) #define drm_dbg_drmres(drm, fmt, ...) \ - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRMRES, fmt, ##__VA_ARGS__) + drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CAT_DRMRES, fmt, ##__VA_ARGS__) /* @@ -471,7 +577,7 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, */ __printf(2, 3) -void __drm_dbg(enum drm_debug_category category, const char *format, ...); +void ___drm_dbg(enum drm_debug_category category, const char *format, ...); __printf(1, 2) void __drm_err(const char *format, ...); @@ -500,29 +606,29 @@ void __drm_err(const char *format, ...); #define DRM_ERROR_RATELIMITED(fmt, ...) \ DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__) -#define DRM_DEBUG(fmt, ...) \ - __drm_dbg(DRM_UT_CORE, fmt, ##__VA_ARGS__) +#define DRM_DEBUG(fmt, ...) \ + __drm_dbg(DRM_DBG_CAT_CORE, fmt, ##__VA_ARGS__) #define DRM_DEBUG_DRIVER(fmt, ...) \ - __drm_dbg(DRM_UT_DRIVER, fmt, ##__VA_ARGS__) + __drm_dbg(DRM_DBG_CAT_DRIVER, fmt, ##__VA_ARGS__) #define DRM_DEBUG_KMS(fmt, ...) \ - __drm_dbg(DRM_UT_KMS, fmt, ##__VA_ARGS__) + __drm_dbg(DRM_DBG_CAT_KMS, fmt, ##__VA_ARGS__) #define DRM_DEBUG_PRIME(fmt, ...) \ - __drm_dbg(DRM_UT_PRIME, fmt, ##__VA_ARGS__) + __drm_dbg(DRM_DBG_CAT_PRIME, fmt, ##__VA_ARGS__) #define DRM_DEBUG_ATOMIC(fmt, ...) \ - __drm_dbg(DRM_UT_ATOMIC, fmt, ##__VA_ARGS__) + __drm_dbg(DRM_DBG_CAT_ATOMIC, fmt, ##__VA_ARGS__) #define DRM_DEBUG_VBL(fmt, ...) \ - __drm_dbg(DRM_UT_VBL, fmt, ##__VA_ARGS__) + __drm_dbg(DRM_DBG_CAT_VBL, fmt, ##__VA_ARGS__) #define DRM_DEBUG_LEASE(fmt, ...) \ - __drm_dbg(DRM_UT_LEASE, fmt, ##__VA_ARGS__) + __drm_dbg(DRM_DBG_CAT_LEASE, fmt, ##__VA_ARGS__) #define DRM_DEBUG_DP(fmt, ...) \ - __drm_dbg(DRM_UT_DP, fmt, ## __VA_ARGS__) + __drm_dbg(DRM_DBG_CAT_DP, fmt, ## __VA_ARGS__) #define __DRM_DEFINE_DBG_RATELIMITED(category, drm, fmt, ...) \ ({ \ @@ -530,7 +636,8 @@ void __drm_err(const char *format, ...); const struct drm_device *drm_ = (drm); \ \ if (drm_debug_enabled(DRM_UT_ ## category) && __ratelimit(&rs_)) \ - drm_dev_printk(drm_ ? drm_->dev : NULL, KERN_DEBUG, fmt, ## __VA_ARGS__); \ + drm_dev_dbg((drm_) ? (drm_)->dev : NULL, \ + DRM_DBG_CAT_ ## category, fmt, ##__VA_ARGS__); \ }) #define drm_dbg_kms_ratelimited(drm, fmt, ...) \ From patchwork Wed Oct 27 04:36:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12586385 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4CCBC43217 for ; Wed, 27 Oct 2021 04:38:10 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 976BC60F70 for ; Wed, 27 Oct 2021 04:38:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 976BC60F70 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A21836E52D; Wed, 27 Oct 2021 04:37:30 +0000 (UTC) Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0B9A78932D; Wed, 27 Oct 2021 04:37:26 +0000 (UTC) Received: by mail-io1-xd2a.google.com with SMTP id r194so2089698iod.7; Tue, 26 Oct 2021 21:37:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7iYW4I4CStTbC9vQQqx1wbnaW7QfaWOV+gu+PhQHi68=; b=bwhmmQWaeTqGmfGhryL8vuXPioJB6//CiznbOIm2iZRVPl+AcEv1t65GnJrm3HtNuO ZBH7pXp8+qRNbXE0VVi/gb4lkEat831GjKilUCXymAF27Fy+r0vJhL6Dmp+SNaZw8ycM 4c9X1c6sUb5qNz8/QUN6Ih55N5s51IrpLl9SeYAQ3QS5NEGA0PHUd4ksB3mv2MnovIZ3 KjVo1J3ALQUK5ZmRSq89qyFRBA1ms9LJRBK7gsKxM7ZmJf4MXYNHgHQYJTL67sUKr2vo vjLKq6FIwKO4/v+3wGYJlbk+EbMI6EETArObjvi/15aDCG2Yo274Ng/+NSGiwvsKGvDC nIyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7iYW4I4CStTbC9vQQqx1wbnaW7QfaWOV+gu+PhQHi68=; b=rsKQv/9J0G2Q3yKv0b06cFumIhd2Xm2sUMNYpbLI1HZq8wDKaDNYqeiWfjXEhxVWB2 FAzBo7UqyC7B1x9mtPdE+T3lnepYV3Jp6toxFKtjrrJk7bADvkH82dDHS4YdxO38+sS4 rkUmWl/nF9gbFmmyIw84/wrU5o6sLmv5r1N8dmcZsOx0aBs+HzEtoc2YfmbR55HpTg8H NA1FdYKkoc43oWQHbs4zw2AlFIkcXtLjXH5d2JZG5PrirVirmuTRWKlNiFBfPtkKLmqa 5ZG4YCsLy5t2H1+5YOqz6xMoSsnjIWQuEj5c2EIng5pr2tgHjSgxedJXSqylnx3avz4v sYMQ== X-Gm-Message-State: AOAM531EFarbdn2E4xh+xGFp0IA2vnPywbQJz+52xFzLuGu/3zjYL99E 7NPQtuAqC/s1WN8y/js6dc31ywDKag4= X-Google-Smtp-Source: ABdhPJz4nVn5zyXeRfn7gHHvpvDCVU+3Y3rIZxzBfd8KgODE1Ou7nwBG8jJvpQ1lwq6FuX/hS41vVQ== X-Received: by 2002:a05:6602:158a:: with SMTP id e10mr18367339iow.157.1635309444000; Tue, 26 Oct 2021 21:37:24 -0700 (PDT) Received: from samwise.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id a15sm2030404ilj.81.2021.10.26.21.37.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 21:37:23 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk, daniel.vetter@ffwll.ch, seanpaul@chromium.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Date: Tue, 26 Oct 2021 22:36:42 -0600 Message-Id: <20211027043645.153133-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211027043645.153133-1-jim.cromie@gmail.com> References: <20211027043645.153133-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v9 07/10] drm_print: instrument drm_debug_enabled X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Duplicate drm_debug_enabled() code into both "basic" and "dyndbg" ifdef branches. Then add a pr_debug("todo: ...") into the "dyndbg" branch. Then convert the "dyndbg" branch's code to a macro, so that the pr_debug() get its callsite info from the invoking function, instead of from drm_debug_enabled() itself. This gives us unique callsite info for the 8 remaining users of drm_debug_enabled(), and lets us enable them individually to see how much logging traffic they generate. The oft-visited callsites can then be reviewed for runtime cost and possible optimizations. Heres what we get: bash-5.1# modprobe drm dyndbg: 384 debug prints in module drm bash-5.1# grep todo: /proc/dynamic_debug/control drivers/gpu/drm/drm_edid.c:1843 [drm]connector_bad_edid =_ "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_print.c:309 [drm]___drm_dbg =p "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_print.c:286 [drm]__drm_dev_dbg =p "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_vblank.c:1491 [drm]drm_vblank_restore =_ "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_vblank.c:787 [drm]drm_crtc_vblank_helper_get_vblank_timestamp_internal =_ "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_vblank.c:410 [drm]drm_crtc_accurate_vblank_count =_ "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_atomic_uapi.c:1457 [drm]drm_mode_atomic_ioctl =_ "todo: maybe avoid via dyndbg\012" drivers/gpu/drm/drm_edid_load.c:178 [drm]edid_load =_ "todo: maybe avoid via dyndbg\012" At quick glance, edid won't qualify, drm_print might, drm_vblank is strongest chance, maybe atomic-ioctl too. Signed-off-by: Jim Cromie --- --- include/drm/drm_print.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index cc853314f44a..36373a91c9e0 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -381,6 +381,11 @@ enum drm_debug_category { #define DRM_DBG_CAT_DP DRM_UT_DP #define DRM_DBG_CAT_DRMRES DRM_UT_DRMRES +static inline bool drm_debug_enabled(enum drm_debug_category category) +{ + return unlikely(__drm_debug & category); +} + #else /* CONFIG_DRM_USE_DYNAMIC_DEBUG */ /* join prefix + format in cpp so dyndbg can see it */ @@ -414,12 +419,13 @@ enum drm_debug_category { #define DRM_DBG_CAT_DP "drm:dp: " #define DRM_DBG_CAT_DRMRES "drm:res: " -#endif /* CONFIG_DRM_USE_DYNAMIC_DEBUG */ +#define drm_debug_enabled(category) \ + ({ \ + pr_debug("todo: maybe avoid via dyndbg\n"); \ + unlikely(__drm_debug & (category)); \ + }) -static inline bool drm_debug_enabled(enum drm_debug_category category) -{ - return unlikely(__drm_debug & category); -} +#endif /* CONFIG_DRM_USE_DYNAMIC_DEBUG */ /* * struct device based logging @@ -569,7 +575,6 @@ void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, #define drm_dbg_drmres(drm, fmt, ...) \ drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CAT_DRMRES, fmt, ##__VA_ARGS__) - /* * printk based logging * From patchwork Wed Oct 27 04:36:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12586359 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1B0CC433FE for ; Wed, 27 Oct 2021 04:38:04 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9129D610A0 for ; Wed, 27 Oct 2021 04:38:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9129D610A0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A7FC08932D; Wed, 27 Oct 2021 04:37:28 +0000 (UTC) Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2A91889381; Wed, 27 Oct 2021 04:37:26 +0000 (UTC) Received: by mail-io1-xd2b.google.com with SMTP id b188so2072902iof.8; Tue, 26 Oct 2021 21:37:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rzpxwtlIwoj67EGOMTCMyIvdrvCgfhRx8udWDZV8HsY=; b=ZzNTZP3Jrfzjpt0p0fyrq0Bsut788iG3hng8fquNO0AkQMGsVkeNKGMK8eT/Tm5CM0 keCNXyrIIWQnSAp5xD8rY5BJYkTynAxTzQ6G1R/3FJEP+EJpOdEruJexUl4Fey2uHuTI MUhzG0PLrTlGgba5b/NF/ADcCO0ZYrfYEMeaKrRhV1mfyKMB5ja99XwG6mKSpdC+/5NP 9PpWc28X1WHeeQTYeHHkdqq2Bm1hjXVt6pbLrFqMdtqvTsMLD7MtdQth7LI/pTdI8PsC C6JOfMBu9XAlNpgxbcmlYD6wmFDGrxp22yKzZ6EG8Bj7fjnopERa/MOyT8R0eXv5T1kL b7fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rzpxwtlIwoj67EGOMTCMyIvdrvCgfhRx8udWDZV8HsY=; b=T6cg5hG0K5DVoZzAlgOI4tQ82FKp0PsunxmotMWAVocmVNXBFIHhHKYkIog3fA3u6r J/YwH6ZzYz38nyASTymcmwdHge/WAUQREPDqd9w+zBPh+c+HDCkJ8rSEIPl4cKnZ9meA 8S0kf8P9BVqMFFug4nhjYJ0KvqkW4JoUfTtdgihegHXZX5oVotJUVdYnbIAEKXFkzaY4 z/6niqep2PLFzA4XECqXlhsH0shH3QOpwyyX7b71wHGwtogsFpXJkBkBmBR1OI2mmEuS +/Ddeymwnu2ZqOgfnCir1hxO1L7lgBK3GqMRWwMmvfqmAWBqoJqljDhUuiMJUzQSMvT4 fy6A== X-Gm-Message-State: AOAM533Jkhh65Q7ck+7SZya9+yv2CgW7skKY/7dBZSzUnQQf9l3/EfzK wGRGzRXE3hc+yKEl4iH0TQE= X-Google-Smtp-Source: ABdhPJyp6NNndGTMee0w75srXLDD78fV52fY91vsDOmeXqvxolmgd8qXFQV7T2CiD403tGvB69Rlew== X-Received: by 2002:a05:6602:27c2:: with SMTP id l2mr17764030ios.147.1635309445148; Tue, 26 Oct 2021 21:37:25 -0700 (PDT) Received: from samwise.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id a15sm2030404ilj.81.2021.10.26.21.37.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 21:37:24 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk, daniel.vetter@ffwll.ch, seanpaul@chromium.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Date: Tue, 26 Oct 2021 22:36:43 -0600 Message-Id: <20211027043645.153133-9-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211027043645.153133-1-jim.cromie@gmail.com> References: <20211027043645.153133-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v9 08/10] dyndbg: add print-to-tracefs, selftest with it - RFC X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Sean Paul proposed, in: https://patchwork.freedesktop.org/series/78133/ drm/trace: Mirror DRM debug logs to tracefs His patchset's objective is to be able to independently steer some of the drm.debug stream to an alternate tracing destination, by splitting drm_debug_enabled() into syslog & trace flavors, and enabling them separately. 2 advantages were identified: 1- syslog is heavyweight, tracefs is much lighter 2- separate selection of enabled categories means less traffic Dynamic-Debug can do 2nd exceedingly well: A- all work is behind jump-label's NOOP, zero off cost. B- exact site selectivity, precisely the useful traffic. can tailor enabled set interactively, at shell. Since the tracefs interface is effective for drm (the threads suggest so), adding that interface to dynamic-debug has real potential for everyone including drm. if CONFIG_TRACING: Grab Sean's trace_init/cleanup code, use it to provide tracefs available by default to all pr_debugs. This will likely need some further per-module treatment; perhaps something reflecting hierarchy of module,file,function,line, maybe with a tuned flattening. endif CONFIG_TRACING Add a new +T flag to enable tracing, independent of +p, and add and use 3 macros: dyndbg_site_is_enabled/logging/tracing(), to encapsulate the flag checks. Existing code treats T like other flags. Add ddebug_validate_flags() as last step in ddebug_parse_flags(). Its only job is to fail on +T for non-CONFIG_TRACING builds. It only sees the new flags, and cannot validate specific state transitions. This is fine, since we have no need for that; such a test would have to be done in ddebug_change(), which actually updates the callsites. ddebug_change() adjusts the static-key-enable/disable condition to use _DPRINTK_ENABLED / abstraction macros. dynamic_emit_prefix() now gates on _DPRINTK_ENABLED too, as an optimization but mostly to allow decluttering of its users. __dynamic_pr_debug() etal get minor changes: - call dynamic_emit_prefix() 1st, _enabled() optimizes. - if (T) call trace_array_printk - if (!p) go around original printk code. done to minimize diff, goto-ectomy + reindent later/separately - share vaf across p|T WRT _dev, I skipped all the specific dev_emit_prefix additions for now. tracefs is a fast customer with different needs, its not clear that pretty device-ID-ish strings is useful tracefs content (on ingest), or that couldn't be done more efficiently while analysing or postprocesing the tracefs buffer. SELFTEST: test_dynamic_debug.ko: Uses the tracer facility to implement a kernel module selftest. TODO: Earlier core code had (tracerfn)() indirection, allowing a plugin side-effector we could test the results of. ATM all the tests which count +T'd callsite executions (and which expect >0) are failing. Now it needs a rethink to test from userspace, rather than the current test-once at module-load. It needs a parameters/testme button. So remainder of this is a bit stale .... - A custom tracer counts the number of calls (of T-enabled pr_debugs), - do_debugging(x) calls a set of categorized pr_debugs x times - test registers the tracer on the module then iteratively: manipulates dyndbg states via query-cmds, mostly format ^prefix runs do_debugging() counts enabled callsite executions reports mismatches - modprobe test_dynamic_debug use_bad_tracer=1 attaches a bad/recursive tracer Bad Things (did) Happen. has thrown me interesting panics. cannot replicate atm. RFC: (DONE) The "tracer" interface probably needs work and a new name. It is only 1/2 way towards a real tracefs interface; and the code I lifted from Sean Paul in the next patch could be implemented in dynamic_debug.c instead, and made available for all pr_debug users. This would also eliminate need for dynamic_debug_(un)register_tracer(), since dyndbg could just provide it when TRACING is on. NOTES: $> modprobe test_dynamic_debug dyndbg=+p it fails 3/29 tests. havent looked at why. $> modprobe test_dynamic_debug use_bad_tracer=1 Earlier in dev, bad_tracer() exploded in recursion, I havent been able to replicate that lately. Signed-off-by: Jim Cromie --- v4: (rfc) . fix printk (to syslog) needs if (+p), since +T also enables . add prototypes for un/register_aux_print . change iface names: s/aux_print/tracer/ . also s/trace_print/tracer/ . struct va_format *vaf - tighten further ? v5: (rfc) . fix "too many arguments to function", and name the args: int (*aux_print)(const char *fmt, char *prefix, char *label, void *); prefix : is a slot for dynamic_emit_prefix, or for custom buffer insert label : for builtin-caller used by drm-trace-print void* : vaf, add type constraint later. v6: (rfc) . more test in test module . add mod arg to *register, following exec_queries pattern . move code . move kdoc to c from h v7: (rfc) . simplify tracer prototype (probably needs more tailoring) . separate from dd-exec-queries . drop struct _ddebug.tracer field . 1 per module registration, into hash . rework test_dynamic_debug ... vlatest: . drop all register_tracer code, and supporting hash code. . copy trace init/cleanup from Seans drm patch use it to provide tracing for all clients, wo needing registration . add dyndbg_site_is_enabled|logging|tracing macros, declutter with them. --- .../admin-guide/dynamic-debug-howto.rst | 7 +- MAINTAINERS | 1 + drivers/gpu/drm/drm_print.c | 1 + include/linux/dynamic_debug.h | 11 +- lib/Kconfig.debug | 11 + lib/Makefile | 1 + lib/dynamic_debug.c | 127 ++++++++-- lib/test_dynamic_debug.c | 222 ++++++++++++++++++ 8 files changed, 355 insertions(+), 26 deletions(-) create mode 100644 lib/test_dynamic_debug.c diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst index b119b8277b3e..48d32782bb11 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -227,7 +227,8 @@ of the characters:: The flags are:: - p enables the pr_debug() callsite. + p enables the pr_debug() callsite to syslog + T enables the pr_debug() callsite to tracefs f Include the function name in the printed message l Include line number in the printed message m Include module name in the printed message @@ -240,8 +241,8 @@ have meaning, other flags ignored. For display, the flags are preceded by ``=`` (mnemonic: what the flags are currently equal to). -Note the regexp ``^[-+=][flmpt_]+$`` matches a flags specification. -To clear all flags at once, use ``=_`` or ``-flmpt``. +Note the regexp ``^[-+=][flmptT_]+$`` matches a flags specification. +To clear all flags at once, use ``=_`` or ``-flmptT``. Debug messages during Boot Process diff --git a/MAINTAINERS b/MAINTAINERS index f26920f0fa65..3f03738a5339 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6561,6 +6561,7 @@ M: Jason Baron S: Maintained F: include/linux/dynamic_debug.h F: lib/dynamic_debug.c +F: lib/test_dynamic_debug.c DYNAMIC INTERRUPT MODERATION M: Tal Gilboa diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index cad14b36d107..ce662d0f339b 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index a9787544aef0..896848f546e6 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -28,15 +28,24 @@ struct _ddebug { */ #define _DPRINTK_FLAGS_NONE 0 #define _DPRINTK_FLAGS_PRINT (1<<0) /* printk() a message using the format */ +#define _DPRINTK_FLAGS_TRACE (1<<5) /* trace_printk() the message */ +#define _DPRINTK_ENABLED (_DPRINTK_FLAGS_PRINT | _DPRINTK_FLAGS_TRACE) + +#define dyndbg_site_is_enabled(desc) (!!(desc->flags & _DPRINTK_ENABLED)) +#define dyndbg_site_is_logging(desc) (!!(desc->flags & _DPRINTK_FLAGS_PRINT)) +#define dyndbg_site_is_tracing(desc) (!!(desc->flags & _DPRINTK_FLAGS_TRACE)) + #define _DPRINTK_FLAGS_INCL_MODNAME (1<<1) #define _DPRINTK_FLAGS_INCL_FUNCNAME (1<<2) #define _DPRINTK_FLAGS_INCL_LINENO (1<<3) #define _DPRINTK_FLAGS_INCL_TID (1<<4) -#define _DPRINTK_FLAGS_INCL_ANY \ +#define _DPRINTK_FLAGS_INCL_ANY \ (_DPRINTK_FLAGS_INCL_MODNAME | _DPRINTK_FLAGS_INCL_FUNCNAME |\ _DPRINTK_FLAGS_INCL_LINENO | _DPRINTK_FLAGS_INCL_TID) +#define dyndbg_site_is_decorated(desc) (!!(desc->flags & _DPRINTK_FLAGS_INCL_ANY)) + #if defined DEBUG #define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINT #else diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 2a9b6dcdac4f..5d551eeb8fd2 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -2468,6 +2468,17 @@ config TEST_STATIC_KEYS If unsure, say N. +config TEST_DYNAMIC_DEBUG + tristate "Test DYNAMIC_DEBUG" + depends on m + depends on DYNAMIC_DEBUG + help + This module registers a tracer callback to count enabled + pr_debugs in a 'do_debugging' function, then alters their + enablements, calls the function, and compares counts. + + If unsure, say N. + config TEST_KMOD tristate "kmod stress tester" depends on m diff --git a/lib/Makefile b/lib/Makefile index a841be5244ac..8f2085a5e94c 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -82,6 +82,7 @@ obj-$(CONFIG_TEST_SORT) += test_sort.o obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o +obj-$(CONFIG_TEST_DYNAMIC_DEBUG) += test_dynamic_debug.o obj-$(CONFIG_TEST_PRINTF) += test_printf.o obj-$(CONFIG_TEST_SCANF) += test_scanf.o obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 54a6a872106d..f19465b114cd 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -72,6 +73,7 @@ static LIST_HEAD(ddebug_tables); static int verbose; module_param(verbose, int, 0644); + /* Return the path relative to source root */ static inline const char *trim_prefix(const char *path) { @@ -85,6 +87,7 @@ static inline const char *trim_prefix(const char *path) static struct { unsigned flag:8; char opt_char; } opt_array[] = { { _DPRINTK_FLAGS_PRINT, 'p' }, + { _DPRINTK_FLAGS_TRACE, 'T' }, { _DPRINTK_FLAGS_INCL_MODNAME, 'm' }, { _DPRINTK_FLAGS_INCL_FUNCNAME, 'f' }, { _DPRINTK_FLAGS_INCL_LINENO, 'l' }, @@ -205,11 +208,12 @@ static int ddebug_change(const struct ddebug_query *query, newflags = (dp->flags & modifiers->mask) | modifiers->flags; if (newflags == dp->flags) continue; + #ifdef CONFIG_JUMP_LABEL - if (dp->flags & _DPRINTK_FLAGS_PRINT) { - if (!(modifiers->flags & _DPRINTK_FLAGS_PRINT)) + if (dyndbg_site_is_enabled(dp)) { + if (!(dyndbg_site_is_enabled(modifiers))) static_branch_disable(&dp->key.dd_key_true); - } else if (modifiers->flags & _DPRINTK_FLAGS_PRINT) + } else if (dyndbg_site_is_enabled(modifiers)) static_branch_enable(&dp->key.dd_key_true); #endif dp->flags = newflags; @@ -427,6 +431,16 @@ static int ddebug_parse_query(char *words[], int nwords, return 0; } +static int ddebug_validate_flags(struct flag_settings *modifiers) +{ +#if !defined(CONFIG_TRACING) + if (dyndbg_site_is_tracing(modifiers)) { + WARN_ONCE(1, "cannot enable T, CONFIG_TRACE=n\n"); + return -EINVAL; + } +#endif + return 0; +} /* * Parse `str' as a flags specification, format [-+=][p]+. * Sets up *maskp and *flagsp to be used when changing the @@ -479,7 +493,7 @@ static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers) } vpr_info("*flagsp=0x%x *maskp=0x%x\n", modifiers->flags, modifiers->mask); - return 0; + return ddebug_validate_flags(modifiers); } static int ddebug_exec_query(char *query_string, const char *modname) @@ -694,11 +708,24 @@ static char *__dynamic_emit_prefix(const struct _ddebug *desc, char *buf) static inline char *dynamic_emit_prefix(struct _ddebug *desc, char *buf) { - if (unlikely(desc->flags & _DPRINTK_FLAGS_INCL_ANY)) + if (unlikely(dyndbg_site_is_enabled(desc) && + dyndbg_site_is_decorated(desc))) return __dynamic_emit_prefix(desc, buf); return buf; } +static struct trace_array *trace_arr; + +#if !defined(CONFIG_TRACING) +/* private stub for 4 users below */ +static inline int __printf(3, 0) + trace_array_printk(struct trace_array *tr, unsigned long ip, + const char *fmt, ...) +{ + return 0; +} +#endif + void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) { va_list args; @@ -713,7 +740,13 @@ void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) vaf.fmt = fmt; vaf.va = &args; - printk(KERN_DEBUG "%s%pV", dynamic_emit_prefix(descriptor, buf), &vaf); + dynamic_emit_prefix(descriptor, buf); + + if (dyndbg_site_is_tracing(descriptor)) + trace_array_printk(trace_arr, _THIS_IP_, "%s%pV", buf, &vaf); + + if (dyndbg_site_is_logging(descriptor)) + printk(KERN_DEBUG "%s%pV", buf, &vaf); va_end(args); } @@ -724,6 +757,7 @@ void __dynamic_dev_dbg(struct _ddebug *descriptor, { struct va_format vaf; va_list args; + char buf[PREFIX_SIZE] = ""; BUG_ON(!descriptor); BUG_ON(!fmt); @@ -733,17 +767,21 @@ void __dynamic_dev_dbg(struct _ddebug *descriptor, vaf.fmt = fmt; vaf.va = &args; + dynamic_emit_prefix(descriptor, buf); + + if (dyndbg_site_is_tracing(descriptor)) + trace_array_printk(trace_arr, _THIS_IP_, "%s%pV", buf, &vaf); + + if (!dyndbg_site_is_logging(descriptor)) + goto out; + if (!dev) { printk(KERN_DEBUG "(NULL device *): %pV", &vaf); } else { - char buf[PREFIX_SIZE] = ""; - dev_printk_emit(LOGLEVEL_DEBUG, dev, "%s%s %s: %pV", - dynamic_emit_prefix(descriptor, buf), - dev_driver_string(dev), dev_name(dev), - &vaf); + buf, dev_driver_string(dev), dev_name(dev), &vaf); } - +out: va_end(args); } EXPORT_SYMBOL(__dynamic_dev_dbg); @@ -755,6 +793,7 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, { struct va_format vaf; va_list args; + char buf[PREFIX_SIZE] = ""; BUG_ON(!descriptor); BUG_ON(!fmt); @@ -764,12 +803,17 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, vaf.fmt = fmt; vaf.va = &args; - if (dev && dev->dev.parent) { - char buf[PREFIX_SIZE] = ""; + dynamic_emit_prefix(descriptor, buf); + + if (dyndbg_site_is_tracing(descriptor)) + trace_array_printk(trace_arr, _THIS_IP_, "%s%pV", buf, &vaf); + if (!dyndbg_site_is_logging(descriptor)) + goto out; + + if (dev && dev->dev.parent) { dev_printk_emit(LOGLEVEL_DEBUG, dev->dev.parent, - "%s%s %s %s%s: %pV", - dynamic_emit_prefix(descriptor, buf), + "%s%s %s %s%s: %pV", buf, dev_driver_string(dev->dev.parent), dev_name(dev->dev.parent), netdev_name(dev), netdev_reg_state(dev), @@ -780,7 +824,7 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, } else { printk(KERN_DEBUG "(NULL net_device): %pV", &vaf); } - +out: va_end(args); } EXPORT_SYMBOL(__dynamic_netdev_dbg); @@ -794,18 +838,24 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, { struct va_format vaf; va_list args; + char buf[PREFIX_SIZE] = ""; va_start(args, fmt); vaf.fmt = fmt; vaf.va = &args; - if (ibdev && ibdev->dev.parent) { - char buf[PREFIX_SIZE] = ""; + dynamic_emit_prefix(descriptor, buf); + + if (dyndbg_site_is_tracing(descriptor)) + trace_array_printk(trace_arr, _THIS_IP_, "%s%pV", buf, &vaf); + + if (!dyndbg_site_is_logging(descriptor)) + goto out; + if (ibdev && ibdev->dev.parent) { dev_printk_emit(LOGLEVEL_DEBUG, ibdev->dev.parent, - "%s%s %s %s: %pV", - dynamic_emit_prefix(descriptor, buf), + "%s%s %s %s: %pV", buf, dev_driver_string(ibdev->dev.parent), dev_name(ibdev->dev.parent), dev_name(&ibdev->dev), @@ -815,7 +865,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, } else { printk(KERN_DEBUG "(NULL ib_device): %pV", &vaf); } - +out: va_end(args); } EXPORT_SYMBOL(__dynamic_ibdev_dbg); @@ -1130,6 +1180,35 @@ static void ddebug_remove_all_tables(void) mutex_unlock(&ddebug_lock); } +#if defined(CONFIG_TRACING) + +static void ddebug_trace_cleanup(void) +{ + if (trace_arr) { + trace_array_put(trace_arr); + trace_array_destroy(trace_arr); + trace_arr = NULL; + } +} + +static void ddebug_trace_init(void) +{ + int ret; + + trace_arr = trace_array_get_by_name("dyndbg-tracefs"); + if (!trace_arr) + return; + + ret = trace_array_init_printk(trace_arr); + if (ret) + ddebug_trace_cleanup(); +} + +#else +static inline void ddebug_trace_init(void) {} +static inline void ddebug_trace_cleanup(void) {} +#endif + static __initdata int ddebug_init_success; static int __init dynamic_debug_init_control(void) @@ -1172,6 +1251,9 @@ static int __init dynamic_debug_init(void) ddebug_init_success = 1; return 0; } + + ddebug_trace_init(); + iter = __start___dyndbg; modname = iter->modname; iter_start = iter; @@ -1223,6 +1305,7 @@ static int __init dynamic_debug_init(void) out_err: ddebug_remove_all_tables(); + ddebug_trace_cleanup(); return 0; } /* Allow early initialization for boot messages via boot param */ diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c new file mode 100644 index 000000000000..dd41a09fd9c8 --- /dev/null +++ b/lib/test_dynamic_debug.c @@ -0,0 +1,222 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Kernel module for testing dynamic_debug + * + * Authors: + * Jim Cromie + */ + +/* + * test-setup: use trace_print attachment interface as a test harness, + * define a custom trace_printer which counts invocations, and a + * pr_debug event generator function which calls a set of categorized + * pr_debugs. + * test-run: manipulate the pr_debug's enablement, run the event + * generator, and check for the expected side effects. + */ + +#define pr_fmt(fmt) "test_dd: " fmt + +#include + +static int hit_ct; +static int test_ct; +static int errors; + +static int __verbose; +module_param_named(verbose, __verbose, int, 0444); +MODULE_PARM_DESC(verbose, "enable print from trace (output verify)"); + +static int __bad_tracer; +module_param_named(use_bad_tracer, __bad_tracer, int, 0444); +MODULE_PARM_DESC(use_bad_tracer, + "use broken tracer, recursing with pr_debug\n" + "\tonly works at modprobe time\n"); + +static void (*my_tracer)(const char *lbl, struct va_format *vaf); + +static void good_tracer(const char *lbl, struct va_format *vaf) +{ + hit_ct++; + + if (__verbose) + pr_notice("%s%pV", lbl, vaf); +} + +static void bad_tracer(const char *lbl, struct va_format *vaf) +{ + hit_ct++; + if (__verbose) + pr_notice("%s%pV", lbl, vaf); + + pr_debug("%s.%pV", lbl, vaf); +} + +static void pick_tracer(void) +{ + if (__bad_tracer) { + pr_notice("using bad tracer - fails hit count tests\n"); + my_tracer = bad_tracer; + } else + my_tracer = good_tracer; +} + +static int expect_count(int want, const char *story) +{ + test_ct++; + if (want != hit_ct) { + pr_err("nok %d: want %d, got %d: %s\n", test_ct, want, hit_ct, story); + errors++; + hit_ct = 0; + return 1; + } + pr_info("ok %d: hits %d, on <%s>\n", test_ct, want, story); + hit_ct = 0; + return 0; +} + +/* call pr_debug (4 * reps) + 2 times, for tracer side-effects */ +static void do_debugging(int reps) +{ + int i; + + pr_debug("Entry:\n"); + pr_info("%s %d time(s)\n", __func__, reps); + for (i = 0; i < reps; i++) { + pr_debug("hi: %d\n", i); + pr_debug("mid: %d\n", i); + pr_debug("low: %d\n", i); + pr_debug("low:lower: %d subcategory test\n", i); + } + pr_debug("Exit:\n"); +} + +static void expect_matches(int want, int got, const char *story) +{ + /* todo: got <0 are errors, bubbled up. no test for that */ + test_ct++; + if (got != want) { + pr_warn("nok %d: want %d matches, got %d on <%s>\n", test_ct, want, got, story); + errors++; + } else + pr_info("ok %d: %d matches on <%s>\n", test_ct, want, story); +} + +static int report(char *who) +{ + if (errors) + pr_err("%s failed %d of %d tests\n", who, errors, test_ct); + else + pr_info("%s passed %d tests\n", who, test_ct); + return errors; +} + +struct exec_test { + int matches; + int loops; + int hits; + const char *mod; + const char *qry; +}; + +static void do_exec_test(struct exec_test *tst) +{ + int match_count; + + match_count = dynamic_debug_exec_queries(tst->qry, tst->mod); + expect_matches(tst->matches, match_count, tst->qry); + do_debugging(tst->loops); + expect_count(tst->hits, tst->qry); +} + +/* these tests rely on register stuff having been done ?? */ +struct exec_test exec_tests[] = { + /* + * use original single string query style once, to test it. + * standard use is with separate module param, like: + * dynamic_debug_exec_queries("func do_debugging +_", "test_dynamic_debug"); + */ + { 6, 1, 0, NULL, "module test_dynamic_debug func do_debugging -T" }, + + /* no modification probe */ + { 6, 3, 0, KBUILD_MODNAME, "func do_debugging +_" }, + + /* enable all prdbgs in DUT */ + { 6, 4, 18, KBUILD_MODNAME, "func do_debugging +T" }, + + /* disable hi call */ + { 1, 4, 14, KBUILD_MODNAME, "format '^hi:' -T" }, + + /* disable mid call */ + { 1, 4, 10, KBUILD_MODNAME, "format '^mid:' -T" }, + + /* repeat same disable */ + { 1, 4, 10, KBUILD_MODNAME, "format '^mid:' -T" }, + + /* repeat same disable, diff run ct */ + { 1, 5, 12, KBUILD_MODNAME, "format '^mid:' -T" }, + + /* include subclass */ + { 2, 4, 2, KBUILD_MODNAME, "format '^low:' -T" }, + + /* re-disable, exclude subclass */ + { 1, 4, 2, KBUILD_MODNAME, "format '^low: ' -T" }, + + /* enable, exclude subclass */ + { 1, 4, 6, KBUILD_MODNAME, "format '^low: ' +T" }, + + /* enable the subclass */ + { 1, 4, 10, KBUILD_MODNAME, "format '^low:lower:' +T" }, + + /* enable the subclass */ + { 1, 6, 14, KBUILD_MODNAME, "format '^low:lower:' +T" }, +}; + +static int __init test_dynamic_debug_init(void) +{ + int i; + + pick_tracer(); + + pr_debug("Entry:\n"); + do_debugging(1); + expect_count(0, "nothing on"); + + //dynamic_debug_register_tracer(THIS_MODULE, my_tracer); + /* 2nd time gets a complaint */ + //dynamic_debug_register_tracer(THIS_MODULE, my_tracer); + + for (i = 0; i < ARRAY_SIZE(exec_tests); i++) + do_exec_test(&exec_tests[i]); + + //dynamic_debug_unregister_tracer(THIS_MODULE, my_tracer); + + /* this gets missing tracer warnings, cuz +T is still on */ + do_debugging(1); + expect_count(0, "unregistered, but +T still on"); + + /* reuse test 0 to turn off T */ + do_exec_test(&exec_tests[0]); + + /* this draws warning about failed deregistration */ + //dynamic_debug_unregister_tracer(THIS_MODULE, my_tracer); + + do_debugging(1); + expect_count(0, "all off"); + + report("init"); + pr_debug("Exit:\n"); + return 0; +} + +static void __exit test_dynamic_debug_exit(void) +{ + report("exit"); + pr_debug("Exit:"); +} + +module_init(test_dynamic_debug_init); +module_exit(test_dynamic_debug_exit); + +MODULE_AUTHOR("Jim Cromie "); +MODULE_LICENSE("GPL"); From patchwork Wed Oct 27 04:36:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12586383 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FBA6C4332F for ; Wed, 27 Oct 2021 04:38:10 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D7A2D60F70 for ; Wed, 27 Oct 2021 04:38:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D7A2D60F70 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7B86A6E527; Wed, 27 Oct 2021 04:37:30 +0000 (UTC) Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by gabe.freedesktop.org (Postfix) with ESMTPS id D33ED895B4; Wed, 27 Oct 2021 04:37:26 +0000 (UTC) Received: by mail-io1-xd35.google.com with SMTP id n67so2072117iod.9; Tue, 26 Oct 2021 21:37:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hUXw1OWc0bijNWeKRWwMm43lU8lNKntPX+8f8UwNPzs=; b=FUKXeYqxji29MCHeOLS1XcPak25DdjiAJQrrVp7Z1xiIyzrGUGSWc9DRHRC4DNLVH3 M0ZD9wPlj8W36lJfQxAm6DpGANFbqKUD/9F4LhVQ2SnlxKnEECOChi3vbjG/uy+DiWyy AqchRPyAlFUgaMUf3lTMfOfh6dMXfTIdbZ2yW1m+wmHgmQ3+IxCXgKfQbjsWAUP1YDP1 6R15jEXiNBfRq1a+xf62CpOaKDvFeNrGmN4kf4lfRQFRlgoMli3JsxU0JobVIfxAih49 g/PGQ0FPCLPtA1RLiJ+5YceVQiH5R8kvjFi1utYo+fAP6GTn7D/FT7cDqD/0G07wBXiX GRHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hUXw1OWc0bijNWeKRWwMm43lU8lNKntPX+8f8UwNPzs=; b=2NedPFRaw7rr+tUiwcggaTFnmcADbPKObgEDwnj2DHBArxbj9Tz6p72DKsqnmeMk6V XHKjc73KSs8RLKO1t6wj3x3PoDyyLFKb/CE7l0HFM6KYLVO5CdnCrfQNVy0t0Rdv7ldb JLQGESKD+dabOijQqpAxhrJUiWap/Ml7F1wV/KZpbGOcA4XdNc7N37N6rui0lWSZll5T cjgy9F/ccx1MXqRGGphAL39sbmPC9rYp2jWkZDfqyQNkgd06pzUAFWMucPKlmulzo+Lm wA90Ad1qFxSuk66rrIk8/OI5LtOxPUqg+pKYR4lfe8hfrxgwIZLyeTY0mYgeW5QQixdj hYRQ== X-Gm-Message-State: AOAM532V0ILrsUg+HAw+4C+7TCbo/sXbFX4Jna61u8sxAHCP609tn4gG aqBJRJbKLKTsafZuaL5yZoc= X-Google-Smtp-Source: ABdhPJzSOzGqdoO8Gck7AAmi8O0Fyw83A48XDRgzWexMwCoillaHbIEX46dwmpBmfZYsImDFq0Kxxg== X-Received: by 2002:a05:6602:2ac8:: with SMTP id m8mr18820933iov.112.1635309446157; Tue, 26 Oct 2021 21:37:26 -0700 (PDT) Received: from samwise.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id a15sm2030404ilj.81.2021.10.26.21.37.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 21:37:25 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk, daniel.vetter@ffwll.ch, seanpaul@chromium.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Date: Tue, 26 Oct 2021 22:36:44 -0600 Message-Id: <20211027043645.153133-10-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211027043645.153133-1-jim.cromie@gmail.com> References: <20211027043645.153133-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v9 09/10] dyndbg: create DEFINE_DYNAMIC_DEBUG_TRACE_CATEGORIES X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" clone DEFINE_DYNAMIC_DEBUG_CATEGORIES interface to enable pr_debug output to tracefs. Extend DEFINE_DYNAMIC_DEBUG_CATEGORIES to work for tracing, by renaming it (with _FLAGS suffix), adding _flags param, and using it 2x; in original and new names, with "p" and "T" flags respectively. TODO: rethink this, consider combined trace/debug declaration. good: single bitmap-spec for both trace,debug, no chance of divergence. bad: arg-type & count checks are hard, and bitmap follows too! to combine both, we need 4 args: sysfs_debug_name, __debug_var sysfs_trace_name, __trace_var // these may be NULL, IFF !CONFIG_TRACE ?? then a bitmap: [0] = { "category1" }, ...) My BUILD_BUG-fu is insufficient to protect a naive macro. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 19 ++++++++++++++----- lib/dynamic_debug.c | 4 ++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 896848f546e6..f273ba82cbb0 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -254,11 +254,20 @@ struct dyndbg_bitdesc { struct dyndbg_bitmap_param { unsigned long *bits; /* ref to shared state */ + const char *flags; struct dyndbg_bitdesc map[]; /* indexed by bitpos */ }; #if defined(CONFIG_DYNAMIC_DEBUG) || \ (defined(CONFIG_DYNAMIC_DEBUG_CORE) && defined(DYNAMIC_DEBUG_MODULE)) + +#define DEFINE_DYNAMIC_DEBUG_CATEGORIES_FLAGS(fsname, _var, _flags, desc, ...) \ + MODULE_PARM_DESC(fsname, desc); \ + static struct dyndbg_bitmap_param ddcats_##_var = \ + { .bits = &(_var), .flags = (_flags), \ + .map = { __VA_ARGS__, { .match = NULL }}}; \ + module_param_cb(fsname, ¶m_ops_dyndbg, &ddcats_##_var, 0644) + /** * DEFINE_DYNAMIC_DEBUG_CATEGORIES() - bitmap control of categorized pr_debugs * @fsname: parameter basename under /sys @@ -271,11 +280,11 @@ struct dyndbg_bitmap_param { * modules calling pr_debugs to control them in groups according to * those prefixes, and map them to bits 0-N of a sysfs control point. */ -#define DEFINE_DYNAMIC_DEBUG_CATEGORIES(fsname, _var, desc, ...) \ - MODULE_PARM_DESC(fsname, desc); \ - static struct dyndbg_bitmap_param ddcats_##_var = \ - { .bits = &(_var), .map = { __VA_ARGS__, { .match = NULL }}}; \ - module_param_cb(fsname, ¶m_ops_dyndbg, &ddcats_##_var, 0644) +#define DEFINE_DYNAMIC_DEBUG_CATEGORIES(fsname, _var, desc, ...) \ + DEFINE_DYNAMIC_DEBUG_CATEGORIES_FLAGS(fsname, _var, "p", desc, ##__VA_ARGS__) + +#define DEFINE_DYNAMIC_DEBUG_TRACE_CATEGORIES(fsname, _var, desc, ...) \ + DEFINE_DYNAMIC_DEBUG_CATEGORIES_FLAGS(fsname, _var, "T", desc, ##__VA_ARGS__) extern const struct kernel_param_ops param_ops_dyndbg; diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index f19465b114cd..b4146178780f 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -629,8 +629,8 @@ int param_set_dyndbg(const char *instr, const struct kernel_param *kp) for (i = 0; map->match && i < BITS_PER_LONG; map++, i++) { if (test_bit(i, &inbits) == test_bit(i, p->bits)) continue; - snprintf(query, FMT_QUERY_SIZE, "format '%s' %cp", map->match, - test_bit(i, &inbits) ? '+' : '-'); + snprintf(query, FMT_QUERY_SIZE, "format '%s' %c%s", map->match, + test_bit(i, &inbits) ? '+' : '-', p->flags); matches = ddebug_exec_queries(query, KP_MOD_NAME); From patchwork Wed Oct 27 04:36:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12586381 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 362B9C433FE for ; Wed, 27 Oct 2021 04:38:09 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0667B60F70 for ; Wed, 27 Oct 2021 04:38:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0667B60F70 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4A18D89083; Wed, 27 Oct 2021 04:37:30 +0000 (UTC) Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by gabe.freedesktop.org (Postfix) with ESMTPS id EE1FB89850; Wed, 27 Oct 2021 04:37:27 +0000 (UTC) Received: by mail-io1-xd33.google.com with SMTP id v65so2107516ioe.5; Tue, 26 Oct 2021 21:37:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cnTkeK8v67eIBs3PS2euQVCRKMfmRbTWdl+Z44hl+ec=; b=hyLsn00WTLCJL4GvOmE2kxDub5BpxRbKWLIpyTkYZF2eqFHzXTbv7M4KAij+kGcq8w Gz7Q6kF3P+6u6t3A5bB/VzAdsm9ralmjQ8B41BWntNLNmeJH/AHDWkq+Ej/m+8lWmPb/ Hd/yO7Edb3UcphCFdVM451GH/37X6CyTP6+c7p8/Rx5hOrApcbqSekYfE2APXIclkST2 scGa8LjGdR29jtDvfvPpH8HR2bJpt9C4R7l3/Rx31ItRrHnCWjjK1vXLw8EvjPAyHIKh StLJ2ShUBrrYetUf3emdR/NQuFRm1rrCiY1qRs6FGXfqiWMbNVGy5H6hv/CW5Pt5Eake gi0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cnTkeK8v67eIBs3PS2euQVCRKMfmRbTWdl+Z44hl+ec=; b=2Pa7ZuPG6N7ByWvqxH7jDo/7spva2YHEBQBej0TzsJxC8SOEhdfsQYczQ1NEfUTEqt BADFrArsW1qq7jmujbysTmFLQcCmMzNuVS4xwEv2uKjaOiZcQVvNTSS9+srpzp+kk9L2 fP5mrjyNRyncqM8a+W+40AdX4j/cUgDcCDwhWeWpBssDOkzAagL6QgWJijkInQ8heu49 ihIEDGoWcgPnX7uPbzlG1hVGyZeFRcZMGV3hGQX4ie6XCbmmCtvPohcAng9wlooq6dfT 7XO0UrRo1dIg8l2T/gDXiOwLP2Il5wa5Tx0gIMkvqaLutjq1OH59vnuRpq/IRa4kepSq 00Bw== X-Gm-Message-State: AOAM530f4WyfLLnvGC8RvTDsPMrPbebOaOYvro43dMVExrzX/FBH2e3D L54bRJuR6oEm0XS7nk1Uxcw= X-Google-Smtp-Source: ABdhPJxOL3av75apCy1NaSeSnBdOn/HBQSzgvyFqXTBntJL0EsDlcBUuZ+4BzU72oZQOjVlVp6bO2w== X-Received: by 2002:a05:6638:d90:: with SMTP id l16mr18388899jaj.36.1635309447330; Tue, 26 Oct 2021 21:37:27 -0700 (PDT) Received: from samwise.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id a15sm2030404ilj.81.2021.10.26.21.37.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 21:37:27 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk, daniel.vetter@ffwll.ch, seanpaul@chromium.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: Jim Cromie Date: Tue, 26 Oct 2021 22:36:45 -0600 Message-Id: <20211027043645.153133-11-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211027043645.153133-1-jim.cromie@gmail.com> References: <20211027043645.153133-1-jim.cromie@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v9 10/10] drm: use DEFINE_DYNAMIC_DEBUG_TRACE_CATEGORIES bitmap to tracefs X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Use new macro to create a sysfs control bitmap knob to control print-to-trace in: /sys/module/drm/parameters/trace todo: reconsider this api, ie a single macro expecting both debug & trace terms (2 each), followed by a single description and the bitmap-spec:: Good: declares bitmap once for both interfaces Bad: arg-type/count handling (expecting 4 args) is ugly, especially preceding the bitmap-init var-args. Signed-off-by: Jim Cromie --- drivers/gpu/drm/drm_print.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index ce662d0f339b..7b49fbc5e21d 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -73,6 +73,25 @@ DEFINE_DYNAMIC_DEBUG_CATEGORIES(debug, __drm_debug, [7] = { DRM_DBG_CAT_LEASE }, [8] = { DRM_DBG_CAT_DP }, [9] = { DRM_DBG_CAT_DRMRES }); + +#ifdef CONFIG_TRACING +unsigned long __drm_trace; +EXPORT_SYMBOL(__drm_trace); +DEFINE_DYNAMIC_DEBUG_TRACE_CATEGORIES(trace, __drm_trace, + DRM_DEBUG_DESC, + [0] = { DRM_DBG_CAT_CORE }, + [1] = { DRM_DBG_CAT_DRIVER }, + [2] = { DRM_DBG_CAT_KMS }, + [3] = { DRM_DBG_CAT_PRIME }, + [4] = { DRM_DBG_CAT_ATOMIC }, + [5] = { DRM_DBG_CAT_VBL }, + [6] = { DRM_DBG_CAT_STATE }, + [7] = { DRM_DBG_CAT_LEASE }, + [8] = { DRM_DBG_CAT_DP }, + [9] = { DRM_DBG_CAT_DRMRES }); + +struct trace_array *trace_arr; +#endif #endif void __drm_puts_coredump(struct drm_printer *p, const char *str)