Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp546604lqp; Wed, 22 May 2024 11:52:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX8r7tfgGciTbbz4VEUW29+ttLpTPenp7H2bfjLiZL1a/+YGTkdPLs45gzxSSuVeMb7qeJjLovdKcW7itAAhBrPAfY9K3Oc683DZLCDxQ== X-Google-Smtp-Source: AGHT+IGFtxXMYks0THLo3XZfajeUw0JoY89Bd/rA364FMvd1wdHQaUo9s3pavbSK3UPY7l4VnaMY X-Received: by 2002:a17:902:f64a:b0:1f3:2a96:912c with SMTP id d9443c01a7336-1f32a969494mr21936195ad.26.1716403962062; Wed, 22 May 2024 11:52:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716403962; cv=pass; d=google.com; s=arc-20160816; b=d92YivSQhG7/i6/mh1ayJ0bHIOx2DiOuGyYyMJWNjuNCn7ZJWzLUlyHZeiorhZvAUY 06/wROoW45PSa7QFp2o4i8B/RiEGEhakEIZRLwaQHvtEozDK75+tdlhl8rht4jBGTPQR 6v+AS9HAbMolZS6neB5OVQuTEDnkHUImQ7FS2z+fzRKvm5FKiKsQ+iEUlkxEqd34UZAZ mogRuf10eMd9sUeHmHRs6SSS+uL0s2GH41a0UHc5NT2saGfhoC2Q8Rrp6zFEedmliVXW EI8XPV5o/4tb6uEixOQSR7FkULtRXR+9OsCW9CNOlcdstqalpwKpiQrG/APvpGIvzoo9 enng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=kUWpivSzxaIrixDkj6aA8gHoz3/kBRnCazuu8dkm+LM=; fh=SPuwKyRtO430hNrb2kIIE30X2ztv/n5T7WgEiJZ3cDQ=; b=k4HsXN/FGg5J+B58/mEXH0hc9BfIGHHv3WIbvDSMI9G3vt4N0ohlUDi+D6VCxYwuN3 j2JjxW//QuhfEbC/EYcxmEZ+ZHuJSuT12MrNu2vzMidr5YDHYzEUezcir6t22tf5yWW6 EXla4DzJDrUcRb9CceNyAKMNVUl/mQN1/ftDOIA6wWPILcIUtIf94IAF1CS1q48CwfsH OUzqeRN2fnGqUVuq3U0QjKdzoche8sf72PDAwvSy2dZlg/NLYqbhj7iOpCm+cyLKo+JI RutW3Hs9/XUV7f1fOWTVfCkn04Kvb+VWJEDlZwqyzgHmnGQgqVRlnbXsVYLhWs2Mo+HR lmEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aCKokZlL; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-186626-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186626-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f309a84d01si42902695ad.344.2024.05.22.11.52.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 11:52:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186626-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aCKokZlL; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-186626-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186626-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 9B38FB2184C for ; Wed, 22 May 2024 18:52:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BCCB9145B3C; Wed, 22 May 2024 18:52:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aCKokZlL" Received: from mail-vs1-f41.google.com (mail-vs1-f41.google.com [209.85.217.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 748D823CB for ; Wed, 22 May 2024 18:52:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716403950; cv=none; b=K8V7WL5UR7fdbqQQ6LYs6babPI6Ed6Oqf7k2BnwvR9XDTiywzl69RqrSrzvQfQKUVfeDCp56KYAH6lGnQ54fPGV14NStvRw5/h5wFedSHIFEOw1ixnCExmX+MwrvF2sGxeUUBZWckT/xSUwIQpkLAjpjfR9LULtzmShJCAhDzko= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716403950; c=relaxed/simple; bh=shm1dhC8Fyb4N2X20Owe1g2clV/Gh8Tk6up6B/kfE1s=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=XtxnUUR0Lh/FwC6PW8VTVvocvZV88n/8odJ5VyINgQAO+flFRTjCceFwp/yQ/FGQhobxASBID0eilwZWRkTBpIc51EUkNYods5XpXSmk1TwFmF0Umgt4o92TlpVFKxxs+1udblebv3pKM2sNixIIBR1Xi/8uj/9x/gQHM/SnerY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aCKokZlL; arc=none smtp.client-ip=209.85.217.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-vs1-f41.google.com with SMTP id ada2fe7eead31-47eff9b3c23so400597137.0 for ; Wed, 22 May 2024 11:52:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716403948; x=1717008748; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=kUWpivSzxaIrixDkj6aA8gHoz3/kBRnCazuu8dkm+LM=; b=aCKokZlLllquLXHkW/lyxQD8K0gQjYVhSMzW7LnP3xuU7JoW4SPWHad2Xtb9rbMUei /IZ3BFtiP56WFLnH8++trbkv3Vc1djikoEYXitlp5cYZji4omoKad5G4ik58y27cHztz DN14sKYTkcQZNNpIbLCXYssZp0GXnJ1isHH0rsJ4HRA7PspllPbAeJfsrj27sj7xeD82 heB5GCUTIP+g9bOrpJrdKdHBX1H/SG7ptnNN5BXuxwFFdB8kK3YMwJwE7U2jWuKR7emG p+G4MYZsTjaHvMIz62wqH0XoBRTs3rMJFb9wYOwH19Gy8cRf5eQ8o8lLVChiiBPX06yf s0+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716403948; x=1717008748; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kUWpivSzxaIrixDkj6aA8gHoz3/kBRnCazuu8dkm+LM=; b=cNpxfZeCu/6ckncuFJ50392hVfbXOTZhae/oVU5Qa5l4+IUJVE94qEL8kRCzskjj2S doedOzxI/u2JSaxUxTJiEjOfJ9vL0FJ1uaYuHl+BGWSQkblNbxk4WCq40aiOHtIAuoYU e7uk21NgYbrAJv+KgjJhwXigM3AuWmYG22lUFraQIKqTd77vXdctt7ArVq/AgDdIY23y pRI5HAo1/AWbOyzKzoM2B3rHHGpcdWEFNJwhqQbuveNfUz5Y0kmtrBclgYgW7vHWnyun yEY/Fq4Yf+yGi9pU2d/Q9h+hd2uX0YpJXp7Fevp6DBNFD7sKNcvhLUV+XyWrPyA9K/jN YdXg== X-Forwarded-Encrypted: i=1; AJvYcCVFi3kW3VTqxL8691b2flNyCrE+fpzhJ0HrtBdBj/mkiAqp6kzMECGs4B96gEXTDLDvgXU6xjrZn67FO98giz9cspCg8EbjBN52cKli X-Gm-Message-State: AOJu0YwEoXBPWQ57+XqZ3pCXaVs/L7vdxRfqSgP1m+wp3gdjIKVg0skw J61wVsZttqMGvSlsQuH3PMoVO8Iv7YT0o7/MtMZh7NDGqjPWG7zNaFOBgncF10mjTArCxq075I1 oJFqxSYZz8rg9jUbGRp7TJaaatM0= X-Received: by 2002:a05:6102:6c3:b0:480:6c41:220b with SMTP id ada2fe7eead31-4890096d879mr3427415137.1.1716403948262; Wed, 22 May 2024 11:52:28 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240516174357.26755-1-jim.cromie@gmail.com> <20240516174357.26755-16-jim.cromie@gmail.com> In-Reply-To: From: jim.cromie@gmail.com Date: Wed, 22 May 2024 12:52:01 -0600 Message-ID: Subject: Re: [PATCH v8-RESEND 15/33] dyndbg-API: fix DECLARE_DYNDBG_CLASSMAP To: =?UTF-8?Q?=C5=81ukasz_Bartosik?= Cc: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk, joe@perches.com, mcgrof@kernel.org, daniel.vetter@ffwll.ch, tvrtko.ursulin@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, groeck@google.com, yanivt@google.com, bleung@google.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, May 21, 2024 at 10:31=E2=80=AFAM wrote: > > On Tue, May 21, 2024 at 5:46=E2=80=AFAM =C5=81ukasz Bartosik wrote: > > > > On Thu, May 16, 2024 at 7:44=E2=80=AFPM Jim Cromie wrote: > > > > > > DECLARE_DYNDBG_CLASSMAP() has a design error; its usage fails a basic > > > K&R rule: "define once, refer many times". > > > > > > It is used across DRM core & drivers, each use re-defines the classma= p > > > understood by that module; and all must match for the modules to > > > respond together when DRM.debug categories are enabled. This is > > > brittle; a maintenance foot-gun. > > > > > > Worse, it causes the CONFIG_DRM_USE_DYNAMIC_DEBUG=3DY regression; 1st > > > drm.ko loads, and dyndbg initializes its DRM.debug callsites, then a > > > drm-driver loads, but too late - it missed the DRM.debug enablement. > > > > > > So replace it with 2 macros: > > > DYNDBG_CLASSMAP_DEFINE - invoked once from core - drm.ko > > > DYNDBG_CLASSMAP_USE - from all drm drivers and helpers. > > > > > Why does DYNDBG_CLASSMAP_DEFINE take "stringified" enum name-vals ? > > > > short version: > > real enum vals would be better - misspellings would be compiler errors > but doing the stringification inside the macro doesnt work, > __stringify(__VA__ARGS__) produces "DRM_UT_CORE, DRM_UT_DRIVER" etc, > not 10 separate stringifications > > I have a patchset for later that fixes this, > but I didnt want to complicate this submission any further. > Its already touching 2 sub-systems, revising and adding API > > > > > - 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. > > > + This module exersizes/demonstrates dyndbg's classmap API, b= y > > > > Typo exersizes -> exercises > > > > yes > > > > +static void ddebug_apply_params(const struct ddebug_class_map *cm, c= onst char *modnm) > > > +{ > > > + const struct kernel_param *kp; > > > +#if IS_ENABLED(CONFIG_MODULES) > > > > Instead of the above maybe use "if (IS_ENABLED(CONFIG_MODULES)) {" ? > > This will allow to get rid of #if and #endif which make code less reada= ble. > > > > will do. > > > > + int i; > > > + meh, turns out the #ifdef was doing more work - hiding the use of struct module in the expression. and since the cm->mod->kp actually refers thru the struct, it must be defin= ed, a forward decl looks insufficient >> lib/dynamic_debug.c:1202:28: error: incomplete definition of type 'struc= t module' 1202 | for (i =3D 0, kp =3D cm->mod->kp; i < cm->mod->num_kp; i++, kp++) | ~~~~~~~^ arch/x86/include/asm/alternative.h:108:8: note: forward declaration of 'struct module' 108 | struct module; | ^ [jimc:dd-classmap-fix-8d 15/36] lib/dynamic_debug.c:1202:28: error: incomplete definition of type 'struct module' I'll probably revert, and stick with the #if block, anything else feels too subtle by half