From mboxrd@z Thu Jan 1 00:00:00 1970 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 shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8BBFDC3DA5D for ; Thu, 18 Jul 2024 01:49:00 +0000 (UTC) Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.97.1) (envelope-from ) id 1sTnhm-0000000083Y-27tB; Tue, 16 Jul 2024 15:19:18 -0400 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.97.1) (envelope-from ) id 1sTnP0-000000001Ld-1Sai for kernelnewbies@kernelnewbies.org; Tue, 16 Jul 2024 14:59:54 -0400 Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-8076708e8ffso5054939f.0 for ; Tue, 16 Jul 2024 11:59:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721156374; x=1721761174; darn=kernelnewbies.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=02GQEyQ8Fgm4yEF+9D4Fm23zLJa07LslS1GKZkXapgQ=; b=D4MUup7m31e4epnwPOnm8pHPUXIfnD2H3gA8vz4ijydR5HFRcdtORcLars3i0MXhCI NxeJWKUv46wYo9nin9KiAmCgIEvARBWIHXr3/n0t6K/4u9oDOfzKWfF6I4jVWfqbr9G3 Fy/2Vyuj/fG5HYzaYGxQwhwO1HUci7oWN4tI/HVx3kRcPhJ9m1BnHcpdKElx7BiOsW8w 6wF/V+RSyZIBRQPOvgWw6JEntwIgdqRIcyo+yHhbcd4sy/3+H7QKahRjuUlcbPX51gzu QSfa0F0rN9nSfuj9No5YN0dajJygkWsNwEnJglI3zHxq1pnJ+vyhmI9BDDt2qBertkPi 5GqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721156374; x=1721761174; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=02GQEyQ8Fgm4yEF+9D4Fm23zLJa07LslS1GKZkXapgQ=; b=XEc939XxTsY6y9j5s6UtXZUL16Yu2SocAr69nh7RExU2beMlgncNxvgUGqg4+AvA5i tkFF36b6K9B92Xm58F0D8Fl5NIhaI89XNbnXgFbiQMorwu56HIxtkE2+gX7/zxw1Qu9E StR7rbEYDtMwz/3PaSgrc2fGxCoxJiUts/tOk4Gler5kL9CuoL+5oIg+TmlMuM92pXjd YkCuhwhoLtEgsmMP/oTusJ3FSzDRlscwmE9sAgjra8qvZbmo1pnWMbpof10osEiWODQL b+zjafNh3Yrf3/bgs/BxFBw4MliYSxbMQubRBap90hXYnBUEfRZmyBj7mW1PnHTcK208 Zhrw== X-Forwarded-Encrypted: i=1; AJvYcCW/cW3F8ZPX9jN8on9X7xFWgXvUgXIxIwBOtiqdxuKBOLubP0/u8weGlOmxeG7/4JYqNtnkaoPMmuVdPrSEFduwcxb7BFrd+6Zqw0kbIY+W X-Gm-Message-State: AOJu0YwST2iJ3Qp7xdagX4UZDPD6EyfjhDL2sE0kJLYIDZFnGwSSxAaz rlmmXldGirA15ygSWVCIDe8C0DkZWbPErcAmMbSDtvUABR7aZNwL1XYvBNvJ X-Google-Smtp-Source: AGHT+IH2P7UQSoQkuUq22B0bjuKA/ngzw01JbZNtKHx44WAJD4WRstjL+48jrY+j0JQqgWF+0C1c2g== X-Received: by 2002:a05:6602:1548:b0:804:f2be:ee21 with SMTP id ca18e2360f4ac-816c2c0d633mr43164039f.3.1721156373964; Tue, 16 Jul 2024 11:59:33 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id 8926c6da1cb9f-4c210f23f1csm75301173.102.2024.07.16.11.59.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 11:59:33 -0700 (PDT) From: Jim Cromie To: linux-kernel@vger.kernel.org, jbaron@akamai.com, gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com Subject: [PATCH v9-resend 54/54] docs-dyndbg: improve howto classmaps api section Date: Tue, 16 Jul 2024 12:58:06 -0600 Message-ID: <20240716185806.1572048-55-jim.cromie@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240716185806.1572048-1-jim.cromie@gmail.com> References: <20240716185806.1572048-1-jim.cromie@gmail.com> MIME-Version: 1.0 Cc: groeck@google.com, linux-doc@vger.kernel.org, Jim Cromie , yanivt@google.com, intel-gfx@lists.freedesktop.org, kernelnewbies@kernelnewbies.org, linux@rasmusvillemoes.dk, robdclark@gmail.com, dri-devel@lists.freedesktop.org, mcgrof@kernel.org, seanpaul@chromium.org, amd-gfx@lists.freedesktop.org, joe@perches.com, bleung@google.com, intel-gvt-dev@lists.freedesktop.org, ukaszb@chromium.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org reword the classmaps-api section to better explain how it supports DRM, and (a little bit) to steer clear of designated-inits in the _DEFINE description. probably just squash this back in Signed-off-by: Jim Cromie --- .../admin-guide/dynamic-debug-howto.rst | 64 +++++++++++-------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst index ccf3704f2143..1ffab6be07fc 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -390,42 +390,56 @@ in case ``prefix_str`` is built dynamically. Dynamic Debug classmaps ======================= -Dyndbg allows selection/grouping of *prdbg* callsites using structural -info: module, file, function, line. Classmaps allow authors to add -their own domain-oriented groupings using class-names. Classmaps are -exported, so they referencable from other modules. +Classmaps adds the "class" keyword, which selects prdbgs based on +author supplied, domain-oriented names; this complements the code +organizational keywords: module, file, function, line. + +The main difference from the others: class'd prdbgs must be named to +be changed. This protects them from generic overwrite: + + # IOW this cannot undo any DRM.debug settings + :#> ddcmd -p + +So each class must be enabled individually (no wildcards): - # enable classes individually :#> ddcmd class DRM_UT_CORE +p :#> ddcmd class DRM_UT_KMS +p # or more selectively :#> ddcmd class DRM_UT_CORE module drm +p -The "class FOO" syntax protects class'd prdbgs from generic overwrite:: - - # IOW this doesn't wipe any DRM.debug settings - :#> ddcmd -p +Or the legacy/normal (convenient) way: -To support the DRM.debug parameter, DYNDBG_CLASSMAP_PARAM* updates all -classes in a classmap, mapping param-bits 0..N onto the classes: -DRM_UT_<*> for the DRM use-case. + :#> echo 0x1ff > /sys/module/drm/parameters/debug Dynamic Debug Classmap API ========================== -DYNDBG_CLASSMAP_DEFINE - modules use this to create classmaps, naming -each of the classes (stringified enum-symbols: "DRM_UT_<*>"), and -type, and mapping the class-names to consecutive _class_ids. +The classmap API is closely modeled on DRM, which has: + +enum drm_debug_category: DRM_UT_* // 10 independent categories. +dyndbg's .classid encodes that directly, allowing 0..62 classes + +DRM has ~5k calls like: drm_dbg(DRM_UT_KMS, "kms msg"); +these are unchanged, even in argtype, since classid === category. + +DRM controls the classes together via sysfs; bits 0..9 control the +classes independently. + +Its expected that other classmap users will also provide debug-macros +using an enum-defined categorization scheme like DRM's, and dyndbg can +be adapted under them similarly. + +DYNDBG_CLASSMAP_DEFINE(var,type,_base,classnames) - this maps +classnames onto class-ids starting at _base, it also maps the +names onto CLASSMAP_PARAM bits 0..N. -By doing so, modules tell dyndbg that they have prdbgs with those -class_ids, and they authorize dyndbg to accept "class FOO" for the -module defining the classmap, and its contained classnames. +DYNDBG_CLASSMAP_USE(var) - modules call this to refer to the var +_DEFINEd elsewhere (and exported). -DYNDBG_CLASSMAP_USE - drm drivers invoke this to ref the CLASSMAP that -drm DEFINEs. This shares the classmap definition, and authorizes -dyndbg to apply changes to the user module's class'd pr_debugs. It -also tells dyndbg how to initialize the user's prdbgs at modprobe, -based upon the current setting of the parent's controlling param. +Classmaps are opt-in: modules invoke _DEFINE or _USE to authorize +dyndbg to update those classes. "class FOO" queries are validated +against the classes, this finds the classid to alter; classes are not +directly selectable by their classid. There are 2 types of classmaps: @@ -436,9 +450,9 @@ DYNDBG_CLASSMAP_PARAM - modelled after module_param_cb, it refers to a DEFINEd classmap, and associates it to the param's data-store. This state is then applied to DEFINEr and USEr modules when they're modprobed. -This interface also enforces the DD_CLASS_TYPE_LEVEL_NUM relation +The PARAM interface also enforces the DD_CLASS_TYPE_LEVEL_NUM relation amongst the contained classnames; all classes are independent in the -control parser itself. +control parser itself; there is no implied meaning in names like "V4". Modules or module-groups (drm & drivers) can define multiple classmaps, as long as they share the limited 0..62 per-module-group -- 2.45.2 _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies