From patchwork Sat Feb 10 23:49:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199325 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1700359dyd; Sat, 10 Feb 2024 15:51:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvAQY4G9Wjs+5wzW/atsFyJPIq7nj4vDKX9pO1DG6M8m70tCp5i2ooLZX1hsAVVbnbct0u X-Received: by 2002:a05:6402:248e:b0:561:aa6:32f5 with SMTP id q14-20020a056402248e00b005610aa632f5mr5075548eda.18.1707609066702; Sat, 10 Feb 2024 15:51:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609066; cv=pass; d=google.com; s=arc-20160816; b=FyIcDvXmgc6jDMPDYqBFke9xWjB0Wo0BSXMwDI1Ap5mJXjBThsJteDNiuZfeZNCu/x YP6lg+75hkURSuF2mnC+WbRbyEWbWYZZRa64l10WlziAJXLia7dQGrvytxJ0Pl6WyJJF rndARIaRQ/2q0wtlJWSwe0dy0ogHb7AmdX7IXDMKJP0tOmnLqTdEO9dhd0+uuKITfxy8 H6UZggT6MG46mb9A2Lh7sRq4in1Zx3lafIIPUqXOob+E7Kt5Q/IYBz9VaZbwfpDgwOWd zOFB/FjI+rgubysNCktMtESRIaDBbxsGGgegqiFqu/dN6AIed6k5M2AeLNfN7W9vHIDz 4xwA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=QOoJLafFWulnfY+ABLHJKXgTr+y2AravVLoCN2Eukac=; fh=gSwbf0M43Jz3NBmUzuvjdkIbIhblBoWoGnOEOHNWN6E=; b=MWWr34uKgFogfv7bgjEqsmrFu0SCXqNE6p9F+BCIm1YQ2MkMLstPK63sN22Bez6qYq 8x16VkRJ5H9b0htOtoe+AN/p21LSHGxiXIDca0eWnAeenCi0/b1gzgee07GuDrlo0EQX pIQ30FiYSjWFhrE8zsmocBV4zxh8v+b0dhhtkcJXdDnY5GCJulUXbR1U7nuyyNOFH80R 7cQTq9xMR9A5gI2XYZULHGc4Cxph6GPbxnfUKMTiPUu6FGtv8txbQtO1WPtzfg5HFLEA Qs+VZT8XczKpgTzNqh3V4WcXYNojCuS3CtYRYgFK7yvWiIlHVTD53BdLJcXTEc5eyYce bPYQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ef7c526k; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60584-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60584-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCUZMCTZy2ZPChB4OWfA96CKfQNtYnhkhkp2s0QYyaFGV017/SqfJl/WjpSHSDo8frT6eH+FTutadh9/OTbcGOCk42jxwA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m29-20020a50d7dd000000b00561446367afsi1285449edj.119.2024.02.10.15.51.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:51:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60584-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ef7c526k; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60584-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60584-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 51DC31F23E05 for ; Sat, 10 Feb 2024 23:51:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D12F06026B; Sat, 10 Feb 2024 23:50:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="ef7c526k" Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) (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 BF2055F84C for ; Sat, 10 Feb 2024 23:50:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.66 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609034; cv=none; b=adjrgO9eBTGrcC7rYTR1llpH7S52EVhBwZqvwAxQ0JDbEAqefpsRez2CW67HC9M4CxNTMiHoZtseGj46ov4IoyvfH6ydYu6/YrQq+Arh4mfiH/gJL98UWAQQ6CgEVShpaYp5oUvYE8PBFYS5wtNS1zxkBofIT8cn7hyIvIQ/foU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609034; c=relaxed/simple; bh=6bHuuhuQD8TDY9jao7qw7tzXO/CI+YZs/Ximv6+tRdw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dUmCo6B0CZdD8kWjQxqSIqSenVKfgmybi+r7qgb6HIXZZJ6EmlGtok6a7cCnGbMnUzkqksiz+P6boiUIdKWnZXajxbrUcpKbsjJnQOcUibsb+79z+S4tBCg4h28xNObRb8i+82HIgEMLU6ZegMJknrEx10Ij1PpQNKjbRI9imwk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=ef7c526k; arc=none smtp.client-ip=209.85.167.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f66.google.com with SMTP id 2adb3069b0e04-5112bd13a4fso3358750e87.0 for ; Sat, 10 Feb 2024 15:50:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609031; x=1708213831; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QOoJLafFWulnfY+ABLHJKXgTr+y2AravVLoCN2Eukac=; b=ef7c526kiZoUj+TKVbq0nWQE+UX2arGsQweYBLfZrOXdCITuSh1WmjVzg87g0nBAE1 ptK05nt0PCcsbiGSRnhEv3OrU45s2gLZb3OO0USzbLdzAwusBqpNhzQFsFAAkM25T6Dj B7f6/mSP1s9nOrXwFOIVoBczPEUh9xwlJO/e8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609031; x=1708213831; 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=QOoJLafFWulnfY+ABLHJKXgTr+y2AravVLoCN2Eukac=; b=cLlJDqPTJtFh3FiafmVQxIb0q74GSvtfq/p6Zqcg2K4l+DBdb0cxUsL1pMcgOKwljO qijxd0dmbr5sOKld3cgRwd+1Y94YUsDyd1Ul7GpkrRbgPgrG8Vqd1hmntFXURQzr0KWv gfYHaDdSRLQ3BjBnCuAeQX5KV39Sxlm/WmTQND9z9TEXwhMyMYBj1GvU0wu5eRnloIh7 JhWaF2JdQGKwHirwgKg7ppNShs58wLbikGlDs4RRrqj01bWC83MtYWQoF4VO6CxRlvSv +e3R8IZCHY1M/QTHPfzJt/UahFeoscmPP50MLZDvMqvZ3ke/MPdU3C/q+KX7bhucJEIC xC+A== X-Gm-Message-State: AOJu0Yxbb4Pot16wp67aC8BG6y6WGUKHWHjbZIZSP+cC6NND5fv2IXqa FiMCkg+cpGpOQtjTN6bSeIC5QTmlJchjz+MzcLgwQP7dl5z66p4yEwxU/YUL X-Received: by 2002:a19:7509:0:b0:50e:9354:67d0 with SMTP id y9-20020a197509000000b0050e935467d0mr931410lfe.14.1707609030596; Sat, 10 Feb 2024 15:50:30 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWR1qliCHrb/rw1JVufMqRw0VLKJMt3eslGm0V9/888+GwXZ5PctKlXXItIoQB5G1V3UFozdKQffcB1NyquT7C6LWZ9iaCE1QLGGNLYueU8jnUpO/uImR+shjBignDqqIIDtTjIdBuLl4MWW6dvY3YAoH/lb6XFkGKk66aSEJwhUK8WujMSNZVSPl8VahxrrXiH4IUHrJ2LjVa+mcsd+eAlGCeML64ZkiOi4BxMxrT7Bd0dijoDWqsqvNtH22eMax4Rq32fRjbNEm0ReZc9JrjJuOmanDaER0rFH9NLXNLO42p5qOTLTx4bYw5ZmlcqspB8pYaqg6T3XH6e9jM7ZgbAZtfbm6a2yIWcjHCO/a58BMkgXkrnabwbAErSInZBRqbbUQk4RSUQTx6oRF/vvj0uvAfGd3YeZE6rwd3NUg4mq6FnncFEpeVJAm3yS5TKT84tbhduNo84syjqyMnPeRYcfe5y6OicMhBywYzbyTzYrC56UDMaugehQBguTnz2DtN8ORFUlC/f9zkXCLh7ojF59y227OnFdtblqR5oLaxv4fhX+Ml2r3+wPV+3cuFg3/fZA0nV2l92gV8X+IIfgrocINe1qQfJoVNhd0xqfLPcVrDnig== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:30 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 01/39] dyndbg: add _DPRINTK_FLAGS_ENABLED Date: Sun, 11 Feb 2024 00:49:31 +0100 Message-ID: <20240210235009.2405808-2-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790557884960493544 X-GMAIL-MSGID: 1790557884960493544 From: Jim Cromie Distinguish the condition: _DPRINTK_FLAGS_ENABLED from the bit: _DPRINTK_FLAGS_PRINT, and re-define former in terms of latter, in preparation to add a 2nd bit: _DPRINTK_FLAGS_TRACE Update JUMP_LABEL code block to check _DPRINTK_FLAGS_ENABLED symbol. Also add a 'K' to get new symbol _DPRINTK_FLAGS_PRINTK, in order to break any stale uses. CC: vincent.whitchurch@axis.com Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 10 ++++++---- lib/dynamic_debug.c | 8 ++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 4fcbf4d4fd0a..7be791af7cf1 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -32,7 +32,7 @@ struct _ddebug { * writes commands to /dynamic_debug/control */ #define _DPRINTK_FLAGS_NONE 0 -#define _DPRINTK_FLAGS_PRINT (1<<0) /* printk() a message using the format */ +#define _DPRINTK_FLAGS_PRINTK (1 << 0) /* printk() a message using the format */ #define _DPRINTK_FLAGS_INCL_MODNAME (1<<1) #define _DPRINTK_FLAGS_INCL_FUNCNAME (1<<2) #define _DPRINTK_FLAGS_INCL_LINENO (1<<3) @@ -44,8 +44,10 @@ struct _ddebug { _DPRINTK_FLAGS_INCL_LINENO | _DPRINTK_FLAGS_INCL_TID |\ _DPRINTK_FLAGS_INCL_SOURCENAME) +#define _DPRINTK_FLAGS_ENABLED _DPRINTK_FLAGS_PRINTK + #if defined DEBUG -#define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINT +#define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINTK #else #define _DPRINTK_FLAGS_DEFAULT 0 #endif @@ -199,10 +201,10 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #ifdef DEBUG #define DYNAMIC_DEBUG_BRANCH(descriptor) \ - likely(descriptor.flags & _DPRINTK_FLAGS_PRINT) + likely(descriptor.flags & _DPRINTK_FLAGS_ENABLED) #else #define DYNAMIC_DEBUG_BRANCH(descriptor) \ - unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) + unlikely(descriptor.flags & _DPRINTK_FLAGS_ENABLED) #endif #endif /* CONFIG_JUMP_LABEL */ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 6fba6423cc10..ee0cb37153ef 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -89,7 +89,7 @@ static inline const char *trim_prefix(const char *path) } static const struct { unsigned flag:8; char opt_char; } opt_array[] = { - { _DPRINTK_FLAGS_PRINT, 'p' }, + { _DPRINTK_FLAGS_PRINTK, 'p' }, { _DPRINTK_FLAGS_INCL_MODNAME, 'm' }, { _DPRINTK_FLAGS_INCL_FUNCNAME, 'f' }, { _DPRINTK_FLAGS_INCL_SOURCENAME, 's' }, @@ -247,10 +247,10 @@ static int ddebug_change(const struct ddebug_query *query, if (newflags == dp->flags) continue; #ifdef CONFIG_JUMP_LABEL - if (dp->flags & _DPRINTK_FLAGS_PRINT) { - if (!(newflags & _DPRINTK_FLAGS_PRINT)) + if (dp->flags & _DPRINTK_FLAGS_ENABLED) { + if (!(newflags & _DPRINTK_FLAGS_ENABLED)) static_branch_disable(&dp->key.dd_key_true); - } else if (newflags & _DPRINTK_FLAGS_PRINT) { + } else if (newflags & _DPRINTK_FLAGS_ENABLED) { static_branch_enable(&dp->key.dd_key_true); } #endif From patchwork Sat Feb 10 23:49:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199326 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1700420dyd; Sat, 10 Feb 2024 15:51:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWAvfzf8IVCNjMFbNesoaVuJ5LoH4YzjWJhFD6iEKJTUJ10U+EpphPG9Qic6DVa6YbqKKlgp7uI4KszMK4ucsLmZllzCg== X-Google-Smtp-Source: AGHT+IF7dT2Gm38fFh0HDNz9XEjd+I5aI7iGcAypN4BLuA6Tz5Yg/mSIoZPtudD5qyH516vn7R3M X-Received: by 2002:a05:6808:14c5:b0:3c0:31ab:b945 with SMTP id f5-20020a05680814c500b003c031abb945mr1833805oiw.4.1707609082155; Sat, 10 Feb 2024 15:51:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609082; cv=pass; d=google.com; s=arc-20160816; b=LWuCOGZD99TjO4xiCHaCSUUwGv26Y9J//MUGmta0SVpD1TrA8fdaLF3PcQBzN81zwf bnEqOQqm60OgI4N0Vn4AYZz4NAhzwvax3Z0zaQjQRpKK3Ijq8Zkdt56a+dU6+ujpBlHB F2rsVJ+/urKIAdg8Tbq2zsTYTqCjFuq/Ia+8tyEjKKjNTWiebRiIA91qXwnzFg9e66yV OLa8a7DciLDODhYN8RBDAU0ttlLA0s5yk9Gx1FX+Fln05IBb4F1aI28s7IlM9iQGwgD3 YkfEEWSQTHyQRSVC2WTW+o3EWVaDEWLjp18G/LgHp46xVhiPzDQhNX1cHG12QSz12oac 7bfg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hiwuT5//sOCIH4TJbmBqDDmgy+L0dj/76G1O/T9yDvA=; fh=5Qx+1MQQbr7INrKANz1kksT+PU/rFGpT9insUoekoPc=; b=hpXaO1/VlA+uOyFhqiCnnCQ2fA1EW0tIejfZX7iIn79RO0dVuODBDfe32v7EY9vU5E ORb5RdFWu7EDbW6ybB1+W7GvedCLmYKjn3vyg1Uj/zBbVKc5QwpnbErVLJDKKva8MDf2 18Ht3USlyhrVmNV7/TNRqp4fWLG0YJGZQfshMVY8OUAlW2BK7jrlvo7rEVpyz8irq+Zn KLC4Wpf/o8GnSotDS9VYGud2LyWsvs45qJZTqKdIXIvYjtKJedvIuSRGxDqjgWAryxVO QNXLW9EfteZAZvzL46DORr98undHnGDpgPmfNz/2B7nPp0RpSxtAebpLuYFksmVS3w40 /zyw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=N+15cEnr; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60585-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60585-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCURyjZagTkLqm5ITEDpwgDFgKeSt6Ix9BQsOQjKckc1A9pD3Y2FXG9aj8KGkfGyHKBhoqwH4m+Jb1htW4wnZ0wmxK7Gjw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id j20-20020a056a00175400b006e086e4c2c9si2682883pfc.22.2024.02.10.15.51.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:51:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60585-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=N+15cEnr; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60585-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60585-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 2F6A7B22B84 for ; Sat, 10 Feb 2024 23:51:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 881CF604B6; Sat, 10 Feb 2024 23:50:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="N+15cEnr" Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (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 C3CCA5FF0C for ; Sat, 10 Feb 2024 23:50:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609036; cv=none; b=R11n0k3igrET7zGAhNBmezplVTFF1HuZB/dGAHZgpxfF2FLHEk36Cqzy4tL5SSpOlQux6y2zYdfDxOhRkg4tV8K51IWm/z9jVXOfoNE4rWPXYYFzZS71lyzndh19Kzi5ptn1eNecUIXFkvMFGYDis5LBVdyxbDInblvXb4q9e/E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609036; c=relaxed/simple; bh=cQmyob+SZ2xtIRHDID5i37Q2ZrwCWWtVkuImLDQlG8I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dUvXHbzxsZNzhFxzlGUg0ShckNPjUf6c9MF9fkgKtLLYoxyaojQeJGpOrmL/kRm5Xd7lb8wQND6Uaugr4Xj5TH3X3idsScpNEMMglkIHSpkzS9hLdzYeQPWy4K3olETZ28JQBfiZZSBgVXppu7BOZvXBzZhElVKAVX+duq68g4k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=N+15cEnr; arc=none smtp.client-ip=209.85.167.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-5116b540163so3090535e87.1 for ; Sat, 10 Feb 2024 15:50:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609033; x=1708213833; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hiwuT5//sOCIH4TJbmBqDDmgy+L0dj/76G1O/T9yDvA=; b=N+15cEnrjnrGkuG/+gzqPPtnfaYDFcsLqv2DRmf14bpgwzKDbU/KgWDw+JT7kJRM8w nCLqp9l8BMhJuNrPFQZ8SEnyub5I+nqliOriEANIMhv/vYftT8gry+ZI4S4n4M3CisfB wJwPgCi1y/4NomFk6YfqHPov89zstXVcC/bOg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609033; x=1708213833; 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=hiwuT5//sOCIH4TJbmBqDDmgy+L0dj/76G1O/T9yDvA=; b=t0cbvu6f9Th7DLYykTpZD38dFDMWJGaDKcTATwEtKZXDJMu2J+I7I4GP0MKzm/nbB8 pnCwJU+BD4GynlhrykjDKBOW+c3OPu623BSDgHgRb9qNzxVHoAEI7NKKvG95c8MT6MzY tMNNsoh+AYauPPdsD1FetmNHhWY0dwxoGsKs64HTMsmEGnIwKwhEXW+nNvne5N5QOUkz 7Q0k5YKj7PI6OU49B66ZzYM3giwXt1OOEKXEZYQ43gH9gz3MEWhHYYz98so7ufIk71ic 7OzHdBNZ3Knx3b/UqdBlvliHFFG6jo6I6piHHU59L4y/0HIK46+eAnkXskSCarhhZYQX CegQ== X-Forwarded-Encrypted: i=1; AJvYcCWYpWE/VDYDFfenvod1SKX5vc7EKDZD+DwdBkr3hlEj5+EGiiB4UNwGeKZANGvnZBzkBVT/SEy8RfPyBvOFED81bcbYkh0ylZaY6GuB X-Gm-Message-State: AOJu0Yw0V4982hqjIxgUyzE7HTbY1Dr3gJn2DFBLSGt+Sjt/p/8FrbAV O74696UDIQswrDLsb4C7l/58TPhVPwYnheyELMf8OWtVW0Kr8nnAZ2/1ZBuy X-Received: by 2002:a19:7412:0:b0:511:4baa:fda8 with SMTP id v18-20020a197412000000b005114baafda8mr1726910lfe.38.1707609032587; Sat, 10 Feb 2024 15:50:32 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVutNH7wXArtZPi16MtiRS1ZNDSArgZzaxKHiPK6BMvhOO/SUfoVl9yVPeMxchKHlhQVAOPkiT6h0Xwa7V76mi+ZxC/Lf558xBN0UhCJ/1jEy7uhVNblQFYQslaNsH1LT02l4WEDjUKdSP31a+2bPAB7sGzl2FBnyaRAkGZ1Aipc6xssHYAtMCFr7VCXmXCw7ST25ukym5FoEZfuQH1+GbcKpT619MEaWUN7o0GaHHnRVSDuguc/dmRIzYyGJ0NAXhuoMWTr5iV71XdmMk3dxu0C4cXwVv9PteLj4et9ldixULw7Ow7gZPYEdpZoms/71+I+nschx45i8dvlxBbAyATdJdosk0ObRHZK24LI/LM/60fsIL1TbiQd6C1Ac2m5VxdkmXNIiMCYAG6jXeTzWrsVnFTBWNOeIUdUr5TUz+oBokl5Ql6zi3epSu77XA1IGE9gieNxcvB4lQ79PqSDFsjy17YFXk3wdA5vy9S+ZUzpNVxeXbBI6EQLX9uQaJO/nJw7LNBW/hNEio8TB/sD/zUJw5t8xy7Iv2/BCx6Mrir+qq/PrW2POJM1YGx4kGUp8JAV8wx5bRCR0us+XbUPzTg+vdTpEBgK73wY2GBvJ9SOMCh0g== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:32 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 02/39] dyndbg: add _DPRINTK_FLAGS_TRACE Date: Sun, 11 Feb 2024 00:49:32 +0100 Message-ID: <20240210235009.2405808-3-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790557901122021939 X-GMAIL-MSGID: 1790557901122021939 From: Jim Cromie Add new flag, and OR it into _DPRINTK_FLAGS_ENABLED definition CC: vincent.whitchurch@axis.com Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 7be791af7cf1..497130816e9c 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -33,6 +33,9 @@ struct _ddebug { */ #define _DPRINTK_FLAGS_NONE 0 #define _DPRINTK_FLAGS_PRINTK (1 << 0) /* printk() a message using the format */ +#define _DPRINTK_FLAGS_TRACE (1 << 6) +#define _DPRINTK_FLAGS_ENABLED (_DPRINTK_FLAGS_PRINTK | _DPRINTK_FLAGS_TRACE) + #define _DPRINTK_FLAGS_INCL_MODNAME (1<<1) #define _DPRINTK_FLAGS_INCL_FUNCNAME (1<<2) #define _DPRINTK_FLAGS_INCL_LINENO (1<<3) @@ -44,8 +47,6 @@ struct _ddebug { _DPRINTK_FLAGS_INCL_LINENO | _DPRINTK_FLAGS_INCL_TID |\ _DPRINTK_FLAGS_INCL_SOURCENAME) -#define _DPRINTK_FLAGS_ENABLED _DPRINTK_FLAGS_PRINTK - #if defined DEBUG #define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINTK #else From patchwork Sat Feb 10 23:49:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199327 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1700497dyd; Sat, 10 Feb 2024 15:51:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IGJnU7+mi8l7qUM8kXwL9fTkj/e4Jdv2c8wU4FJbu95RCp+TES+yd+lGieU0Ch8srtjZ+d4 X-Received: by 2002:ac8:4e8e:0:b0:42c:63a8:5c9f with SMTP id 14-20020ac84e8e000000b0042c63a85c9fmr2845105qtp.33.1707609105355; Sat, 10 Feb 2024 15:51:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609105; cv=pass; d=google.com; s=arc-20160816; b=rftWlC2JxXEgfFkZiImk4itmcDTta2eyWfB65Um/+n6PXnKli7JOwMmL1kgPMvs3ku Xe+kr+TCaU46zOJe68/4mm0trYV3b7Hf6JlnKHKVhqC7HzAZgjAqMZbJxro4r86o/Wer 5nuoKfLpnkenFxkYn3G57UksQwCfrJlc+g2L2tUBRKA6/bfqxseRo77HCWohzObEUOTQ iCfsYfKBD/gDJgRf84kTezJ0nkexmB9S1frHVjVyzFol7VcUPA4nZA52+UZ/ct3gz6gr TAz8BpWx+lCbfJcOshKkynnKBno3c3+T8Ob0QvaemM8KHSVn3bGiiz7oZGOumzXO+of4 dpKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ly40RGk0505qZZwJrMXVp+0btu3kjXk0eZbz7jDJEP8=; fh=lBBZMKEe8qj1g4sq83oOs03+UN3MpksOOZ1SbsxMawk=; b=PLryxK2UE03q/9/hMVtSuaE6BZ0OxNo9LheXqWHMBVUj/xvwSwbppSjQUC9+//rVsP X64AZ1cBaux0iP7w55UPuRCCu3cShINAvh3sNKDw0+0dL65HpOaiBEaX1wsVQ9FIVeN5 k89/pEGxrG2p1sC8IsApdo3ERyUuYNP5s6/lIYM6Sv6etrgMctti+AciXQuchGQpjGG2 xeaPrNZAaPSD7X0Cf223F5yogats2Ll8RgSZDYkBq6l21n8X0fT7cIKU3NsignI4v4bk EkrjMA/exnzS7gYzMTXyORThbhEGZhSmEw27sZvdmK364A8R7q2Iv3lm8/JWUVrs/5jT my/w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PB8zS2jS; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60586-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60586-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCVBReAOns9q9YZvglivVXAn/BXJ7mGVrzTniGrWFrm63CSukcLTAmNUK2UuRWdluXFi/QvX7DrJpzQQS+9SebJ4wZJRDA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id b23-20020a05620a119700b00785ba2b09f4si2816499qkk.214.2024.02.10.15.51.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:51:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60586-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PB8zS2jS; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60586-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60586-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 1315B1C2122A for ; Sat, 10 Feb 2024 23:51:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DFB19605AA; Sat, 10 Feb 2024 23:50:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="PB8zS2jS" Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (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 81A3160246 for ; Sat, 10 Feb 2024 23:50:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609038; cv=none; b=URedz/+kf5eHZq4k1P30WRexfSWF2LnQ9S/IcHjEG1zoNqS9Fm0nPQod3agcMi9ivigU9/TbZjoWxkvK6Z2+i81oct1EKUmjuv0+opxRQExk9J6AXctz+9v6Z0/uwBZsuhqH+lO+zfgbfbKAz7R6Nd0R3ZAKnUNO+uPd82zJG1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609038; c=relaxed/simple; bh=242XzWlkrmIbWKryguVx0gbpFFR2SSZonxu1VaG0yK8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Mk46e8NhN56bQGWERHIYDYplJagTUUt0nTPBAJudv/uvTGVId+0Ofq7mnp+/YQuvCGZNq8zyZaOMLr3oZZqAkUpoahghI+rmHgdcVWAMEDeHYwCe+GIvcQLbJ8faUxtrwm6lUalS6zlrQGEzVgvnm1nQbbDHUSnfsaua9TyxRc4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=PB8zS2jS; arc=none smtp.client-ip=209.85.208.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2d073b54359so29828201fa.0 for ; Sat, 10 Feb 2024 15:50:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609034; x=1708213834; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ly40RGk0505qZZwJrMXVp+0btu3kjXk0eZbz7jDJEP8=; b=PB8zS2jSs1y++yx9b7ngXmi7ZiZZFcRlNrwrSkne5yYdxwmCHnaZUBsQoq1b+cVCLV RU1961sLdyLpEsTszWZpwaE719yJhYPM4W0qXR6oKBnU3pJuc5srNhA+zeujdnj9Bgc4 q1wV5HcWxowhzhJPf6o4GHkXbJVN5E0NwCbpQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609034; x=1708213834; 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=ly40RGk0505qZZwJrMXVp+0btu3kjXk0eZbz7jDJEP8=; b=BJUT40ax2NBIay5qRYNuIn+bQIMoYsM0ez8H2Fwzr54vJaFuApcKj/0uS4qSy9oYiF anAvaFo+nBsVGgzgVXNUQ7RZY9UfPcKEGnEcJTpnTQg5aB7g1bnISjhrMaLRVrnJ5CyT Rxsq8i5QEqkWjyIYY7R3gVBudmHvVVlm+BF1Rpn2NVIf2QP3puLBfUCn3yAlB2IowfFM gl4CcgUWfXnlS4Rf6lG0SceDDTWT6H++U5YTF1pfQ+xex3j28B8EOPoEbGnXQxVbDHt1 c40USg0QbHxkk1H2NQPCw2228rtv1CurhXUspFJK46feaGAVvlQeSdlMWOJF2BK/18hH /GTQ== X-Gm-Message-State: AOJu0Yx0uNI+WiYdJSjHM3ZgKPhxXs5zfyDRRhV1c1oX4UloVAoM235G Fk6mVIUDGOk53dJcjWlIkJYQxJxVL+qqj+1Q1m7iXSnKWYjO9ty3pUG+akS0G8vwEaoxiHc/ag= = X-Received: by 2002:a05:6512:238d:b0:511:81ed:1a53 with SMTP id c13-20020a056512238d00b0051181ed1a53mr1860445lfv.42.1707609034272; Sat, 10 Feb 2024 15:50:34 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVBg465FgvzkgKJbJecrQpVIvaSXaGMrZD1YX9kJKKqsnesrwM9NAcdeckeKPzTEJwYAY6MLfbXseetLZXpYG15LWw+X8FSTw37Vwn8NKjNCcadSBu7C8q5SfYpa0sSg1Wj686rA7yNclSsHYnFBugs1hoGIjgOPz6MD5XjBLn/w2V87A4A3ltukN09Fqae4YqqWundx/ECz8ja2yZ+fuUtKfR5ZuyD77MR7DGJaj3WuF8XGZXZ+zDot3tiZU/eQhv9ckSxFL9+gSc9Q2t8KL2yec+rMnyYZsLdjP3o4CJ7X7fYUr9t3sC5b36UtbuH4g+80ooCOwCoNTaWPPdAgEyQvlXOdOOMwU87sxu8wxk94pCCm9vmP3JTRPsGJ6t127GuqsHE/mz9xFJuZ2rmZr8kn7gg5b9HtQvQEtYImVUKcM5X+Y08CXuqxUWWkzUCH82/lUhVE1xo/+d17CtQyQS1vZZVmlkYHPrC7+ssRKI4s5VGvuIaB0fQ4QdyZGJyO6JEIJY5aKUe1f2GfU58KZm/EH1OkQSK3bRcotWpCIOi2Wq4KDHwxGjn3QdwtQl1wJkOvKu7CzbhA6SZ+UNRHq8Nr8ShKIr+uQgE8qYSWeGO3+Re7g== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:33 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 03/39] dyndbg: add write events to tracefs code Date: Sun, 11 Feb 2024 00:49:33 +0100 Message-ID: <20240210235009.2405808-4-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790557925093248131 X-GMAIL-MSGID: 1790557925093248131 From: Jim Cromie adds: ddebug_trace() uses trace_console() temporarily to issue printk:console event uses internal-ish __ftrace_trace_stack code: 4-context buffer stack, barriers per Steve Rostedt call it from new funcs: ddebug_printk() - print to both syslog/tracefs ddebug_dev_printk() - dev-print to both syslog/tracefs These handle both _DPRINTK_FLAGS_PRINTK and _DPRINTK_FLAGS_TRACE cases, allowing to vsnprintf the message once and use it for both, skipping past the KERN_DEBUG character for tracing. Finally, adjust the callers: __ddebug_{pr_debug,{,net,ib}dev_dbg}, replacing printk and dev_printk with the new funcs above. The _DPRINTK_FLAGS_TRACE flag character is 'T', so the following finds all callsites enabled for tracing: grep -P =p?T /proc/dynamic_debug/control This patch,~1,~2 are basically copies of [1] with a few differences: - s/dynamic_/ddebug_/ on Vincent's additions - __printf attrs on the _printk funcs - reuses trace_console() event, not adding a new "printk:dyndbg" event. next patch replaces this with 2 new events [1] https://lore.kernel.org/lkml/20200825153338.17061-1-vincent.whitchurch@axis.com CC: vincent.whitchurch@axis.com Signed-off-by: Jim Cromie --- .../admin-guide/dynamic-debug-howto.rst | 5 +- lib/dynamic_debug.c | 156 +++++++++++++++--- 2 files changed, 133 insertions(+), 28 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst index 0e9b48daf690..90449a04946e 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -209,8 +209,9 @@ of the characters:: The flags are:: - p enables the pr_debug() callsite. - _ enables no flags. + p callsite prints to syslog + T callsite issues a dyndbg:* trace-event + _ enables no flags Decorator flags add to the message-prefix, in order: t Include thread ID, or diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index ee0cb37153ef..016f33c20251 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -90,6 +91,7 @@ static inline const char *trim_prefix(const char *path) static const struct { unsigned flag:8; char opt_char; } opt_array[] = { { _DPRINTK_FLAGS_PRINTK, 'p' }, + { _DPRINTK_FLAGS_TRACE, 'T' }, { _DPRINTK_FLAGS_INCL_MODNAME, 'm' }, { _DPRINTK_FLAGS_INCL_FUNCNAME, 'f' }, { _DPRINTK_FLAGS_INCL_SOURCENAME, 's' }, @@ -858,6 +860,98 @@ static inline char *dynamic_emit_prefix(struct _ddebug *desc, char *buf) return buf; } +/* + * This code is heavily based on __ftrace_trace_stack(). + * + * Allow 4 levels of nesting: normal, softirq, irq, NMI. + */ +#define DYNAMIC_TRACE_NESTING 4 + +struct ddebug_trace_buf { + char buf[256]; +}; + +struct ddebug_trace_bufs { + struct ddebug_trace_buf bufs[DYNAMIC_TRACE_NESTING]; +}; + +static DEFINE_PER_CPU(struct ddebug_trace_bufs, ddebug_trace_bufs); +static DEFINE_PER_CPU(int, ddebug_trace_reserve); + +static void ddebug_trace(const char *fmt, va_list args) +{ + struct ddebug_trace_buf *buf; + int bufidx; + int len; + + preempt_disable_notrace(); + + bufidx = __this_cpu_inc_return(ddebug_trace_reserve) - 1; + + if (WARN_ON_ONCE(bufidx > DYNAMIC_TRACE_NESTING)) + goto out; + + /* For the same reasons as in __ftrace_trace_stack(). */ + barrier(); + + buf = this_cpu_ptr(ddebug_trace_bufs.bufs) + bufidx; + + len = vscnprintf(buf->buf, sizeof(buf->buf), fmt, args); + trace_console(buf->buf, len); + +out: + /* As above. */ + barrier(); + __this_cpu_dec(ddebug_trace_reserve); + preempt_enable_notrace(); +} + +__printf(2, 3) +static void ddebug_printk(unsigned int flags, const char *fmt, ...) +{ + if (flags & _DPRINTK_FLAGS_TRACE) { + va_list args; + + va_start(args, fmt); + /* + * All callers include the KERN_DEBUG prefix to keep the + * vprintk case simple; strip it out for tracing. + */ + ddebug_trace(fmt + strlen(KERN_DEBUG), args); + va_end(args); + } + + if (flags & _DPRINTK_FLAGS_PRINTK) { + va_list args; + + va_start(args, fmt); + vprintk(fmt, args); + va_end(args); + } +} + +__printf(3, 4) +static void ddebug_dev_printk(unsigned int flags, const struct device *dev, + const char *fmt, ...) +{ + + if (flags & _DPRINTK_FLAGS_TRACE) { + va_list args; + + va_start(args, fmt); + ddebug_trace(fmt, args); + va_end(args); + } + + if (flags & _DPRINTK_FLAGS_PRINTK) { + va_list args; + + va_start(args, fmt); + dev_vprintk_emit(LOGLEVEL_DEBUG, dev, fmt, args); + va_end(args); + } +} + void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) { va_list args; @@ -872,16 +966,18 @@ 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); + ddebug_printk(descriptor->flags, KERN_DEBUG "%s%pV", + dynamic_emit_prefix(descriptor, buf), &vaf); va_end(args); } EXPORT_SYMBOL(__dynamic_pr_debug); void __dynamic_dev_dbg(struct _ddebug *descriptor, - const struct device *dev, const char *fmt, ...) + const struct device *dev, const char *fmt, ...) { struct va_format vaf; + unsigned int flags; va_list args; BUG_ON(!descriptor); @@ -891,16 +987,18 @@ void __dynamic_dev_dbg(struct _ddebug *descriptor, vaf.fmt = fmt; vaf.va = &args; + flags = descriptor->flags; if (!dev) { - printk(KERN_DEBUG "(NULL device *): %pV", &vaf); + ddebug_printk(flags, 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); + ddebug_dev_printk(flags, dev, "%s%s %s: %pV", + dynamic_emit_prefix(descriptor, buf), + dev_driver_string(dev), dev_name(dev), + &vaf); } va_end(args); @@ -913,6 +1011,7 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, const struct net_device *dev, const char *fmt, ...) { struct va_format vaf; + unsigned int flags; va_list args; BUG_ON(!descriptor); @@ -922,22 +1021,24 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, vaf.fmt = fmt; vaf.va = &args; + flags = descriptor->flags; if (dev && dev->dev.parent) { char buf[PREFIX_SIZE] = ""; - dev_printk_emit(LOGLEVEL_DEBUG, dev->dev.parent, - "%s%s %s %s%s: %pV", - dynamic_emit_prefix(descriptor, buf), - dev_driver_string(dev->dev.parent), - dev_name(dev->dev.parent), - netdev_name(dev), netdev_reg_state(dev), - &vaf); + ddebug_dev_printk(flags, dev->dev.parent, + "%s%s %s %s%s: %pV", + dynamic_emit_prefix(descriptor, buf), + dev_driver_string(dev->dev.parent), + dev_name(dev->dev.parent), + netdev_name(dev), netdev_reg_state(dev), + &vaf); } else if (dev) { - printk(KERN_DEBUG "%s%s: %pV", netdev_name(dev), - netdev_reg_state(dev), &vaf); + ddebug_printk(flags, KERN_DEBUG "%s%s: %pV", + netdev_name(dev), netdev_reg_state(dev), &vaf); } else { - printk(KERN_DEBUG "(NULL net_device): %pV", &vaf); + ddebug_printk(flags, KERN_DEBUG "(NULL net_device): %pV", + &vaf); } va_end(args); @@ -953,26 +1054,29 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, { struct va_format vaf; va_list args; + unsigned int flags; va_start(args, fmt); vaf.fmt = fmt; vaf.va = &args; + flags = descriptor->flags; if (ibdev && ibdev->dev.parent) { char buf[PREFIX_SIZE] = ""; - dev_printk_emit(LOGLEVEL_DEBUG, ibdev->dev.parent, - "%s%s %s %s: %pV", - dynamic_emit_prefix(descriptor, buf), - dev_driver_string(ibdev->dev.parent), - dev_name(ibdev->dev.parent), - dev_name(&ibdev->dev), - &vaf); + ddebug_dev_printk(flags, ibdev->dev.parent, + "%s%s %s %s: %pV", + dynamic_emit_prefix(descriptor, buf), + dev_driver_string(ibdev->dev.parent), + dev_name(ibdev->dev.parent), + dev_name(&ibdev->dev), + &vaf); } else if (ibdev) { - printk(KERN_DEBUG "%s: %pV", dev_name(&ibdev->dev), &vaf); + ddebug_printk(flags, KERN_DEBUG "%s: %pV", + dev_name(&ibdev->dev), &vaf); } else { - printk(KERN_DEBUG "(NULL ib_device): %pV", &vaf); + ddebug_printk(flags, KERN_DEBUG "(NULL ip_device): %pV", &vaf); } va_end(args); From patchwork Sat Feb 10 23:49:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199328 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1700554dyd; Sat, 10 Feb 2024 15:52:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IELjnwDa4YWWHg23TIpT0ybc+1BqQetX6Y2T0pHQ/iI2MpFZRbAnn3SAIcVPf9nuF5WM98C X-Received: by 2002:a0c:dd14:0:b0:68c:627f:ed53 with SMTP id u20-20020a0cdd14000000b0068c627fed53mr3430592qvk.59.1707609123757; Sat, 10 Feb 2024 15:52:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609123; cv=pass; d=google.com; s=arc-20160816; b=vJN6HjKYOodWdhF0BTHOw//uTPLDebB8iJPS0vNxWmfEgKVTqpeEkEqELqq8nJMEZb 0kODPo3ID4sqxG2jmsUVLFKoWkZjQvS5p1tWMprGvQd8t6lNedzo/wzmY8mxhYKx94vK 9pIaF3xNxpO1rPa3AA6txiFaM5NFBaLncVn6hXS0SiIllLoZ0p/bdB0rf3i+EGmFPmpf cQPe+Nm7WlwAV7jX+/4G8lNSCuW3RTlgh6S2YNXsNUp0G2VrppXN7yyikn+AB2k7O7Yq Wa1NI8Y8gtjIkMl+oTncmtxXAB94ru+IPhrHxRpIPbG0LcXQEwjZLbQRuZRU2KMUjlp2 didw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=YLc3gWSl0LchmKR99ALue7JLN9oC+x+LGj79tJSMKXk=; fh=8MZXUGOSUUirSnwSzdKF/8pZG+/gft0a7ifcqKHJA7w=; b=Sp3XzyYbhJ+ZWDej0YRL1/kafo1MrXvUUwxDPt+Bmn6E5AGw3vv8pYX/IinNqAwVj+ Bn0giYubXgeKRmZ/vKS5IJJDAYFBdbZ6RpQolOT6z1klBDd3OzimQ9PrnN2wfP6lKQKJ a9a23wnZoWsMJSKg3o2UIz2Xl4Nc89kUhUtXlpQCA6E6Tsu9l78+i8Ko+ndogff3qovx QAvRAxqbkTPzDMOBGKfZ3dHigToGMWgHCyya5mtt7BVlpeQCC2mZm3AUnYCSJKsDRxM0 5CHL+y3jv6VRFy96DSlyJlfxE3gd1ZGqONNZ7mH5KLlxKxtx+x9fYUgKlkz5xOJd+jzS /ZPw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="TPcv2/vp"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60587-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60587-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCUyHniPUc7B+vCzBS8DLzdmDx7rKvLTu+LFLpYb7AXGnAVnsTFSgtITFRDogQfYAg9z2PC1S6G5w9DauerZU2+GHOF2Bg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id jk13-20020ad45d4d000000b0068cd864e3a6si4008612qvb.445.2024.02.10.15.52.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:52:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60587-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="TPcv2/vp"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60587-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60587-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7CDF81C21734 for ; Sat, 10 Feb 2024 23:52:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8ED4C605D2; Sat, 10 Feb 2024 23:50:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="TPcv2/vp" Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (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 EAE946026D for ; Sat, 10 Feb 2024 23:50:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609040; cv=none; b=cGrQpH+a+qfOJpHoP3pPhxVa/4c6P2i7sny8FOfSYEK3hgpLXJuevhjhlUghMYiY5B4VJPSLQ4EVuM2dPoa9At076HTOcfPCTsacreErp8VlJjqYiQCcrU+w8phivuUnmdYOT86FwEEEgMisnHAsFOY8ZEWhqcTtidEHmGfDoW4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609040; c=relaxed/simple; bh=0WPu5jLceer/15RgqkDnTN8EtF6NRfk3cwJFKokZXw8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WdYhPp2uW3fPmIcuX1UiywOyZ6TvhcpUOwyHinkMlvKhNaYzm7GLxwdpwVokpu054EegT5LWG6FlGYC3cUyNXabxPUwgucgIl7MOnAf307zOuUYVe3CyiteGn0xeWIGK1BvCnjeAvbPGgIizYXFKLy/6TUnKjCPCNqyQzXc03ik= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=TPcv2/vp; arc=none smtp.client-ip=209.85.167.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-5114c05806eso3460895e87.1 for ; Sat, 10 Feb 2024 15:50:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609036; x=1708213836; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YLc3gWSl0LchmKR99ALue7JLN9oC+x+LGj79tJSMKXk=; b=TPcv2/vpk1PbjwueE4X9Bh3G/6pn4azZHMUYmEvuaP0giC+E+RFZ/SN2g7LJZxisnw OTw92MSpjpiTgZF0iqOKY5N2+b9b2t1fOyK9lSh1O8pNeZHPGMm1pqv82uyIlQwXxVjg Mc3b7km+SRGFCukjGPFwI/LafJojzHSNvcJQY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609036; x=1708213836; 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=YLc3gWSl0LchmKR99ALue7JLN9oC+x+LGj79tJSMKXk=; b=LjpL7Ac3jOwpUFyakHgbtw5rvEz7v4zA6FO6FDE24s+uzZnhbFM5gLDyhCsrMGUrRM UP8C2d+RmVPIoifb6hGog3+CGQSBNJ+IlncWNgMsBjfFyIdYAgukp/q+FGTL/tDUXF6I nZRHrallIfKEnnM+YBO9ZPVZh3LW25bTSLIQOtepiTuV8ABymNi+5Z8oi0ErhrfYn3/f iV26gfEXmXohhk+V+PDd/Z1Xs7Dc+0Cwn7RquYqqgXYYgy22uE/qiew2twtDEyVSMTxo uAoq096aPJlzetVZgFgXEIrkRk/4s/CEMDXum2p8stokxYGWOBHIsFVAmnn/fbrflnIM DQKQ== X-Gm-Message-State: AOJu0YxaXs89vQnM5qaNL2JZwwciRDmhcfnfpiFNApkNhJfAGf+yJK/g 9saAbA7eZZdoIn8qUpXeFWnBEITDrZUXYb5KaBeZ4KaEO4WZqsdxn8G6qHaG X-Received: by 2002:a05:6512:3a8b:b0:511:6e10:b80e with SMTP id q11-20020a0565123a8b00b005116e10b80emr2312748lfu.33.1707609035990; Sat, 10 Feb 2024 15:50:35 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXaQDyedBIoalcHoj2hK83zkBhs6ItS+Rswe3MiPpk7uCpr83LdsqrqFU4cVDjrNGQit7ssv0A1f5ixj7MOEVkvhop0dgy/K0hE4FQ07Ml8TdyQ4CS2PGbJ+/72sLx/j3vTrtiSoXmfeJpjGhIwmly1aTk55s9h62u87KsfFCBoPAqeJKqy+9Jm1eRf9ufq9sXIWBDq1b4MmkOosKnXSmtoxvQhZ+Yb61fMKuv9YmkhjIr1bevnedaYW3UT9yKQIliPuOHSvgPxx2XacEDP6v/b+pEwN+xBXsjZoJ/P1mOG375ajp2/Ci7uoJFC8LgASS8ffxHoW+2wPMbemvH44WVCnIbBMJ7IWcEQ+t2ncPBKaO5dldNsvR/o9NyN5AikHZrqa83+A/tYHqrZyvQ1NbpJCgCSORJUtYU0w1GYrvgtl5zP7/nEi6SHNte2tYBt/7v9rOyk55TMDYQbG5KiYXiZSz4h11XshKfi6ufZNDpix2yAseFB6S5ZpUWE20TAvev3Wkk6CVv6VAw98iDs19CcZq1tIoKKGcIGOZBEDe22lekxTe50/UYRwsdfjcYcHZdsMFTMA2WB/JslnyQXakLXSE82jvajLNm0A5Tj7IsUZdhavg== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:35 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 04/39] dyndbg: add 2 trace-events: prdbg, devdbg Date: Sun, 11 Feb 2024 00:49:34 +0100 Message-ID: <20240210235009.2405808-5-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790557944143623351 X-GMAIL-MSGID: 1790557944143623351 From: Jim Cromie ddebug_trace() currently issues a single printk:console event. Replace that event by adding include/trace/events/dyndbg.h, which defines 2 new trace-events: dyndbg:prdbg & dyndbg:devdbg. These events save a debug message and use its length for processing. They also accept the _ddebug descriptor and dev structure so they can be used to access the whole callsite record in the future: file, line, function, flags. This allows the addition of a dynamic prefix later. So ddebug_trace() gets 2 new args: the descriptor and the device. And its callers: ddebug_printk(), ddebug_dev_printk() upgrade their flags param to pass the descriptor itself, and thus also the flags. Signed-off-by: Jim Cromie Co-developed-by: Łukasz Bartosik Signed-off-by: Łukasz Bartosik --- MAINTAINERS | 1 + include/trace/events/dyndbg.h | 63 ++++++++++++++++++++++++++++++ lib/dynamic_debug.c | 73 ++++++++++++++++++----------------- 3 files changed, 101 insertions(+), 36 deletions(-) create mode 100644 include/trace/events/dyndbg.h diff --git a/MAINTAINERS b/MAINTAINERS index 960512bec428..b584a8468fb9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7456,6 +7456,7 @@ M: Jason Baron M: Jim Cromie S: Maintained F: include/linux/dynamic_debug.h +F: include/trace/events/dyndbg.h F: lib/dynamic_debug.c F: lib/test_dynamic_debug.c diff --git a/include/trace/events/dyndbg.h b/include/trace/events/dyndbg.h new file mode 100644 index 000000000000..647c30206a7d --- /dev/null +++ b/include/trace/events/dyndbg.h @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM dyndbg + +#if !defined(_TRACE_DYNDBG_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_DYNDBG_H + +#include + +/* + * template for dynamic debug events + * captures debug log message and uses its length, it also + * accepts _ddebug and dev structures for future extensions + */ +DECLARE_EVENT_CLASS(dyndbg_template, + + TP_PROTO(const struct _ddebug *desc, const struct device *dev, + const char *msg, size_t len), + + TP_ARGS(desc, dev, msg, len), + + TP_STRUCT__entry( + __dynamic_array(char, s, len+1) + ), + + TP_fast_assign( + /* + * Each trace entry is printed in a new line. + * If the msg finishes with '\n', cut it off + * to avoid blank lines in the trace. + */ + if (len > 0 && (msg[len-1] == '\n')) + len -= 1; + + memcpy(__get_str(s), msg, len); + __get_str(s)[len] = 0; + ), + + TP_printk("%s", __get_str(s)) +); + +/* captures pr_debug() callsites */ +DEFINE_EVENT(dyndbg_template, prdbg, + + TP_PROTO(const struct _ddebug *desc, const struct device *dev, + const char *msg, size_t len), + + TP_ARGS(desc, dev, msg, len) +); + +/* captures dev_dbg() callsites */ +DEFINE_EVENT(dyndbg_template, devdbg, + + TP_PROTO(const struct _ddebug *desc, const struct device *dev, + const char *msg, size_t len), + + TP_ARGS(desc, dev, msg, len) +); + +#endif /* _TRACE_DYNDBG_H */ + +/* This part must be outside protection */ +#include diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 016f33c20251..fcc7c5631b53 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -36,7 +36,9 @@ #include #include #include -#include + +#define CREATE_TRACE_POINTS +#include #include @@ -878,7 +880,9 @@ struct ddebug_trace_bufs { static DEFINE_PER_CPU(struct ddebug_trace_bufs, ddebug_trace_bufs); static DEFINE_PER_CPU(int, ddebug_trace_reserve); -static void ddebug_trace(const char *fmt, va_list args) +__printf(3, 0) +static void ddebug_trace(struct _ddebug *desc, const struct device *dev, + const char *fmt, va_list args) { struct ddebug_trace_buf *buf; int bufidx; @@ -897,7 +901,11 @@ static void ddebug_trace(const char *fmt, va_list args) buf = this_cpu_ptr(ddebug_trace_bufs.bufs) + bufidx; len = vscnprintf(buf->buf, sizeof(buf->buf), fmt, args); - trace_console(buf->buf, len); + + if (!dev) + trace_prdbg(desc, NULL, buf->buf, len); + else + trace_devdbg(desc, dev, buf->buf, len); out: /* As above. */ @@ -907,9 +915,9 @@ static void ddebug_trace(const char *fmt, va_list args) } __printf(2, 3) -static void ddebug_printk(unsigned int flags, const char *fmt, ...) +static void ddebug_printk(struct _ddebug *desc, const char *fmt, ...) { - if (flags & _DPRINTK_FLAGS_TRACE) { + if (desc->flags & _DPRINTK_FLAGS_TRACE) { va_list args; va_start(args, fmt); @@ -917,11 +925,11 @@ static void ddebug_printk(unsigned int flags, const char *fmt, ...) * All callers include the KERN_DEBUG prefix to keep the * vprintk case simple; strip it out for tracing. */ - ddebug_trace(fmt + strlen(KERN_DEBUG), args); + ddebug_trace(desc, NULL, fmt + strlen(KERN_DEBUG), args); va_end(args); } - if (flags & _DPRINTK_FLAGS_PRINTK) { + if (desc->flags & _DPRINTK_FLAGS_PRINTK) { va_list args; va_start(args, fmt); @@ -931,19 +939,19 @@ static void ddebug_printk(unsigned int flags, const char *fmt, ...) } __printf(3, 4) -static void ddebug_dev_printk(unsigned int flags, const struct device *dev, +static void ddebug_dev_printk(struct _ddebug *desc, const struct device *dev, const char *fmt, ...) { - if (flags & _DPRINTK_FLAGS_TRACE) { + if (desc->flags & _DPRINTK_FLAGS_TRACE) { va_list args; va_start(args, fmt); - ddebug_trace(fmt, args); + ddebug_trace(desc, dev, fmt, args); va_end(args); } - if (flags & _DPRINTK_FLAGS_PRINTK) { + if (desc->flags & _DPRINTK_FLAGS_PRINTK) { va_list args; va_start(args, fmt); @@ -966,7 +974,7 @@ void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) vaf.fmt = fmt; vaf.va = &args; - ddebug_printk(descriptor->flags, KERN_DEBUG "%s%pV", + ddebug_printk(descriptor, KERN_DEBUG "%s%pV", dynamic_emit_prefix(descriptor, buf), &vaf); va_end(args); @@ -977,7 +985,6 @@ void __dynamic_dev_dbg(struct _ddebug *descriptor, const struct device *dev, const char *fmt, ...) { struct va_format vaf; - unsigned int flags; va_list args; BUG_ON(!descriptor); @@ -987,15 +994,14 @@ void __dynamic_dev_dbg(struct _ddebug *descriptor, vaf.fmt = fmt; vaf.va = &args; - flags = descriptor->flags; if (!dev) { - ddebug_printk(flags, KERN_DEBUG "(NULL device *): %pV", - &vaf); + ddebug_printk(descriptor, KERN_DEBUG "(NULL device *): %pV", + &vaf); } else { char buf[PREFIX_SIZE] = ""; - ddebug_dev_printk(flags, dev, "%s%s %s: %pV", + ddebug_dev_printk(descriptor, dev, "%s%s %s: %pV", dynamic_emit_prefix(descriptor, buf), dev_driver_string(dev), dev_name(dev), &vaf); @@ -1011,7 +1017,6 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, const struct net_device *dev, const char *fmt, ...) { struct va_format vaf; - unsigned int flags; va_list args; BUG_ON(!descriptor); @@ -1021,24 +1026,22 @@ void __dynamic_netdev_dbg(struct _ddebug *descriptor, vaf.fmt = fmt; vaf.va = &args; - flags = descriptor->flags; if (dev && dev->dev.parent) { char buf[PREFIX_SIZE] = ""; - ddebug_dev_printk(flags, dev->dev.parent, - "%s%s %s %s%s: %pV", - dynamic_emit_prefix(descriptor, buf), - dev_driver_string(dev->dev.parent), - dev_name(dev->dev.parent), - netdev_name(dev), netdev_reg_state(dev), - &vaf); + ddebug_dev_printk(descriptor, dev->dev.parent, + "%s%s %s %s%s: %pV", + dynamic_emit_prefix(descriptor, buf), + dev_driver_string(dev->dev.parent), + dev_name(dev->dev.parent), + netdev_name(dev), netdev_reg_state(dev), + &vaf); } else if (dev) { - ddebug_printk(flags, KERN_DEBUG "%s%s: %pV", - netdev_name(dev), netdev_reg_state(dev), &vaf); + ddebug_dev_printk(descriptor, &dev->dev, KERN_DEBUG "%s%s: %pV", + netdev_name(dev), netdev_reg_state(dev), &vaf); } else { - ddebug_printk(flags, KERN_DEBUG "(NULL net_device): %pV", - &vaf); + ddebug_printk(descriptor, KERN_DEBUG "(NULL net_device): %pV", &vaf); } va_end(args); @@ -1054,18 +1057,16 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, { struct va_format vaf; va_list args; - unsigned int flags; va_start(args, fmt); vaf.fmt = fmt; vaf.va = &args; - flags = descriptor->flags; if (ibdev && ibdev->dev.parent) { char buf[PREFIX_SIZE] = ""; - ddebug_dev_printk(flags, ibdev->dev.parent, + ddebug_dev_printk(descriptor, ibdev->dev.parent, "%s%s %s %s: %pV", dynamic_emit_prefix(descriptor, buf), dev_driver_string(ibdev->dev.parent), @@ -1073,10 +1074,10 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, dev_name(&ibdev->dev), &vaf); } else if (ibdev) { - ddebug_printk(flags, KERN_DEBUG "%s: %pV", - dev_name(&ibdev->dev), &vaf); + ddebug_dev_printk(descriptor, &ibdev->dev, KERN_DEBUG "%s: %pV", + dev_name(&ibdev->dev), &vaf); } else { - ddebug_printk(flags, KERN_DEBUG "(NULL ip_device): %pV", &vaf); + ddebug_printk(descriptor, KERN_DEBUG "(NULL ip_device): %pV", &vaf); } va_end(args); From patchwork Sat Feb 10 23:49:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199329 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1700575dyd; Sat, 10 Feb 2024 15:52:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IEtRMjEzjw01GxeSujM3nyy1s0y0wCCtABiOfl//JAGfsbIJ/j6KURSLBnBt8bVOeIBtvFP X-Received: by 2002:a05:6358:7303:b0:176:805d:4f1e with SMTP id d3-20020a056358730300b00176805d4f1emr5460623rwg.12.1707609128160; Sat, 10 Feb 2024 15:52:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609128; cv=pass; d=google.com; s=arc-20160816; b=C6tosW93OJIYahOc+irSkcQILrfa6UN7CQKV6eCtcIWbQSk5yQgk2VxFnifoSxYVF4 NJtgws9tu2gl5O4iKbsYdiw+bXQC2xV/jLYqYymPZU2S9oe3z0Je57jG9bwtH68RowHE w4cAFNhdIGxVRVMwErSM0akGAGMkOiCwTGjHlvcG7jVQ08e9d9tAjLyF3bHIzQLWwTSh YMbsgdGc1UBaDUTSq4jz8N10qnfgenum921GtDsjKm0BUhombuwV29YV3trw8ww4BsMm gDALaOx0Buvoiab16fbdlImuYdsroDxYnPN05/9OoZHE7chtrYlkfUqKd+KLWi1b1ilg BlWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=mJESVK7kHt1+7K3a2iTQplxRuP50hVTmiKkfD52o08Q=; fh=5HWISSTTRUm3AP/VLqYGMr62q7HvbZEebRSUnvInYfE=; b=g+PdfaZuk/H5roRaPxRCe5ony3ZRs/e19rd/X4AoJS4HvGFvq061h22iriWOrsw3+W EXhp1O4c4FSOHGTmF29wASzhBNuWSzx8fi3k748pz2NdeKODG+4H1Ss4AtsKe9WIP23x xvpb4B9Rw8CbpXxOeUI18Y9hQDSdIE7rHjuTZWYJI6yKOLsi/n9MU9Onx3S8masJNLko 3ZDE3UdVHsWz2BmEg4CdiECfyOeLkkLbl20inywQ5UedLpf9LYOPn4bWrnHX3LgNN1qr Qk8fiO+EsbV0okz7CSG5GquzaEqjGOzbUmT2zEvPoVAXjN7d/0qxXkScm2dRMlfQNUTw 4o3g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Y4WEghAA; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60588-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60588-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCXgAYBdWRkF1VXeqdh9QoOe6LopErsGGxMwC06bQcW0Bilq1ZF5OrC4eRus5VrBBDPsyg50Fx59171JtePCvEOkPVk0cQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id me13-20020a17090b17cd00b00297185aa548si1724937pjb.11.2024.02.10.15.52.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:52:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60588-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Y4WEghAA; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60588-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60588-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 2DF2AB22C20 for ; Sat, 10 Feb 2024 23:52:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D971C605DB; Sat, 10 Feb 2024 23:50:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Y4WEghAA" Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (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 C5134604BA for ; Sat, 10 Feb 2024 23:50:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609041; cv=none; b=LSKijHIvSL9sRHxA3yRfCHVeVgKOOnXrDnROU2QSzMFo1qzDFJjLWFi8qz1UFI6hE7iCLqBmFZFauczpUjoxdJBLyiVyTknHOSCdSftTM71pGLpSZKik5rM2yT4w2Zjdel2ESLiqc7k/bc+MthUmKJha5nZ0DRTnOcH8KOpdEa4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609041; c=relaxed/simple; bh=CEm2u5oLoANuCFcHRqanlvBhrRP8jePFysyGpg9GOkE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HAN72GXPh8p4wXJO/tCId7gaUUSkdDXY5m1+yEETYsZ0+vhIwbji5xmDIEEqwXG1GsyhAJq7mC5mvoDdU70JN63Ac+SoG/+M+Cb2e0ECH42jr5enc6xhFCpHNiko3OQ7ancyYGVBuY4L89WUajxj4/OTcgLBGdYF4Ax1DAD2cmY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=Y4WEghAA; arc=none smtp.client-ip=209.85.208.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2cf206e4d56so27700721fa.3 for ; Sat, 10 Feb 2024 15:50:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609038; x=1708213838; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mJESVK7kHt1+7K3a2iTQplxRuP50hVTmiKkfD52o08Q=; b=Y4WEghAAak9V/nq8V6yn3g7oTyKN08K8z0dIfkXqNLLvBcvGFXfcT/sj/sNZPEfXLM XB++GTxyxfozCOZDd/c015p6Vd2RnGxpP8iIleU7PRsZVDuMOxjtjYNP0TVL61GFwc9F 2szYnYg353BjDU/jlik+iFQCO/Qmh+t0IGbp8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609038; x=1708213838; 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=mJESVK7kHt1+7K3a2iTQplxRuP50hVTmiKkfD52o08Q=; b=sYO8YYmm5iP7xjJb62eDdgNXsrwGAzlTxWQSIAmkQLfqy7140iP30jg2Db4Uz3N7F2 38pEc80t24wlI272AF7J91T5lzQZHEjQ9o/mqsRIaTz4+0wvnzlDy6S/csCpTOmx9IaR 4Q8aBrcWAnTQnd6vUXNys747qsuhgX8vpZOyMkp8idgo9PDO26dX+LD7V7L+3A8ub4nv ptwtp9sye0FHly7Yak9U1H/ZIY8NfuaPIYjtm4AN7FVYRgRV87y0pwzwXv9PFrlDsD7t rCJ5kSVI9naHmLi3nTbqHZLjTDOykTrwoBoIUE2v6nfT7Eq4JHRdGni76PeWNQRf2t0C SaGA== X-Gm-Message-State: AOJu0YzayMRy9glTYTFXLHQ91pOZqdLfElp/U3vQ6mtVnQs4nonyamnj 9GRPsi5ZC3HpBxbJkv3VX7ewNCtXqle2PLf38XHkZ3SSEofdd5j1Tojb+w0f X-Received: by 2002:a19:5209:0:b0:511:79ce:f325 with SMTP id m9-20020a195209000000b0051179cef325mr1576643lfb.31.1707609037846; Sat, 10 Feb 2024 15:50:37 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUnU0vsLxtkUbNcbT7Arujl/3sW/7tv/nm0MPyXW+L7RPEIemfAuiboHfYHpEovp6knESiGxQUDU7oHl8LWX9pfg+l7apXoAhYfShXHF8Css4OirBKnTd45MkuwevTRvvYnhagwTL352TxZSsevQINxiKhl/RiYLxg3EKRfZ7hPhvPBmccMe4UaF9Bbfdqk08mZAooteiCTjxLnBAF+WEq1XObEZnP3IUxdxOpfIifIz3Pem0rup4v8FtNPxQEOqeaoLIYfR3ikAJP9osWhkzcvtqyWEq/MqwA3rcbP8VA7McIrEzPdC7jfnVK72jCYbgETxgAoC+h3RMDNj9lq8HyDduu0RwMvf58pqmBKHrWgoIvg7FbWEaXvfvB3OdwnJxVo4LlT7m1+p0PFFE7kKrfV0of7lofCYt5a84Otgo7Rq+vVFgNxVz1KBCDWWzzlO32YYmS9GFZgkA5G0MNsEd9AqLTXnuZgbpUal3ZcchxxOvqlkWk5Xg9akEHpNOvm+wHu05y95HpNsuX3NfHR9k4K+BtTlkrmneNQiJH5oKfR39i0WDGK6ufjp3rVZW+G1raw5f79vk/39tiYr7gSaiWsmkvlKlMwJ+QmHuP9nV5e/2fA5w== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:37 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 05/39] tracefs: add __get_str_strip_nl Date: Sun, 11 Feb 2024 00:49:35 +0100 Message-ID: <20240210235009.2405808-6-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790557949017994644 X-GMAIL-MSGID: 1790557949017994644 From: Jim Cromie This variant of __get_str() removes the trailing newline. It is for use by printk/debug-ish events which already have a trailing newline. It is here to support [1] which taught dyndbg to send pr_debug() msgs to tracefs, via -T flag. It "reused" the include/trace/events/printk.h console event, which does the following: TP_fast_assign( /* * Each trace entry is printed in a new line. * If the msg finishes with '\n', cut it off * to avoid blank lines in the trace. */ if (len > 0 && (msg[len-1] == '\n')) len -= 1; memcpy(__get_str(s), msg, len); __get_str(s)[len] = 0; ), We can avoid trimming the last \n during write into the tracebuf, by instead stripping it when reading the tracebuf. So do that. [1] https://lore.kernel.org/lkml/20200825153338.17061-1-vincent.whitchurch@axis.com Cc: Cc: Vincent Whitchurch Cc: Cc: Cc: Cc: Cc: Simon Ser Cc: Sean Paul Signed-off-by: Jim Cromie Co-developed-by: Łukasz Bartosik Signed-off-by: Łukasz Bartosik --- include/trace/stages/stage3_trace_output.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/trace/stages/stage3_trace_output.h b/include/trace/stages/stage3_trace_output.h index c1fb1355d309..283533a17e62 100644 --- a/include/trace/stages/stage3_trace_output.h +++ b/include/trace/stages/stage3_trace_output.h @@ -19,6 +19,19 @@ #undef __get_str #define __get_str(field) ((char *)__get_dynamic_array(field)) +#undef __get_str_strip_nl +#define __get_str_strip_nl(field) \ + ({ \ + char *s = trace_seq_buffer_ptr(p); \ + size_t len; \ + trace_seq_printf(p, "%s", __get_str(field)); \ + trace_seq_putc(p, '\0'); \ + len = strlen(s); \ + if (len && s[len-1] == '\n') \ + s[len-1] = '\0'; \ + s; \ + }) + #undef __get_rel_dynamic_array #define __get_rel_dynamic_array(field) \ ((void *)__entry + \ From patchwork Sat Feb 10 23:49:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199330 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1700638dyd; Sat, 10 Feb 2024 15:52:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXDxevyyDXoi3xqcmWoHp5kHBXFDCHWLrGAvE5BtDjIlZuPxumIKl+CgNd0VRDBYmIj0x5zciquT6kwdVScV8DlQJahmg== X-Google-Smtp-Source: AGHT+IGrH8Ox/HGT7zxow6bWivYfTGbregIdk2Y0kECO2Ig8YVryPr9T8ShIJc4FWJlYuWW73YuB X-Received: by 2002:ae9:e30d:0:b0:785:c28b:d86c with SMTP id v13-20020ae9e30d000000b00785c28bd86cmr2964868qkf.66.1707609143067; Sat, 10 Feb 2024 15:52:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609143; cv=pass; d=google.com; s=arc-20160816; b=L5L++xqihtwGrCXs1dqP8jpW6MHWP+Ud/zoOw+8Nx1A2jqk3t+1ugNqYKRDHV8RL1B LAZX0Ku2hb8wAByURQOsZVLT3Fa5DN/D352bOLJyX9Ftv9+Y35yxQxbLgK0E6ynDhgnq O1/tDBfq0xTbs9AsBzcQf9kgWzXiCgD+WJguXlrQx0O34jsuWlBLZquzV9L+yw7H9WLr /cmW0G4iAMcgCwoc8ODHy87BxOYEajcNSgvfXBDXONhGpNAkF+OGl+e0Ch3qbxEB83kW 7WH6E7m8oOtgbtGkA+DvlLWBH/7EhlW6xbBlsd1Dmoh71UWUWvLlyCUnnFKMlte4MB+2 xjdQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=x00D6P9yOyMiqD2q0GliLWT+bL7NY08ZLZWAqgBxEXY=; fh=gjCU2zwcHunl4tLk63pYjYbzQSp/h/fibU8jDf0sL68=; b=Pw2iaAjDv7q9Q+aptF7PUE4VFUGPzw0d8uaj3qWtM/YBfyDNN5KgvxLHLtodop/Ewu M3vPFbSq28sNz1aTU9Psmb/H6cVXBFMKApqKxXML8qs10FJyD21wTLhDxI9nVGHCAS/E oruSltN9X+lvakDBqvXKHjVdZGFOWSfrG/QZ0roF0EgY3KRj6Zt33oSGAGVZaPET2H7W GxZCgXqnEDhWQ3cjzKD4UCC7gqdxPEcKaptN3ovxES5eXt9Bp4/Wza0te1BNJ35yt9uu nyed3xiP5Fcr7/4aCq+f65g+nf2ucQvMkZxyCA0PwVJzDhmrP1m+wP7jOgaWSrwH9/Te 2lig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bsh7dshm; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60589-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60589-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCUVyC7bPga8pPL0fnBbtup2VqMNnGtEFrenoaGE6ap5zgF11ky9M3BEJ1n04A+Tg52trcTZ1QBjNniGvK9/6+xQ4WenQw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id wa6-20020a05620a4d0600b007838dfec439si2816840qkn.297.2024.02.10.15.52.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:52:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60589-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bsh7dshm; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60589-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60589-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C91041C2150D for ; Sat, 10 Feb 2024 23:52:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7612B60882; Sat, 10 Feb 2024 23:50:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="bsh7dshm" Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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 4E3A2604CF for ; Sat, 10 Feb 2024 23:50:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609043; cv=none; b=GdjCXyRoaRb1vGoIiPqtvVihtX7rjgelrwmCCU9d0+cvQFmA7ytUDy/nN4ShY43L0jcrR2h/NmHtIvQSpiwf2ipKGOIDmGQWLnghiVm7MbnOimZaQ6g5GxD4zjjFMA9eHW734tVdqkxhVWa8Xu4erb16NWF0d4rS+wYYV736IeA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609043; c=relaxed/simple; bh=bAccrTv3hmSTu7zPzthT8nvQoJH35PHedf4O6GRUW3I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SSMDGoadZs8delhvMPz/avxJa38vUERmdewpEqiKDMdBahB158CZ4wPh9i1/kUSI0fKdRmIWki0SRb/Nh0XWhjewaR2tiebNyI2MBviDRjh3p8BHke6a7dVadhty6m/hJiHPCQYnaDZ0vu4jOMufF6YNm6h29sZ7k+otC1bzSnk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=bsh7dshm; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-5114b2b3b73so2506813e87.0 for ; Sat, 10 Feb 2024 15:50:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609039; x=1708213839; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=x00D6P9yOyMiqD2q0GliLWT+bL7NY08ZLZWAqgBxEXY=; b=bsh7dshm4K0Nbe5N2eBL91tg68F66TZi0f/LIzUQjQN5r8FOXqtqnm2hz4MzO3u7V8 PQncXmd2Po1xZkTYiMqsq4/4HoNtz64ufAV91DQdC7xJN2+m3e3ijcpYcDirjEK67Jw4 AfMBofNWutpT103dFQ+LJ0dHpKpPWn0RiBgW8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609039; x=1708213839; 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=x00D6P9yOyMiqD2q0GliLWT+bL7NY08ZLZWAqgBxEXY=; b=rU2hhRjo24R8wjI4pguTQpq4g+RaGpzLOlwKKzI1ZqsJH7t/31qiyt0dQlYoDP5ZdH BEfjEeQXug+VyLf6p2OxTPjEB5aq20U2hBCuTeBvM0Tcg9doHQYQz3ElycJwb9jV1ELV 4aJjbGwZ1RmEBbBElIm9nxiFj1FkGKTGjEoLQVUF0+COGaRSg/wIPMnps8dUxt7NRdj4 ShH+RBT5DHRvwkVrV1aUM4LVoprrbZX+yOc2xlT+2uWsUMnviFUGURd5MInSCmorcXcH 8446eKJ22jw5v0iY39Mz8KTsWEl+aap6osHBM/PMQbXASX8bIQ/lNi4ZlkEHIQtFljcn wNQw== X-Forwarded-Encrypted: i=1; AJvYcCWdTQW3atXGBD6j0BFfO7FVR0Zp+jru1DODSEJ7QqSDQww0wQhwWiGezjVicOb7pXLI69gxurJ2aZatIQt/rhuO0TTWdQ70Hl9Aio13 X-Gm-Message-State: AOJu0Yw9aBUEnvE6+cWZwEe8BmLLD3BQ5JHIzxW47G+Ysw32aTz5uDQp vvCpu6DCSyiUcRkMbsAhJ9jJnCkQphEe+xIX9QcfziXcXK7Z+rOribIgvR56 X-Received: by 2002:a05:6512:31d4:b0:510:ee2c:e9c4 with SMTP id j20-20020a05651231d400b00510ee2ce9c4mr2815993lfe.17.1707609039442; Sat, 10 Feb 2024 15:50:39 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV7ySymF3+AZV/6j1K9+VJqK5qT7OPdyNN28fJe2JQqW3xVM2SBYur4wQol+rUwrbeum1oQKxJE2gW7XvXM4MagBlhPedO9CFSwpcSYyFs7LPcPLIxgCe0KpYo234EU1Is2CVFVPkWWkUMYMj/A2MR+etJNsp9MBoXIT7cIs1xYIwJY/Ovxgb/0YVWn9QmJG1iUGqNecxny1WI9D4kxIgNfpIEZ9aeT8SSWYUrj5NrD2yAh6m9U1kIVuhEnZ1IVk/hR5my+nmOe3sVestZnkkup5wU/gZvWFEylKK/FALNsvUtjdiqJc4m+rGadQZ3kivXiDFiXPf1mJWaoNR1AaYWtzMvCOYOYsVDr3JeKFIjzfUSeNURPieCatlRwgbAJQuG6ampB4tYgnwwf1pYtW5s+GyGiC//jfNPXE3RFc4md5VUSuG0VEauzE5/+pCIafiAnhaTKJF1QQtzyKgTHSQPHy00nWD4mKdj055Mq5GWL7sHRLvMRJfRQkf3z6yRoCBAGGdHomteoQ/yY2gcaHqugcMgnTB2Dx+LxDfdZRDTzzxXXxq1rmbADKpATKYjOfHga1gUxQx2qEeZEG32hYsrp91dKbOkW2peqBd/Z3T7buu4Sbg== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:39 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 06/39] dyndbg: use __get_str_strip_nl in prdbg and devdbg Date: Sun, 11 Feb 2024 00:49:36 +0100 Message-ID: <20240210235009.2405808-7-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790557965016161703 X-GMAIL-MSGID: 1790557965016161703 From: Jim Cromie Recently added dyndbg events: prdbg, devdbg have code to strip the trailing newline, if it's there. Instead of removing the newline in TP_fast_assign use __get_str_strip_nl macro in TP_printk. Advantage of such an approach is that the removal is done on the read side (slow path). The change removes also passing of debug message length to prdbg and devdbg events. This use is slightly premature/overkill, since some pr_debugs do not have the expected trailing newline. While those lacks are arguably bugs, this doesn't fix them. Signed-off-by: Jim Cromie Co-developed-by: Łukasz Bartosik Signed-off-by: Łukasz Bartosik --- include/trace/events/dyndbg.h | 27 +++++++++------------------ lib/dynamic_debug.c | 7 +++---- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/include/trace/events/dyndbg.h b/include/trace/events/dyndbg.h index 647c30206a7d..ffd21480cd9d 100644 --- a/include/trace/events/dyndbg.h +++ b/include/trace/events/dyndbg.h @@ -15,46 +15,37 @@ DECLARE_EVENT_CLASS(dyndbg_template, TP_PROTO(const struct _ddebug *desc, const struct device *dev, - const char *msg, size_t len), + const char *msg), - TP_ARGS(desc, dev, msg, len), + TP_ARGS(desc, dev, msg), TP_STRUCT__entry( - __dynamic_array(char, s, len+1) + __string(s, msg) ), TP_fast_assign( - /* - * Each trace entry is printed in a new line. - * If the msg finishes with '\n', cut it off - * to avoid blank lines in the trace. - */ - if (len > 0 && (msg[len-1] == '\n')) - len -= 1; - - memcpy(__get_str(s), msg, len); - __get_str(s)[len] = 0; + __assign_str(s, msg); ), - TP_printk("%s", __get_str(s)) + TP_printk("%s", __get_str_strip_nl(s)) ); /* captures pr_debug() callsites */ DEFINE_EVENT(dyndbg_template, prdbg, TP_PROTO(const struct _ddebug *desc, const struct device *dev, - const char *msg, size_t len), + const char *msg), - TP_ARGS(desc, dev, msg, len) + TP_ARGS(desc, dev, msg) ); /* captures dev_dbg() callsites */ DEFINE_EVENT(dyndbg_template, devdbg, TP_PROTO(const struct _ddebug *desc, const struct device *dev, - const char *msg, size_t len), + const char *msg), - TP_ARGS(desc, dev, msg, len) + TP_ARGS(desc, dev, msg) ); #endif /* _TRACE_DYNDBG_H */ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index fcc7c5631b53..9682277f3909 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -886,7 +886,6 @@ static void ddebug_trace(struct _ddebug *desc, const struct device *dev, { struct ddebug_trace_buf *buf; int bufidx; - int len; preempt_disable_notrace(); @@ -900,12 +899,12 @@ static void ddebug_trace(struct _ddebug *desc, const struct device *dev, buf = this_cpu_ptr(ddebug_trace_bufs.bufs) + bufidx; - len = vscnprintf(buf->buf, sizeof(buf->buf), fmt, args); + vscnprintf(buf->buf, sizeof(buf->buf), fmt, args); if (!dev) - trace_prdbg(desc, NULL, buf->buf, len); + trace_prdbg(desc, NULL, buf->buf); else - trace_devdbg(desc, dev, buf->buf, len); + trace_devdbg(desc, dev, buf->buf); out: /* As above. */ From patchwork Sat Feb 10 23:49:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199331 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1700679dyd; Sat, 10 Feb 2024 15:52:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvj7aXxXgDQE/ExWTn+agUBs0vRloG1M9zvyrXtPX7OICzxqkdsv+pd+D3fiLF/stFJxVj X-Received: by 2002:a05:6358:8421:b0:178:68c4:5c18 with SMTP id b33-20020a056358842100b0017868c45c18mr5520547rwk.10.1707609152182; Sat, 10 Feb 2024 15:52:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609152; cv=pass; d=google.com; s=arc-20160816; b=aH+iNrynDu2+JpUzFEpaYJ7w+w3yVwhAx+9xWAD4FjW6g2LoSLwK+ZRgM3IJG7JFcm P00HRJh5NBNjMoPPyg3PGUx8Dn/WaYKM/W3KlX7jTPOp0QDbB37ebf+aqWJ2c5M9CPss SLM3LEB6QlxG3SgiUKd+XP6yo7Grm7hDJCSBEo6W0QqcH8Ue+33NED0l768oOr0jq/+j zdle5NAFaqkbTVOUS/K3nWhEEGs5bN/L0AGCo/lWogVwMrS0Bo8jz9Aie1fX5z+rCpop gDv9IAXSjePuwgjupEzyEmw9QA3qI3na9omFL2QhcCZYujTwephZkvErO1+YbMRE2U3o TNDw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=wHpG276MmElKepXhunEl7bkyaSWvxSiZXup8NnNdSuc=; fh=2Z+WPToD2mU5inIEuChB1KKbk9xuOfpUBKWIeBM20nw=; b=wU6l3HJW/i3wjRo/kOQjpbkM0O1/LTvSVHgEIS0yjPTa0Bla9RUfc/BCILRr+oSvXW UQkE3ADA9HZfodGL3vPGLvGp3edfkrNHhRvDryat39T8NcTmKXp/5n+EcH/7A2mvOJmB 54AFZ/Lq84+DgPfER2ewmVRvLt5eUVD2I5DbuoflGCqhLoGo8VjkE8iSsHEueuKeW0s0 /L040w8qXe9eRT8Eib3TyNboRLiuxzJUDiEfqc75AbENvqR3SpW7fD8oy75sLbk/pRcz iy1LnzPZBoYm/VlkxF+9NloXdJPQL4cI2kPoY6FLIAJi5VG9sg2zXCYeIdH2NN12uYNq i6gg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XXrkXuw5; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60590-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60590-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCX+Q5Su0NfV1IdDfZYJAaWdnjWPBTweEf21UMbbcSNVheATVvQM8MO5MatRqWY9AAjxix7mkFo2EjHWl4t26NgzeIDkEg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u24-20020a17090ae01800b00290c6b287a6si3933007pjy.56.2024.02.10.15.52.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:52:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60590-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XXrkXuw5; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60590-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60590-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E7B07283C92 for ; Sat, 10 Feb 2024 23:52:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 90B616089A; Sat, 10 Feb 2024 23:50:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="XXrkXuw5" Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (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 E0BF5605AB for ; Sat, 10 Feb 2024 23:50:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609044; cv=none; b=BnN7rdJAZAV4cEm8gZs173LEg7Qb8QqMbzce4TDKIbNKkkCJTDGZchTyXz+q9Ceq+wAxSAjKvznEUJ+3ZMwHyz0aSbaW9PZFGeVsYq6l4CYndtAYP4TIro3egzEKFFDcWOcFuIggYE9QgpejUxcuigJ6Flj2j0v7eiXr9Lq1HuI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609044; c=relaxed/simple; bh=PKIPCdVpIuUn/00YwCRKhljNgiSyRdjJyytN1tq9BaQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W6Fx+IE6vNO5YvRXQqN9b0tJg0afyK1LhwMloK4qHRRQbcU88fotetBbSJZIh8VdZkuaKT/yCUdMWoe8AGRwoho1bB/sYs74vs2Han3QPohNniWWz5tJR8wVEhkY0kBTyut88xK8KIwyaegcsX8iIpGrIm7YxEf6h/pyTW2B0YY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=XXrkXuw5; arc=none smtp.client-ip=209.85.167.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-5101cd91017so2348452e87.2 for ; Sat, 10 Feb 2024 15:50:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609041; x=1708213841; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wHpG276MmElKepXhunEl7bkyaSWvxSiZXup8NnNdSuc=; b=XXrkXuw5amxDB1i/GGDQsUqAAlmsPklnIIoxdJYS3v2b7eottwGsfgsRPdpq3g/Hgn UGJ78SKGREnDpwObfm5yCjp5AV32mgAo2xtSRAiV2b038MnEjasuovWUdrBGFmVFGC+5 teN4oCZ1IWrulbn2xgVLC1dI6WCgiVlTXTQuA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609041; x=1708213841; 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=wHpG276MmElKepXhunEl7bkyaSWvxSiZXup8NnNdSuc=; b=CPnCPTbzodaacQzi26ZcUOi4VSBrOieXuOdqElFjYe6+vM7jZKYRmjVYNLFUf1MFi3 7FeIn+vyXhg4Cgzj2Y8I5zRDacxCjrMhQkG1LrBIU0cyNoVlDyDfXfeTHmRYCkh4CMZp DVHffz4BHjHjaFiEoRBXwLtJ9vVKMojBvtytW9bRc6EQwFE/KDETltLKolgiVb3udhfZ O+uuaAyJ0FyF6yqFovwLhmokMbYRVVWxn7923AumhDW+h/pZBJ0vdbKHOy353c/tRj9h SZ8w3D65XrqKFla0aJRygwd3MNPMJTEgMB2VhaWgGIATZvBuw70fjTBWf20klJ0OKlr7 EsLg== X-Gm-Message-State: AOJu0YyjFGc7/F93VBOGiCmVAwncQYjcJB2HVSFA+nwzrJ8l34DoSBs6 rmRrgS4Q16tIE+znYpp8lNJGRQviX2VMvndFN4mV1CAksmiSFStS1qM+Bf+S X-Received: by 2002:a05:6512:3246:b0:511:882e:aa2f with SMTP id c6-20020a056512324600b00511882eaa2fmr249269lfr.50.1707609041040; Sat, 10 Feb 2024 15:50:41 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVXzcfxvl53b0KUr1AgxRUitK73QLnppDlhHkKvnYnab4XlZzdLWCQtiWNZTYX4A42GkbmGlrcniR/8P9q9qsEfn5rnazlCjGxZ/7GZ12O3O7hHnIetYy+tHDPpZWSkRdAF5LGaz9p1aSZi1NwR6pRUq8VdmvotG8GZ+nFvPdc7wHduqJbYT7MpMjfz2E4YKzn6X/JFh9qgWcm/tO2BQYHs7QM+9nsK0KxXA0BTFqZit1tt2d0Ucftula3JtEJPHSXiffMXkeAEId7sF6lSGVsHXSEOE5XcWFnnwNo3CIpLB1CiLs0wh79FheTZivU2sASNqFuDMzszhOH2rpWy2aMx6fDsmIN68V+MLmEOcfQzAqBUegcMlfV0NEFW/44q9cqHla+NQuJZUbi/6dHGkSqSlKIhkoVjfhIZeNoF8EZ4ALwrOR9kCjxXMrTyG5D6BA+59BZXkaYVzqzIHFlHupE3DCLtEcs8Cttack5ZOZpHdgEg91o79IUTbfMHMYjG+gl1uXliMCJAcsevu4KzWWKJ+U36DbxTZE9kWRnYZC8FuRWU8Yf6oOZU/vGU8pVxS5FQsBKTDr1mgLhGyiWyb1JjeTkakLsk2B9EJX7djmTZFOY50Q== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:40 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 07/39] dyndbg: repack _ddebug structure Date: Sun, 11 Feb 2024 00:49:37 +0100 Message-ID: <20240210235009.2405808-8-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790557974174043216 X-GMAIL-MSGID: 1790557974174043216 From: Jim Cromie Move the JUMP_LABEL to the top of the struct, since they're both align(8) and this closes a pahole (unfortunately trading for padding, but still). Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 497130816e9c..b9237e4ecd1b 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -14,6 +14,12 @@ * the special section is treated as an array of these. */ struct _ddebug { +#ifdef CONFIG_JUMP_LABEL + union { + struct static_key_true dd_key_true; + struct static_key_false dd_key_false; + } key; +#endif /* * These fields are used to drive the user interface * for selecting and displaying debug callsites. @@ -53,12 +59,6 @@ struct _ddebug { #define _DPRINTK_FLAGS_DEFAULT 0 #endif unsigned int flags:8; -#ifdef CONFIG_JUMP_LABEL - union { - struct static_key_true dd_key_true; - struct static_key_false dd_key_false; - } key; -#endif } __attribute__((aligned(8))); enum class_map_type { From patchwork Sat Feb 10 23:49:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199332 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1700754dyd; Sat, 10 Feb 2024 15:52:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IFTT3isVDclFwemNcjB3tSOtkNJMf/Jll10I6QO0onHvV1Qg2CebAaJdecrBxnJ8z0lMagL X-Received: by 2002:a05:6808:2027:b0:3bf:cc0e:f6a6 with SMTP id q39-20020a056808202700b003bfcc0ef6a6mr3893150oiw.11.1707609174478; Sat, 10 Feb 2024 15:52:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609174; cv=pass; d=google.com; s=arc-20160816; b=07P6ZD64UmBwe/g1DKJcp5gTfogWGriRcYdOvRCrvJxr7HQJlsM3St8hJf59nK8kCK BLYaV5X8pngO6jwl0j2mPshRmGuDSYZV1zMQOEsExBMOp2wp6+OvB01MhEbSoXwO+74B zandlGQFd8jbSpVsCH4tAoHIF1Nb/qG6rrPFgIn3UfxgF4rWS/VYrPRIN8/S41wEYFd1 7stjknA6edVU595pzUvqrA2ZRg1Zb098BoGNRyiCw0BQ3YhuKT+ELEdWOyGfqXFw1ZO+ mWy6YPpMjroDJE96Zmtli4VTb/jHhmadC9AzJ3Gc39F/D+BleShZeZOrot1dDI600Msu y8lA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hSW8rXIgUpmvq2wb08IXdigJ9UWnCc/ryLuvI1HuFRg=; fh=1DNvA7bFSwzrLTiWmn7LvA35gwxbvjrUxFH8QEjZW94=; b=X/YlLNmK10XNbqXpuVExxUsOG2i4e28KFxlyGXH2uXMrYl7rDC0YgKFqxmc0peRYRo zkFUhmuXxb9zb6w2LjPbtvzbQrd6VDoRzVPALchZwcN4l34JyAo3ZwNQPz+OraZpUKrn ThP+icrhp+dHwZhjA9WvrZj7ZQNnDTAG0pE3HBQJfVEahzkEL+vXu9Obim1LW+gRe/2V QvCVSlrW7+jrid9UD3S/9fxlSOVJ1C7172WdzbZEcpj7sQPSRjtNtQWSp+TAMGSy0wjM OsDCZ+4UX2pISGTkq7sAcVrtrTu/FZ2VhWNNkJW6TZZACsTcbttS+piwK3IjIOVHBS6h NVmA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aylZEiq9; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60591-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60591-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCV/kRmsso2gYcUhomBncKo0wvs6EbtXqoVw0aCddjqnZuyquTNp2yqOfSVXssvHrXtg03VbaptLq/wSxM6Lk/NAmoV4CQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q17-20020a637511000000b005dc3c49442esi4018018pgc.732.2024.02.10.15.52.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:52:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60591-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aylZEiq9; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60591-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60591-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 39361283ACE for ; Sat, 10 Feb 2024 23:52:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA0B260BAE; Sat, 10 Feb 2024 23:50:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="aylZEiq9" Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) (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 8B807605D0 for ; Sat, 10 Feb 2024 23:50:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.68 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609046; cv=none; b=RHJ/V6RdMadeUBE5FfSVbln3iWgdBIYWpY/qHf3dIyi7m5A8DrKL8AZeENhVbuyvubl3MseiOs5hrgC5phHWwRcT0+7y4Co72vVB9CvlUCNNZFUyeNWwejjvwCFd5TfKeQ1Ui5+gIxbsS9NS+IPYazzqa+uXMBWBtfrHFC9OyW4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609046; c=relaxed/simple; bh=N7cA8bn8EjCVuVHuDU0PP9ju1v33Lwp1kuaVQzOCU4g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HGvPaKraZlkMy7ZYQnhflA8LqaiNerpdIQcA9hA4HupcryqL0DgGgJ7PXIqK0KKsW6LLVSFUIxScb9NUfOmq0q/H219dXMB1Jt48nR6ZkStD3tZGOhdfJGy3K5Vx4KfQjPoP6i6ZjKyXK2wFUHcmdZrPbCWR14MvKfjZmC+ona8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=aylZEiq9; arc=none smtp.client-ip=209.85.167.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f68.google.com with SMTP id 2adb3069b0e04-511570b2f49so2794220e87.1 for ; Sat, 10 Feb 2024 15:50:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609042; x=1708213842; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hSW8rXIgUpmvq2wb08IXdigJ9UWnCc/ryLuvI1HuFRg=; b=aylZEiq9E/qFEiR/eiO+ebTW0jVWymk8vKgiAgun+zEQoOIjRMrt75KKN5I6wECC3q JiAQPjX6RskCapxzw1YWEhNH0DRXepXvor/XoZkbw01FxmQ9aIo1IO2ecViUCxDe5SWX NMEXdnFwKf/zX86RXJbA3uL2COwNzMvWyRrX0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609042; x=1708213842; 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=hSW8rXIgUpmvq2wb08IXdigJ9UWnCc/ryLuvI1HuFRg=; b=Wm3QpOqHInywbNd+IWcRMfpeN/riFut1Ylze8l/I9flthXX2Meq0Zktj+WbUSsbXKZ 6oquioHdy4xMCK2N0MVkKwxxo7bbFXB5DMyXi5KZWfwyrtOX5f3TyiLwpAm7wzuljsK+ xJ1hjFKXtZi46BtGIc4nSdUESK3w+b7VG24MgjcqqrKUT8XwfpOFvbIMYH8ZfM0GFmHj 2mfoJ4htKOkiziP3iUPHJJilYoWQD44G3urGkQXgzao1MCVvf3ltAfftK8Fc13rQjR4S Bf4xHUBMZfldVIzOFUvR6jwyPC/J29ngkZDdqQOGgGo/RwJDI6y7cMNJfulJGijE0BjY YjEg== X-Gm-Message-State: AOJu0YxRP+YvtNTVNl0yekGTH5WggwXDYOXnpnmfo2DYgpFlz+H9+6FO aWP+T5i28SpyC0eMSyKbZVnwRMnydcdIdh8/FS730007J5B4s7x4fLRdyV6W X-Received: by 2002:a05:6512:3e28:b0:511:737d:661a with SMTP id i40-20020a0565123e2800b00511737d661amr1974636lfv.28.1707609042741; Sat, 10 Feb 2024 15:50:42 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUEL6IuQVTDfgEq8cmA2Dm+DQ6N5Xl8H019iNbYo2XCU4T/t5EfPLhwRWbW0eIkvQ/fsdmfg52wQAqYjGeg65ItFFZhgyU1UjLS4as++Up2B0G7HcTk7j3xrhSddP0r35tomWTt+fYGG6/Num6QlOzOOF5qusTEhCvux9Yx77gdWSvOyYHzC1TpNVnL6ZUOwDHyDC9kjH3PyGBKcDdf/RTnqXWU9TfQ7zEU4KAplqLorHAbfnozeZcDSQZic6SfHbwcEiY9EpesTToE4jn65n03Q4mhnmNORUMpif8FEGqi3TXjn6uvxYtT2/7v/IblP4iaE8lPKMYZVUp2W9Sret0nyXH1DL0ibb7E5Jd/CL7jhFvvA/IMyd6D9K6l9Ro5oCoL0r7YDSWyH3G1bPQY1R3iCz/pZs78c6vRZFUXFnSs6k5FzuQYXp94gN5brY/WhfwHNcKLn+i/q7lSzbDdvk582EaQMdh0VrEy+y5C/a4qKFiwYzh0vCE83OKSbJJjO8q7iGbH5sTHriqVNZRu6lQZbMnEyjOxnbAq1i6il6+PyMSBLSICfGVhl5i3ZOU/M3UBqjPq7/NnVR7dtOifd04CavmWPDg7XfVqKxV5PvqhdOLNMQ== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:42 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 08/39] dyndbg: move flags field to a new structure Date: Sun, 11 Feb 2024 00:49:38 +0100 Message-ID: <20240210235009.2405808-9-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790557997435839103 X-GMAIL-MSGID: 1790557997435839103 Add a new structure ctrl and place it in 4 padding bytes of _ddebug struct. Move flags field to the ctrl struct and create setter and getter for the flags field. Add unused fields to explicitly emphasise size of each bitfield. This step prepares for addition of a trace_dst field. Layout of _ddebug struct after addition of ctrl is: struct _ddebug { union { struct static_key_true dd_key_true; /* 0 16 */ struct static_key_false dd_key_false; /* 0 16 */ } key; /* 0 16 */ const char * modname; /* 16 8 */ const char * function; /* 24 8 */ const char * filename; /* 32 8 */ const char * format; /* 40 8 */ unsigned int lineno:18; /* 48: 0 4 */ unsigned int class_id:6; /* 48:18 4 */ unsigned int unused:8; /* 48:24 4 */ struct dd_ctrl ctrl; /* 52 4 */ /* size: 56, cachelines: 1, members: 9 */ /* last cacheline: 56 bytes */ } __attribute__((__aligned__(8))); Signed-off-by: Łukasz Bartosik --- include/linux/dynamic_debug.h | 13 +++++++---- lib/dynamic_debug.c | 44 ++++++++++++++++++++++------------- 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index b9237e4ecd1b..a551b2967cb8 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -32,6 +32,8 @@ struct _ddebug { #define CLS_BITS 6 unsigned int class_id:CLS_BITS; #define _DPRINTK_CLASS_DFLT ((1 << CLS_BITS) - 1) + unsigned int unused:8; + /* * The flags field controls the behaviour at the callsite. * The bits here are changed dynamically when the user @@ -58,7 +60,10 @@ struct _ddebug { #else #define _DPRINTK_FLAGS_DEFAULT 0 #endif - unsigned int flags:8; + struct { + unsigned int flags:8; + unsigned unused:24; + } ctrl; } __attribute__((aligned(8))); enum class_map_type { @@ -171,7 +176,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, .filename = __FILE__, \ .format = (fmt), \ .lineno = __LINE__, \ - .flags = _DPRINTK_FLAGS_DEFAULT, \ + .ctrl = { .flags = _DPRINTK_FLAGS_DEFAULT }, \ .class_id = cls, \ _DPRINTK_KEY_INIT \ }; \ @@ -202,10 +207,10 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, #ifdef DEBUG #define DYNAMIC_DEBUG_BRANCH(descriptor) \ - likely(descriptor.flags & _DPRINTK_FLAGS_ENABLED) + likely(descriptor.ctrl.flags & _DPRINTK_FLAGS_ENABLED) #else #define DYNAMIC_DEBUG_BRANCH(descriptor) \ - unlikely(descriptor.flags & _DPRINTK_FLAGS_ENABLED) + unlikely(descriptor.ctrl.flags & _DPRINTK_FLAGS_ENABLED) #endif #endif /* CONFIG_JUMP_LABEL */ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 9682277f3909..f47cb76e0e3d 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -80,6 +80,16 @@ module_param(verbose, int, 0644); MODULE_PARM_DESC(verbose, " dynamic_debug/control processing " "( 0 = off (default), 1 = module add/rm, 2 = >control summary, 3 = parsing, 4 = per-site changes)"); +static inline unsigned int get_flags(const struct _ddebug *desc) +{ + return desc->ctrl.flags; +} + +static inline void set_flags(struct _ddebug *desc, unsigned int val) +{ + desc->ctrl.flags = val; +} + /* Return the path relative to source root */ static inline const char *trim_prefix(const char *path) { @@ -247,11 +257,11 @@ static int ddebug_change(const struct ddebug_query *query, nfound++; - newflags = (dp->flags & modifiers->mask) | modifiers->flags; - if (newflags == dp->flags) + newflags = (get_flags(dp) & modifiers->mask) | modifiers->flags; + if (newflags == get_flags(dp)) continue; #ifdef CONFIG_JUMP_LABEL - if (dp->flags & _DPRINTK_FLAGS_ENABLED) { + if (get_flags(dp) & _DPRINTK_FLAGS_ENABLED) { if (!(newflags & _DPRINTK_FLAGS_ENABLED)) static_branch_disable(&dp->key.dd_key_true); } else if (newflags & _DPRINTK_FLAGS_ENABLED) { @@ -261,9 +271,9 @@ static int ddebug_change(const struct ddebug_query *query, v4pr_info("changed %s:%d [%s]%s %s => %s\n", trim_prefix(dp->filename), dp->lineno, dt->mod_name, dp->function, - ddebug_describe_flags(dp->flags, &fbuf), + ddebug_describe_flags(get_flags(dp), &fbuf), ddebug_describe_flags(newflags, &nbuf)); - dp->flags = newflags; + set_flags(dp, newflags); } } mutex_unlock(&ddebug_lock); @@ -824,10 +834,11 @@ static int remaining(int wrote) static char *__dynamic_emit_prefix(const struct _ddebug *desc, char *buf) { + unsigned int flags = get_flags(desc); int pos_after_tid; int pos = 0; - if (desc->flags & _DPRINTK_FLAGS_INCL_TID) { + if (flags & _DPRINTK_FLAGS_INCL_TID) { if (in_interrupt()) pos += snprintf(buf + pos, remaining(pos), " "); else @@ -835,16 +846,16 @@ static char *__dynamic_emit_prefix(const struct _ddebug *desc, char *buf) task_pid_vnr(current)); } pos_after_tid = pos; - if (desc->flags & _DPRINTK_FLAGS_INCL_MODNAME) + if (flags & _DPRINTK_FLAGS_INCL_MODNAME) pos += snprintf(buf + pos, remaining(pos), "%s:", desc->modname); - if (desc->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) + if (flags & _DPRINTK_FLAGS_INCL_FUNCNAME) pos += snprintf(buf + pos, remaining(pos), "%s:", desc->function); - if (desc->flags & _DPRINTK_FLAGS_INCL_SOURCENAME) + if (flags & _DPRINTK_FLAGS_INCL_SOURCENAME) pos += snprintf(buf + pos, remaining(pos), "%s:", trim_prefix(desc->filename)); - if (desc->flags & _DPRINTK_FLAGS_INCL_LINENO) + if (flags & _DPRINTK_FLAGS_INCL_LINENO) pos += snprintf(buf + pos, remaining(pos), "%d:", desc->lineno); if (pos - pos_after_tid) @@ -857,7 +868,7 @@ 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(get_flags(desc) & _DPRINTK_FLAGS_INCL_ANY)) return __dynamic_emit_prefix(desc, buf); return buf; } @@ -916,7 +927,8 @@ static void ddebug_trace(struct _ddebug *desc, const struct device *dev, __printf(2, 3) static void ddebug_printk(struct _ddebug *desc, const char *fmt, ...) { - if (desc->flags & _DPRINTK_FLAGS_TRACE) { + + if (get_flags(desc) & _DPRINTK_FLAGS_TRACE) { va_list args; va_start(args, fmt); @@ -928,7 +940,7 @@ static void ddebug_printk(struct _ddebug *desc, const char *fmt, ...) va_end(args); } - if (desc->flags & _DPRINTK_FLAGS_PRINTK) { + if (get_flags(desc) & _DPRINTK_FLAGS_PRINTK) { va_list args; va_start(args, fmt); @@ -942,7 +954,7 @@ static void ddebug_dev_printk(struct _ddebug *desc, const struct device *dev, const char *fmt, ...) { - if (desc->flags & _DPRINTK_FLAGS_TRACE) { + if (get_flags(desc) & _DPRINTK_FLAGS_TRACE) { va_list args; va_start(args, fmt); @@ -950,7 +962,7 @@ static void ddebug_dev_printk(struct _ddebug *desc, const struct device *dev, va_end(args); } - if (desc->flags & _DPRINTK_FLAGS_PRINTK) { + if (get_flags(desc) & _DPRINTK_FLAGS_PRINTK) { va_list args; va_start(args, fmt); @@ -1246,7 +1258,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p) seq_printf(m, "%s:%u [%s]%s =%s \"", trim_prefix(dp->filename), dp->lineno, iter->table->mod_name, dp->function, - ddebug_describe_flags(dp->flags, &flags)); + ddebug_describe_flags(get_flags(dp), &flags)); seq_escape_str(m, dp->format, ESCAPE_SPACE, "\t\r\n\""); seq_puts(m, "\""); From patchwork Sat Feb 10 23:49:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199333 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1700783dyd; Sat, 10 Feb 2024 15:53:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV6ecQRs7GoAA6POkYGrn9J3VN2Wwly/KprXh2U8Fsaq7AdR8aya9K6bMud+ep8+6JssGz5vbINaTBocr5rDKBj2AgU8A== X-Google-Smtp-Source: AGHT+IHxDM8ZPkiv5fVAzxWX7WEbwmUF0HafLIMgATvcqp53vJyXmi0VS0mQpmbnurp2RORyltjm X-Received: by 2002:a05:6870:eca5:b0:218:f685:3a88 with SMTP id eo37-20020a056870eca500b00218f6853a88mr3603355oab.45.1707609187559; Sat, 10 Feb 2024 15:53:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609187; cv=pass; d=google.com; s=arc-20160816; b=JaYYjh7cbEhebDpf29RXqUN1B5DN4H/YaodUw4xtemSiqNYueb9d34lmukVq9/drX5 wLuRbcrSBY3fU0MbEehhwEzGWdPlh7Spmht7Ue2F8J8VHnSl7FsVJcAnfLl6s8Rsa/6l JWpFQayCsKNrdqs/1QmaJCgz0Pi2+6nPTzaA+9wGYzvOmcfO2fUMWD0+/w62x4L1a0Gg y0LUz5yZoVlg1UvPNiCNqde6awR7rtguySa+k4Uuo4dr/1l1/z7s6ZSQCsiCLN/Wm+AA xNoy+n92ZodKStuzVSf9FQgdAm6V5BgGZqaJOF5Di9e4br9JF9Xkjum34hWBOp+N2F2d p7+g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=nULGoBvrjPazMaReX9FXf3uprPHVFqensPMgM7zd3J0=; fh=DwF21Yzg5Y5vWxZqVN/81vm7fdr3m8X/E9uT+uF1vRg=; b=aUm72LqXjyGRJ+HwvtcHXgShwV/d+Z26finu0hdbxaEdtmk3QRJk8imbI6DA6o2V9K BovYDN1OjoOXcQwtnCdsePr5kPz1UOpSezEmXl3unxJxjjRH15FcBhaE+rqtvEqvcf+5 sgL/GatYf1am52UiQkkeJtR9/pPX8GDfSQ9Kvzjkb8tvNi0lqnalVmdTAzqNisxA97Dt f3ExuJAJwtVpWkyzbOgTaqxYUGYZhg8TRo99HL9v0gzbGVpQkWM29LdIqln7H5tJRxx/ oo7cWYN7aG/qzUO/kGz4Wka5NJRyuLSCSR0g0MJlmvfo6RLIZyqLmkwKg2UYjsW9oA6l 9llA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Ztvr1j+v; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60592-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60592-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCXjwr1gk+wklthcys/ougUL7WVpl64CEBUscl68Uux//cebUflWHB4GUrd/oJstSyeay5wQwCRiP19So5AkzQpIklNeUA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q25-20020a637519000000b005d8e320fea4si4088723pgc.336.2024.02.10.15.53.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:53:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60592-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Ztvr1j+v; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60592-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60592-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 668A7B22BCE for ; Sat, 10 Feb 2024 23:53:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE71B60DC9; Sat, 10 Feb 2024 23:50:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Ztvr1j+v" Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) (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 6481160881 for ; Sat, 10 Feb 2024 23:50:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.68 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609048; cv=none; b=O3OU/Ga1kldKsHv+rR1TKH51yXTDZmTQSXdnDV1y6x+t0105CPp4/VgZEb4LwUfhxvTn+Ft0r1CNx2/msZSVLPSoqjqeyV3ltWm9Eh5koiIkk85RxNOeDXLqdbaQ2mseMvHW9U350edytidnEYY9m6A+oWP5ag20MLEWPUWxQmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609048; c=relaxed/simple; bh=Yix+pbfpxiUDW0+LvNlKGlFsd39VDWqixPWRM9lIlGU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jwxfRkm0NhcFfG4cMzwMFeFAZ//NY76PDS8WO7AYEYowXn34Hd8Ec0oEs95sz93X0BAfUzZBw2k7g8zJ8bhu37xuMp8/EgtD0hPskywIeYRtUI8TuGxGYZ6EQka5YmLvzZAiBeT6JPZq03REkT3MkZr3vd61IbjZqqyL+9vdRRY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=Ztvr1j+v; arc=none smtp.client-ip=209.85.167.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f68.google.com with SMTP id 2adb3069b0e04-51147d0abd1so2384481e87.1 for ; Sat, 10 Feb 2024 15:50:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609044; x=1708213844; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nULGoBvrjPazMaReX9FXf3uprPHVFqensPMgM7zd3J0=; b=Ztvr1j+vWq8KHrlGO+JrHCEpW+dj5020sOzySAlrFPWkL7I2/KDSAg5hlfTp8ykMm6 feA3ej0NTV7gURHhjWF/kNwYWqOlGHm7FYkg8zeN+44Fri21U+AL3b+Jtn8VejHUDUhz ivtACn2mmKNm3pi16Is88SBzOsKkxdbSqaod8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609044; x=1708213844; 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=nULGoBvrjPazMaReX9FXf3uprPHVFqensPMgM7zd3J0=; b=HxRjkDUXtRFTcwNIHGKZ/qP1Ext7lQKywg5lpzMJwqXHpMoS+uLsl3tT9reXooFpwT w+sD//WgkkZbqLaWEkR/JGhWTaWevxOVHUKV3Moc2znBkthihAikxiWTaoINWKfI+jKa +oPCshGKYk0d+j+pDxnQgRs3De1iMBe64yIS21CpiqGTEs2lJrsfjOTSa7SBnoQ5MVSm ml1LuY7Dx5dmyMsYQ3quaK4E+VdF4AwUiPhdTY3UKesjpGUNzIaCP7epZnTPSriTJDK3 IBoOM0lF/ea3EpUYv2TPEooNGp8Ft26vSPMwn6wvb13xNcHiGdSS4qtKPypKbspP7jwg Jv4Q== X-Forwarded-Encrypted: i=1; AJvYcCVJUPIa0GkjApL3sm1+1lNWccbAK28TDfj4KI8JdhwDbbPWs5jAvoeRd7+4c0uVOJFz6KpXD08VPbtnvhYqYuuzW4gdjJwgl/IiWX+S X-Gm-Message-State: AOJu0Yz/6ePEZY79WMwHzXO9jPQ+czy280zMXZlJGEZqJ4519bYQn7gs ABvuCBIsqY0bfRqpsUQO/ubxjRbQ4RVFaRjlMVa1PGok3zij7brBH5ww5mP7 X-Received: by 2002:a05:6512:2e9:b0:511:2e97:add2 with SMTP id m9-20020a05651202e900b005112e97add2mr1854012lfq.66.1707609044477; Sat, 10 Feb 2024 15:50:44 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXQzzEwiN58SQb8vBfDQPtFpNaKYkBecdyHyEUZb8tbv73P3Ah9jV2pyLh9mjjU9J+ku92PzDwu4vY3zbwQOmObLeROtbnDLn6ep0xGE4s/a4Tg1UhwiRouuWZSgMtt3jOEowM51QT1+OR6BpPstnDsZDoCL3SSFOvQAeEOPwGlxuXwHt5bl5r9h+dNVVWs4hlnzobgTEEvLU+0/XRRM1IIEthZjcYc1i/p/Q+ay7r4ECMi7QVM75haNQIrhf7uMB2KeZ+J+tju2ZzF29fxrqTxLbnt0PZWnxeW7LbR4xaAcQvvU8nNKCjbk7SH6bcTcDMkPL2UtQM1zlPit6SPeSU6eGo1NtDibmR28maW1wmPwvyWkSKswNeQOslO5P9DnXdvpuSDV2bjoopPHZWG/5skswr1uRUkNNVsVkQIcqCxl+hjjcSDM2AlMucPFMOSVwxZfCRM6IGBihRYsGtDo0K9bOSl2Mxmy4Byl7spbFhAqayILLNjiVm5iSKYMXFSPtDRHQN7NzDEYFncM4leytKlBzazpsxaw1egd0usYZ75c+NsMylO4yH7hcx2/s+rcxbbZtOc6Aw0vWiW851AZ0n0djmYsd+kHtgXh8CiWN9mPlJXMg== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:44 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 09/39] dyndbg: add trace destination field to _ddebug Date: Sun, 11 Feb 2024 00:49:39 +0100 Message-ID: <20240210235009.2405808-10-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790558011560901550 X-GMAIL-MSGID: 1790558011560901550 The trace destination field is used to determine output of debug logs when +T is set. Setting trace_dst value to 0 enables output to prdbg and devdbg trace events. Setting trace_dst value to a value in range of [1..63] enables output to trace instance. Signed-off-by: Łukasz Bartosik --- include/linux/dynamic_debug.h | 13 +++++++++++-- lib/dynamic_debug.c | 28 +++++++++++++++++++--------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index a551b2967cb8..dc10c7535f13 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -60,9 +60,18 @@ struct _ddebug { #else #define _DPRINTK_FLAGS_DEFAULT 0 #endif - struct { + struct dd_ctrl { unsigned int flags:8; - unsigned unused:24; + /* + * The trace destination field is used to determine output of debug + * logs when +T is set. Setting trace_dst value to 0 enables output + * to prdbg and devdbg trace events. Setting trace_dst value to a + * value in range of [1..63] enables output to trace instance. + */ +#define TRACE_DST_BITS 6 + unsigned int trace_dst:TRACE_DST_BITS; +#define TRACE_DST_LAST (1 << TRACE_DST_BITS) + unsigned unused:18; } ctrl; } __attribute__((aligned(8))); diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index f47cb76e0e3d..0dc9ec76b867 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -80,14 +80,24 @@ module_param(verbose, int, 0644); MODULE_PARM_DESC(verbose, " dynamic_debug/control processing " "( 0 = off (default), 1 = module add/rm, 2 = >control summary, 3 = parsing, 4 = per-site changes)"); +static inline struct dd_ctrl *get_ctrl(struct _ddebug *desc) +{ + return &desc->ctrl; +} + +static inline void set_ctrl(struct _ddebug *desc, struct dd_ctrl *ctrl) +{ + desc->ctrl = *ctrl; +} + static inline unsigned int get_flags(const struct _ddebug *desc) { return desc->ctrl.flags; } -static inline void set_flags(struct _ddebug *desc, unsigned int val) +static inline unsigned int get_trace_dst(const struct _ddebug *desc) { - desc->ctrl.flags = val; + return desc->ctrl.trace_dst; } /* Return the path relative to source root */ @@ -190,8 +200,8 @@ static int ddebug_change(const struct ddebug_query *query, { int i; struct ddebug_table *dt; - unsigned int newflags; unsigned int nfound = 0; + struct dd_ctrl nctrl = {0}; struct flagsbuf fbuf, nbuf; struct ddebug_class_map *map = NULL; int __outvar valid_class; @@ -257,14 +267,14 @@ static int ddebug_change(const struct ddebug_query *query, nfound++; - newflags = (get_flags(dp) & modifiers->mask) | modifiers->flags; - if (newflags == get_flags(dp)) + nctrl.flags = (get_flags(dp) & modifiers->mask) | modifiers->flags; + if (!memcmp(&nctrl, get_ctrl(dp), sizeof(struct dd_ctrl))) continue; #ifdef CONFIG_JUMP_LABEL if (get_flags(dp) & _DPRINTK_FLAGS_ENABLED) { - if (!(newflags & _DPRINTK_FLAGS_ENABLED)) + if (!(nctrl.flags & _DPRINTK_FLAGS_ENABLED)) static_branch_disable(&dp->key.dd_key_true); - } else if (newflags & _DPRINTK_FLAGS_ENABLED) { + } else if (nctrl.flags & _DPRINTK_FLAGS_ENABLED) { static_branch_enable(&dp->key.dd_key_true); } #endif @@ -272,8 +282,8 @@ static int ddebug_change(const struct ddebug_query *query, trim_prefix(dp->filename), dp->lineno, dt->mod_name, dp->function, ddebug_describe_flags(get_flags(dp), &fbuf), - ddebug_describe_flags(newflags, &nbuf)); - set_flags(dp, newflags); + ddebug_describe_flags(nctrl.flags, &nbuf)); + set_ctrl(dp, &nctrl); } } mutex_unlock(&ddebug_lock); From patchwork Sat Feb 10 23:49:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199334 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1700832dyd; Sat, 10 Feb 2024 15:53:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUBmICBTpilqvv0DyvnRWo2wQkGQP0S5x0wwxL1r66br6pcp5iBgZ7XrvJsI3W9zbBux28IYq2tcsVOi0Kx+nUpzkKUEQ== X-Google-Smtp-Source: AGHT+IEL3ii/SJFn/UmaZAOv/cQsV8kWv5KEVVjXEzZj9JPduYCc4i3SmPF1Y8lSoSGQkb9YhCd4 X-Received: by 2002:aa7:8817:0:b0:6dd:88a8:cf25 with SMTP id c23-20020aa78817000000b006dd88a8cf25mr3942973pfo.8.1707609204241; Sat, 10 Feb 2024 15:53:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609204; cv=pass; d=google.com; s=arc-20160816; b=0G/0PNvAOWXHdxm35SMEHleROQ+kwez/hpGopVDBAjHEy0SsLZ2v9krZgTjbi6NZXr a2wJE3wt6LArEhOIQAcf0GEhbR4UO29VuFH3Fw0koLOc1+HZwX2CGezyDqeG/eOrYW56 ba65ao7KHetTTq4k6CvpMF6wevECnYsajntO0crXpfZMjLuzA5nGar436+qSmYBPQpqL 0K0TZOtHoDYmvuz61VT3r6FoFx74SpRJsbtrxgpWWlWcfEHKcDMylS5b9nhtEHv17VBq w9S3o1JRf5RrEjHxpMWBrnvgdAa31+ccNGm+A8mPgfLvThVGzYDxKoyeTfwHXGGdIl+e FJew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=kdad3Evs7q/LlRKkCSzkMMat3wm4/GWPiv0LyGMWHAo=; fh=cid4tAp4TW5AS0IFbwAEn9PQof795dMBurJa2AE89eg=; b=Sw70jKWsck/iTIMeqcmTmaKoyt2hQcjBkMG4UQLqswqDfge4TUgM6s/aONbkWWUBvR jzItw4t3n09gsboZ6ncokhVnxi5iTyw77F6ocwISN/2Cg13zBb1S50a8s3Ml0SkvGKuK h06ERFK6NHHDE26zar9EqqpmHmGBcacVPlSjhfz0Ax9QikSaKdojnOKjepfjhdK2phO5 ej/SQ0UfVSiJOW/DtSMHvzEq9ooncTOoxHyuGbmdr1OTCihSY1NHnm9SF2aLwqPQD14I sF5CXX5lEV6EuyDMSSvH7N9VEIwjYyNeETrd4zBJqG0WbMSRC4p9ukjRhpUGWJGttH6R dMBA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=j1k3Z5rt; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60593-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60593-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCVbr/bWkzPncDMMyzMxfvasEqxhdx4wGWaMHPPoAJX80uPkuY+gos2kITbRLNOzffiokxZAOJ2GSB4CyOv7I+ItYNjEyA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b27-20020a63715b000000b005dbefa1fb3asi4237965pgn.578.2024.02.10.15.53.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:53:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60593-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=j1k3Z5rt; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60593-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60593-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id F2EB4283F3B for ; Sat, 10 Feb 2024 23:53:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1865460DF0; Sat, 10 Feb 2024 23:50:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="j1k3Z5rt" Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 E3D8C6089D for ; Sat, 10 Feb 2024 23:50:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609049; cv=none; b=lLKlYqS4Q/vRZDY33dtVDi/BlpjhpdmB3G082g5XfPDGyYATlpHn4VjvL5EllsG1pqC+L8+k3vvPRqnnTGz8wV1xUfT7Lr2gIulOwCNjSQppqb0ZAOXPhASsF4A7MoZgVc7MBff3KpaF/lI2EG7YHneAFn7zVD+a+9UYoPSlZgs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609049; c=relaxed/simple; bh=auLLBjaM7NJ4bfEIN23dALRyRz9gbqEMOckQKBJQ810=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TQDE39RUDjEKs0NS9lxKa5Hz/RTAE1ZGeoyCN/paPTD/44XufNHYk2hbD8iRpnnNhSeuxE9CWaDbf7RAH6UZAbxUEM3yd1T2uEG3+FjTr/5ZNEjE2ku3hCh2KutcjeLjCAIA8uvVI1SqXl0bYsLI424C+QL828XTBdhlarVuR+Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=j1k3Z5rt; arc=none smtp.client-ip=209.85.167.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-51142b5b76dso3281284e87.2 for ; Sat, 10 Feb 2024 15:50:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609046; x=1708213846; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kdad3Evs7q/LlRKkCSzkMMat3wm4/GWPiv0LyGMWHAo=; b=j1k3Z5rtUWmHRtmR3GJjUOn9dVhcpdRsqrXrRZwQMHMvD6o0uGtO7c/oQgoPm5TxV3 Nfbi1+l8iCEtj7KEQ6mG5wl72NLeQvmnZg+Uj1i+FUO1QMf6WiqKifMF69grRPTfJDAy NGrZC/Gkf9JUt1qcHHS68l4Jnh9mNfjqp/UsA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609046; x=1708213846; 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=kdad3Evs7q/LlRKkCSzkMMat3wm4/GWPiv0LyGMWHAo=; b=moRNomSsGlxa0cMCj3OGGHmeEEf4VKIKmLzN8Mgh1aUNFxiZOee0xfxvZYYD0SQR+W ZzGQTL4kTxzxEx2AQ4l7jBDZpZhU4YXPxf/pu4y8xyqgAbugSWUx57Z+1A/vcG5YPV4j RxSMIdLIlNOHqqYfwweIylxB+L1dx8JHQd6ZmL1ozIwQWgKinNAQgdqDAiLhWyJGi51y uMBo6sJQEnVM7CLw4X/syHfuSINKnWNfGDBBDKb8k1jHfKxBM3f0vQBAAIdA2DP99Bfj Pyusr10UaHQbIyVF1E+0kBasDXURbFlqIUqBCQDrUbSIuWo9dAMHaARAugB/jmu71YyQ I6nQ== X-Forwarded-Encrypted: i=1; AJvYcCX0QkbpL+2Qk+JmM5t3ayLzDbL3gCVfS6T6Vcv44uNMpUsR4pvcf/JhIzV4lVShYHDP/7WaiytUBmhikZNTOAQV8sclXL8Jw2Kv9nuc X-Gm-Message-State: AOJu0Ywo4P+Cx5COnruXP3YgLkIYSezlwQ+d4xRTKOf2hFOD9o2IbvF6 lJF9qBrDC4Zh6z8NY5yC/UPSkXoJpyDK3TUBxul3g6vxEZ8rkfZiY6LQz0Vs X-Received: by 2002:a05:6512:2246:b0:511:30fd:9223 with SMTP id i6-20020a056512224600b0051130fd9223mr2437424lfu.55.1707609046141; Sat, 10 Feb 2024 15:50:46 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUeEN/u1Ra7BheU7TL7DwOI0jDwcjxIBHsm8aVcbFuDjCj+dW8hZSBy5ZT1IwGGzhMw5TqcEYZW5wLWCkd75BpMVrWwv0pTLf9lPeFUYkvRpsXNIJYQoM/x9N3DpljZPErHGV+NaskAjRof7bcNxFFVArSMz+1KZ3He9pWp1rvkOUycnbKChd3gzROwFRP02mN3cc9YBhrqWVmgHNoKi/q+q/a27oa5bzQrXllzp4a0sJ43xUUPen/EGCHScoFFkEdsI+Ggw89WzKmE0FHyVD4TyZ4m1nM6JHfhKVkoGk0eWZp1Vy3w6QG5vl1yGIKHzwKVdN9Qx9JtoSydwDa8ZF4H4uOfhwWtxS2BbMO7PODELBbmLTJFqggZ4xlLDnO+1qzDCwmrNpmvyUq+G2h/F9HXOlGd2T67KhOtuEn2M34nuv+nlrfD8ZOHMKztDVkitd8AU3TI8Gl0YtAKhS2NyeXq0bSlU++yKM/XTobzRUzEVUY7f9VhAG1e3GgRvODesSnS2M/MJiuscLwLkoO5HAOiB8zxi/5mpDyTFMYw073n+OZq1QbBzOKvqBmAEVVTT1ayanfbV9xLgVeqjiTskDbm4VZJ3uBxOaSF7FmF/bZej21DGw== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:45 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 10/39] dyndbg: add open and close commands for trace Date: Sun, 11 Feb 2024 00:49:40 +0100 Message-ID: <20240210235009.2405808-11-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790558029366174324 X-GMAIL-MSGID: 1790558029366174324 Add open and close commands for opening and closing trace instances. The open command has to be mandatory followed by a trace instance name. If a trace instance already exists in /tracing/instances directory then the open command will reuse it otherwise a new trace instance with a name provided to the open will be created. Close command closes previously opened trace instance. The close will fail if a user tries to close non-existent trace instances or an instance which was not previously opened. For example the following command will open (create or reuse existing) trace instance located in /tracing/instances/usbcore: echo "open usbcore" > /dynamic_debug/control Signed-off-by: Łukasz Bartosik --- lib/Kconfig.debug | 2 + lib/dynamic_debug.c | 194 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 975a07f9f1cc..01caf885d86b 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -110,6 +110,7 @@ config DYNAMIC_DEBUG default n depends on PRINTK depends on (DEBUG_FS || PROC_FS) + depends on TRACING select DYNAMIC_DEBUG_CORE help @@ -181,6 +182,7 @@ config DYNAMIC_DEBUG_CORE bool "Enable core function of dynamic debug support" depends on PRINTK depends on (DEBUG_FS || PROC_FS) + depends on TRACING help Enable core functional support of dynamic debug. It is useful when you want to tie dynamic debug to your kernel modules with diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 0dc9ec76b867..d0d1057911e8 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -36,6 +36,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include @@ -73,6 +74,27 @@ struct flag_settings { unsigned int mask; }; +#define DD_OPEN_CMD "open" +#define DD_CLOSE_CMD "close" +#define DD_TR_EVENT "0" + +struct dd_private_tracebuf { + const char *name; + struct trace_array *arr; +}; + +/* + * Trace destination value 0 is reserved for writing + * debug logs to trace events (prdbg, devdbg), that + * is why buf[0] is not used and we traverse bitmap + * starting from bit 1 (bit 0 is also not used). + */ +struct dd_tracebuf_tbl_info { + struct dd_private_tracebuf buf[TRACE_DST_LAST]; + DECLARE_BITMAP(bmap, TRACE_DST_LAST); + int bmap_size; +}; + static DEFINE_MUTEX(ddebug_lock); static LIST_HEAD(ddebug_tables); static int verbose; @@ -80,6 +102,9 @@ module_param(verbose, int, 0644); MODULE_PARM_DESC(verbose, " dynamic_debug/control processing " "( 0 = off (default), 1 = module add/rm, 2 = >control summary, 3 = parsing, 4 = per-site changes)"); +static struct +dd_tracebuf_tbl_info trc_tbl = { .bmap_size = TRACE_DST_LAST }; + static inline struct dd_ctrl *get_ctrl(struct _ddebug *desc) { return &desc->ctrl; @@ -171,6 +196,145 @@ static void vpr_info_dq(const struct ddebug_query *query, const char *msg) query->first_lineno, query->last_lineno, query->class_string); } +static bool is_dd_trace_cmd(const char *str) +{ + if (!strcmp(str, DD_OPEN_CMD) || !strcmp(str, DD_CLOSE_CMD)) + return true; + + return false; +} + +static bool dd_good_trace_name(const char *str) +{ + /* "0" is reserved for writing debug logs to trace events (prdbg, devdbg) */ + if (!strcmp(str, DD_TR_EVENT)) + return false; + + /* we allow trace instance names to include ^\w+ and underscore */ + while (*str != '\0') { + if (!isalnum(*str) && *str != '_') + return false; + str++; + } + + return true; +} + +static int find_tr_instance(const char *name) +{ + int idx = 1; + + for_each_set_bit_from(idx, trc_tbl.bmap, trc_tbl.bmap_size) + if (!strcmp(trc_tbl.buf[idx].name, name)) + return idx; + + return -ENOENT; +} + +static int handle_trace_open_cmd(const char *arg) +{ + struct dd_private_tracebuf *buf; + int idx, ret = 0; + + mutex_lock(&ddebug_lock); + + /* bit 0 is not used, reserved for trace prdbg and devdbg events */ + idx = find_next_zero_bit(trc_tbl.bmap, trc_tbl.bmap_size, 1); + if (idx == trc_tbl.bmap_size) { + ret = -ENOSPC; + goto end; + } + + if (!dd_good_trace_name(arg)) { + pr_err("invalid instance name:%s\n", arg); + ret = -EINVAL; + goto end; + } + + if (find_tr_instance(arg) >= 0) { + pr_err("instance is already opened name:%s\n", arg); + ret = -EEXIST; + goto end; + } + + buf = &trc_tbl.buf[idx]; + buf->name = kstrdup(arg, GFP_KERNEL); + if (!buf->name) { + ret = -ENOMEM; + goto end; + } + + buf->arr = trace_array_get_by_name(buf->name, NULL); + if (!buf->arr) { + pr_err("failed to get trace array name:%s", buf->name); + ret = -EINVAL; + goto end; + } + + ret = trace_array_init_printk(buf->arr); + if (ret) { + pr_err("failed to init trace array name:%s", buf->name); + trace_array_put(buf->arr); + trace_array_destroy(buf->arr); + goto end; + } + + set_bit(idx, trc_tbl.bmap); + v3pr_info("opened trace instance idx=%d, name=%s\n", idx, arg); +end: + mutex_unlock(&ddebug_lock); + return ret; +} + +static int handle_trace_close_cmd(const char *arg) +{ + struct dd_private_tracebuf *buf; + int idx, ret = 0; + + mutex_lock(&ddebug_lock); + + idx = find_tr_instance(arg); + if (idx < 0) { + ret = idx; + goto end; + } + + buf = &trc_tbl.buf[idx]; + + trace_array_put(buf->arr); + /* + * don't destroy trace instance but let user do it manually + * with rmdir command at a convenient time later, if it is + * destroyed here all debug logs will be lost + * + * trace_array_destroy(inst->arr); + */ + buf->arr = NULL; + + kfree(buf->name); + buf->name = NULL; + + clear_bit(idx, trc_tbl.bmap); + v3pr_info("closed trace instance idx=%d, name=%s\n", idx, arg); +end: + mutex_unlock(&ddebug_lock); + return ret; +} + +static int ddebug_parse_cmd(char *words[], int nwords) +{ + if (nwords != 1) + return -EINVAL; + + if (!strcmp(words[0], DD_OPEN_CMD)) + return handle_trace_open_cmd(words[1]); + if (!strcmp(words[0], DD_CLOSE_CMD)) + return handle_trace_close_cmd(words[1]); + + pr_err("invalid command %s\n", words[0]); + return -EINVAL; +} + static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_table const *dt, const char *class_string, int *class_id) { @@ -567,6 +731,11 @@ static int ddebug_exec_query(char *query_string, const char *modname) pr_err("tokenize failed\n"); return -EINVAL; } + + /* check for open, close commands */ + if (is_dd_trace_cmd(words[0])) + return ddebug_parse_cmd(words, nwords-1); + /* check flags 1st (last arg) so query is pairs of spec,val */ if (ddebug_parse_flags(words[nwords-1], &modifiers)) { pr_err("flags parse failed\n"); @@ -1191,6 +1360,20 @@ static struct _ddebug *ddebug_iter_next(struct ddebug_iter *iter) return &iter->table->ddebugs[iter->idx]; } +/* + * Check if the iterator points to the last _ddebug object + * to traverse. + */ +static bool ddebug_iter_is_last(struct ddebug_iter *iter) +{ + if (iter->table == NULL) + return false; + if (iter->idx-1 < 0 && + list_is_last(&iter->table->link, &ddebug_tables)) + return true; + return false; +} + /* * Seq_ops start method. Called at the start of every * read() call from userspace. Takes the ddebug_lock and @@ -1281,6 +1464,17 @@ static int ddebug_proc_show(struct seq_file *m, void *p) } seq_puts(m, "\n"); + if (ddebug_iter_is_last(iter) && + !bitmap_empty(trc_tbl.bmap, trc_tbl.bmap_size)) { + int idx = 1; + + seq_puts(m, "\n"); + seq_puts(m, "#: Opened trace instances:"); + for_each_set_bit_from(idx, trc_tbl.bmap, trc_tbl.bmap_size) + seq_printf(m, " %s", trc_tbl.buf[idx].name); + seq_puts(m, "\n"); + } + return 0; } From patchwork Sat Feb 10 23:49:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199335 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1700837dyd; Sat, 10 Feb 2024 15:53:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IGsyiArdQ1Ov9LDjnnziBbBpBuO2RqTcVVKirT4h2AtnqgBW75QnUxngeSuNNhRUgy2/++5 X-Received: by 2002:a05:620a:85b:b0:785:bfc8:193f with SMTP id u27-20020a05620a085b00b00785bfc8193fmr6221889qku.23.1707609206082; Sat, 10 Feb 2024 15:53:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609206; cv=pass; d=google.com; s=arc-20160816; b=LjKRvpoyVUcA1VMEeMx+obx9fIfRv8Lu/jWJgJ/t4HGP+1mUFPXqNblfh03MjLtIJr Y4FnyAUsW2XAZZ7+s3rc6+2WhOsFIUjYMF1OpYUPQ7lGr+VR33gjcuO4w4NAyt5/BTnh /7BGLIqibSM1dE8+s0ZtxSM0TBFr0Qfyynh9h3fQXe6tuWs7ikYhtmNWETsNcHdriqsu UzQbi2S7WjFKS4b5cPWLOzBwWOD815QgcEGYJLc2sZ6tYhSNgRXWO9tQYo7CItZNxUw3 52N6Dl0OhWDcmbh3NsaI+hceyzEr1A8CADebWHdNUmsNbKctCIxL790RQ/ChjqWJw+oX O9Cg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=457Ak5D/cnjLkQBnQYpRWcf9B+gpaO4d0gKyEUhhPYE=; fh=ZG7mivRgWLn3xjuAy2u5N9mD+Rl1cOC+v6Dd1sfjoFg=; b=LMH1A6DI8Uu/BFE2XtBuwicvUCr0jsvSoMKlyfk5LqWAqK9TQ+WFJk+g4jzPz9uSv9 m88f2QTnCzDxoyGS6Y3KVvUaKi4kRlKrxLvufQUMGzkN1oHVMiJQMWidQdVbw9o9If7b A8GNPsBNEbM+/yrlLohs9ZR/UKrZt9SEyCJ/JB2+hG2kFxzJ9S6vBOwuEWh63QOWtN+6 Smo/xc6p9/mbp9dFvsq7uZ62psWz/IOEkskXlZ3fHibuapTM3mWdLJ3WsW4Bq58rR3oW ylkRbGOU5WgVNpCACw3hTVe4oTQgJgQyGhBOOAYysCPyXaUVtN/wZ/8nDV58Z5dvICr6 noEQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=M9RUtWqF; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60594-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60594-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCUFe4YZqpATbU/jh0hAU8q9XgCweOijm0Ts5MuLxUxEW3QZFv7CF6jCmTEYI9P2OaRmTqcedCNK7mNQbcrJidXZbQRkWA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o1-20020a05620a0d4100b007854df8a6e6si2745953qkl.417.2024.02.10.15.53.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:53:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60594-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=M9RUtWqF; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60594-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60594-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C83971C219C9 for ; Sat, 10 Feb 2024 23:53:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 493FB60DF4; Sat, 10 Feb 2024 23:50:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="M9RUtWqF" Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) (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 8405960B95 for ; Sat, 10 Feb 2024 23:50:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609051; cv=none; b=Cwt9ksBEJJ6OPv3CbeVFJegy9szeXTJmwrmzCpm+qITI6NsuDXl+xQZ8zSydLhPlG9pgNPAoifjw4OyU0Dzc44Nt4OtGl/UklkMPuw+dc0ufs923KRnQOqlMI6W6WC3akeGzW1sGBxQ207vc6jlZGAtgtSKNPKcgqPkBTvklH0g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609051; c=relaxed/simple; bh=Q12PHdJJNT6cHmzxSgqa8vX7kdu2nXbasdwo0iTu/C4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=omRkYFqhbgsu0KlcttnZIu9SdBYz/oP56QYA6skxxXcTjk8Cvxr+3fwyo4Upe/CVpna0H0b8+Qsqyg5rLQxB2aEYCX2jB/Tjn/ByttyrrjkN7lpboDsWpihJvfXdyIzVWfkC3Qx0Ne5QU0tjUZzYFlUv89uT2ARj0UKm4tNkp2I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=M9RUtWqF; arc=none smtp.client-ip=209.85.167.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f65.google.com with SMTP id 2adb3069b0e04-51167e470f7so2650892e87.2 for ; Sat, 10 Feb 2024 15:50:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609047; x=1708213847; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=457Ak5D/cnjLkQBnQYpRWcf9B+gpaO4d0gKyEUhhPYE=; b=M9RUtWqFgbfNjL/ujjQKLYU58wc9EE6hmHq9m6CiyVWgKtD7VxiGti44i/3fPYLL16 z8aLItMeLvn1Hyalj4fOX6uzq8ec8gmVYJndgdWmijAzCYBP6AYJKtXreeM/i2//DKcT eC4l2FQqoyeZZwewlVjoJszMHqcdfE4oNqwuo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609047; x=1708213847; 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=457Ak5D/cnjLkQBnQYpRWcf9B+gpaO4d0gKyEUhhPYE=; b=qedTKKZcoR26edBZHrBnS78DJhb4oji+Ml2j0GCszOxPYR2EP/HpAP2EJWbXOA6QYI Ai5n8wOdmcMDRCiEtHB18crze/0Zq/kVsLGoWkETz7CKlllPVGbQWgL1D5se6mJIJBk+ DLGvvDeBY2tRNau5wvO9YgoMxic5b3cAIohUwgMl96QsbZPb+76ss2R1jO163xQwS07A ENEXRCkONh4acwmyAntb1DGum24tQGU1A1G3wZ2yRMQ3Zst6IipAbQGO3c9V0BBDJ9XH OWt/7syBNUw2dWlTs5X/IRVli/q/Bc+GZKCf2XXnQdmYX7gFV7/klU9sEx5AE7qe8IRy Z2FA== X-Gm-Message-State: AOJu0Yze5yprBJfTistUbzVxXSjGm3+tOX+YMz9X0ksXE+bL1zBT6DoE fafqME8sjmoSj39zBuinWWJSxawIyF5/lXiUP+UNTlQmMMoSzno5jCrNc5Sw X-Received: by 2002:a19:7506:0:b0:511:82a9:d1ba with SMTP id y6-20020a197506000000b0051182a9d1bamr1457500lfe.28.1707609047708; Sat, 10 Feb 2024 15:50:47 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCW5raDEuSR4hlFmQbaPuUFU4U8r0QGr8yRF5A8pn4yL7EjCSmrvGldSg/Vy19lmZaBy+BKzxBQuiYTaQcreViEjFFImhUvmVpfNLo33gr2HMooqImQOycKUXFwISZAoC2LL+7cM/+fhFeJHpyrU/EU7rKzrnNl5wzuJzoY6JcM6qvi5eRe4E04nLrIKT6A42tPYtsL7po0+yrgEPnzx5enJ8Cncytm6iuw+bg120c8soKGLxAn0MCR2Pwjc16IxvIOsg0+z6BPbXWrkkDhN+WqZq58jZsYOedfiidvpEYQHz8Mw2uTpT8Rd0nnQaniDcPoRZRpXPCLY1jaoRoKVgPb1pijLsiL+k035seqfeWWl8JNSuZ4GYHSEZPtd9p4a8ZjpjKHfPJWDydaFJ5yqVMxZpj3BQ2F2GyV9TvgP0OEWXpxOv6Jexnof8/B929zA+MIlvy4GxbgUQWHAm1mvG+Te/e3zOcS+kgjENNNRKRG0WZFvLYzp1CqhAqFhdeCzM/MhwwUJK7roJu84fAuFrPvagLBcdLj3y0mE+vGIoiI9hxhLnPU4jzmSsZsT0SzShc9xEIPgmtn7FqGc7lXff2IjHezQbhOQgWKmhOj9aWewVW1vZw== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:47 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 11/39] dyndbg: don't close trace instance when in use Date: Sun, 11 Feb 2024 00:49:41 +0100 Message-ID: <20240210235009.2405808-12-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790558030644953263 X-GMAIL-MSGID: 1790558030644953263 Don't allow trace instance to be closed when it is still being used by at least one callsite. Signed-off-by: Łukasz Bartosik --- lib/dynamic_debug.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index d0d1057911e8..6668f265f2c3 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -81,6 +81,7 @@ struct flag_settings { struct dd_private_tracebuf { const char *name; struct trace_array *arr; + int use_cnt; }; /* @@ -279,6 +280,7 @@ static int handle_trace_open_cmd(const char *arg) goto end; } + buf->use_cnt = 0; set_bit(idx, trc_tbl.bmap); v3pr_info("opened trace instance idx=%d, name=%s\n", idx, arg); end: @@ -301,6 +303,14 @@ static int handle_trace_close_cmd(const char *arg) buf = &trc_tbl.buf[idx]; + WARN_ON(buf->use_cnt < 0); + if (buf->use_cnt) { + pr_err("trace instance is being used name=%s, use_cnt=%d\n", + buf->name, buf->use_cnt); + ret = -EBUSY; + goto end; + } + trace_array_put(buf->arr); /* * don't destroy trace instance but let user do it manually @@ -321,6 +331,22 @@ static int handle_trace_close_cmd(const char *arg) return ret; } +static +void update_tr_dst(const struct _ddebug *desc, const struct dd_ctrl *nctrl) +{ + int odst = get_trace_dst(desc); + int ndst = nctrl->trace_dst; + + if (odst == ndst) + return; + + if (odst) + trc_tbl.buf[odst].use_cnt--; + + if (ndst) + trc_tbl.buf[ndst].use_cnt++; +} + static int ddebug_parse_cmd(char *words[], int nwords) { if (nwords != 1) @@ -447,6 +473,7 @@ static int ddebug_change(const struct ddebug_query *query, dt->mod_name, dp->function, ddebug_describe_flags(get_flags(dp), &fbuf), ddebug_describe_flags(nctrl.flags, &nbuf)); + update_tr_dst(dp, &nctrl); set_ctrl(dp, &nctrl); } } @@ -1628,6 +1655,14 @@ int ddebug_dyndbg_module_param_cb(char *param, char *val, const char *module) static void ddebug_table_free(struct ddebug_table *dt) { + int dst, i; + + for (i = 0; i < dt->num_ddebugs; i++) { + dst = get_trace_dst(&dt->ddebugs[i]); + if (dst) + trc_tbl.buf[dst].use_cnt--; + } + list_del_init(&dt->link); kfree(dt); } From patchwork Sat Feb 10 23:49:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199338 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1701067dyd; Sat, 10 Feb 2024 15:54:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUw67AF4ChTSRgj2t+1P+2F3wMX3fjC9oeBJAxEetdBuIoDk4K+241aHLpaqgVpFWgzjLbDH1Vmbl9HV5M4nmAEbOwSeQ== X-Google-Smtp-Source: AGHT+IEcGKLftjKGkvIoSP93IHcvzx5KzLunTs04RhGWGTEjGrIiUDC3ljCFnQM891F3ohyFzYrM X-Received: by 2002:a05:6a21:3993:b0:19e:c777:5c60 with SMTP id ad19-20020a056a21399300b0019ec7775c60mr2817139pzc.21.1707609263644; Sat, 10 Feb 2024 15:54:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609263; cv=pass; d=google.com; s=arc-20160816; b=QyTGUBIQ0xUvN9uEkJweAkQXZB1DyTdMgawOPnEDcflmEKzEiNv4NJeZBfgKhgYYfr fpxa1lV2sTQxj3ILI2uq84cDU9ekBO7fvQMWjaOiuxrvec9EHWcHbVQYXRfp1qvupG3E yRhM0SkIj5A1tFc1QyP1IPtlIY/3wuLXGYt7stR4KXIcZlvF6QY/vJb4EjhcDoMfxUVa oldUXp58sotC0D/hZw++muhSvvaml9p+JIxWKvC1PuK9wls7BXj9VhM06Rqc2bmDjlau zduDANnHDw0SOKY7AMGPEFM3JqaCzDMcsseMkJoT/4JSa0rTRh5s0TjXTbiLszxaI+dP 3Sog== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=VfKj9NP/58mMOcfaMc+gvbzTB/hMk+FrCsCCziFkNU8=; fh=Ua34lwqQZFQeaFEWke4h1aEPEI1AXKL2Y13wT0Ozu3A=; b=UJ8wdWcmSONnqubW2eJ1aqABD91wYnGJhKO0QesYEOoMY1FsUkp5mi+VoKKZ47FhoI wHjZZjN7IBdXvq9yAb5EjFnK78H9nDdXzXg0RGBplA513wGyX6URfFDiY8DWNmbeAF92 rs9A44DUcj/mr+0LGngIIUBK67jyed0dZw3h5U7qbWAvI4JaqM3Sa4uEKkKCc+WoEtU+ cx/tuG7rpYWGq9583B4R7tmRJEqYKgWz9oSFt2dRrVUh/qhmnAN1yReaTiaGzuytEN8L FNVieUaXra9LlLnt2uex7ahhvWS25H3ddAD3L49NOxYcwO0BTljjJErWP3jg0WKygICX shpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NEc68OHh; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60595-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60595-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCV/7MM7RHUQQIhHFPowqjtLjIMpSqQmDkY65uDL1Zz89iI32DPJ7mES1SbrZ67JqTJpjufaZnKoWZtsxc6CwXcfas62gA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id bo6-20020a056a02038600b005dc4af11fedsi4214490pgb.887.2024.02.10.15.54.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:54:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60595-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NEc68OHh; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60595-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60595-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 25694283EAF for ; Sat, 10 Feb 2024 23:54:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E1ABF612DE; Sat, 10 Feb 2024 23:50:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="NEc68OHh" Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 4AD0060BB8 for ; Sat, 10 Feb 2024 23:50:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609053; cv=none; b=abckQW7o9xHfBjbo4iaQY3qgfUdzKCDGA20k5Gs6/os5c84i45L5DFv9MlKlgyYgUxcd7hD2oL6L3NEiVYxsceozyQbDPv9ROX9YyC1UzwAkSrsJSzDgXpR2mNAAVsZOV/v3N9wCgW88MDydzSfYrCwiXXKfewW1iaxEMBQf1vc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609053; c=relaxed/simple; bh=YbEEGz+x4DGalh89sTCHjKKTuGvWKdWzObsdPhFL1wQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GtQiTygtl2sUtW1hf2Ua1D0ErCMZYjYgp4I2sC0Xq4OT/CHawbEAkhBeXa4ICxTp+wcw2yQRKmhJ77Ar43JpJKvEPqoFyMMT3piWa8bFbaeNZPY7w45uYCa1El4nJiLjksTtad3BrCyfujyP/TLCfb4J2mPeSotZKgXfU4dYHdI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=NEc68OHh; arc=none smtp.client-ip=209.85.167.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-511531f03f6so2471383e87.0 for ; Sat, 10 Feb 2024 15:50:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609049; x=1708213849; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VfKj9NP/58mMOcfaMc+gvbzTB/hMk+FrCsCCziFkNU8=; b=NEc68OHhXtTFO9xYinVIt81NO9lLr6U0JS87MQ1dGhZUiVuJmoX3p81Jy7Q2nZApXS NR0FnMH29PvJN0IE9PyPYu+1k7VVfcIOCoYXyS1v88XafT98mFaupl5spRmLtK/TCvJP eEbt/R4YdKUUueytTUHchHue6CMDOtAZ5hY78= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609049; x=1708213849; 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=VfKj9NP/58mMOcfaMc+gvbzTB/hMk+FrCsCCziFkNU8=; b=AO5obeQEHMZuBqIswlHoZ8DufvI5nO0CYLOWGLPoCV5CDFluqXCLjmUwuFBzSp6Ep2 d4jJDE8U6DFHliFdpatqBmZwoWcZCowULxVxV70KxKOt5qzc9vGe0gTXAQ3tl4oCvsya 2sSeQUcORo2J8poYHmw07fenYX6wmGNVddR9Zq22y8f8LDp6pQUK6rFciETxJr2Cg2Y8 dzg2MmytJtV6+2/9RFGKRGUsPAu+uSresnusTIHa1E8w1aYSSEzeokkZlw7vfm6dx7Yz LKxVxB12aQqLp9imcPokCmI33UxUrNDZjIDMCNfp8NZlIThtSdi3jfxzEU3ZY0gdAX26 ELdQ== X-Forwarded-Encrypted: i=1; AJvYcCVv5VOnK1IitUVv0Ky+pTzOWnPA048Y0eUb3BvXeQlgHirEf4MFLxBsBn9w3qYwSj3MNqa4YiDvxg9Md07EDDRi2wWstPlo0++Ynlrt X-Gm-Message-State: AOJu0YyR/GNSZvyUfSgqy5qrvZPA2WtCAQeadg9xKda+yuy4Fs4IVqtQ bQ8+o2nt2u6EgXm4qqLKFlDonEx9M3kJUmezmo729gWeYPM4t2WuaK9/pvse X-Received: by 2002:a05:6512:3494:b0:511:29ee:83b8 with SMTP id v20-20020a056512349400b0051129ee83b8mr1734783lfr.62.1707609049402; Sat, 10 Feb 2024 15:50:49 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUnsHsChtMY0XIdk/Tmra55cNHHohds/OiiSOJLv0iBqWdC10K+YsgbEEMMOPsB3XJbsSI9NoifHRtdkIOnt8nhTBwoEUIWQFELx7VPy3kr5rvDa+HIrOhzWFGXASHJahCFj0felYnPLIDmbBHjsuw4R+X8Nu4c46DhDTT2LUs3rfA/DSm8yihWmkKno1ZXluMLqdlRVrDe6bZpV1oSI7QTYxoc0MazdDiSEldCMtbJV/DvNht6h8Xp1dF6wX9yMWqM62Pu6mk4LpSR1gsGOilSy5C+01lrHoW3a91i/dKJKjiUp+dZaPrF9tBlkm2D8fUGqo2EwsvunTwLZy5Hsmt8M1HhHmmuZr1mjoMoWl/vatS3+R2Cfysoq2629ZIKOEim1xDUh5UXf595ug8JUu/FafXFRmCUHKu06nCNct70PsSKiG9t9KeFGnpsLqhIG8Qrye0gEat0A853slueNJ2Tkv/xYPB/a99MpnFX+lIumz1pJNF3KcwDCJsOSns0/yTgleI8cowwpjn5w079sIIdynDazFUZ8Pnz5uGxq+L1uA/SGRiXhNIATE1qNVl6yvmkqEiOWROuoi9ScBWc1VxBYjPt8vnCtUPojnMyIK8p+RKKig== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:49 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 12/39] dyndbg: handle [+T]:buf_name.flags grammar Date: Sun, 11 Feb 2024 00:49:42 +0100 Message-ID: <20240210235009.2405808-13-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790558091562538519 X-GMAIL-MSGID: 1790558091562538519 Add processing to handle the new [+T]:trace_name.flags grammar. The name provided sets selected callsites' trace-destinations: "0" - pr_debug()s are written to prdbg and devdbg trace events. name - pr_debug()s are written to named trace instance, if its already been open'd, else err. A user can provide trace destination name by following T flag with ":" and trace destination name, for example: echo "module thunderbolt =pT:tbt" > /dynamic_debug/control echo "module thunderbolt =lT:tbt.p" > /dynamic_debug/control Or user can provide only ":" and trace destination name, for example: echo "module thunderbolt =p:tbt" > /dynamic_debug/control echo "module thunderbolt =l:tbt.p" > /dynamic_debug/control In the former examples trace destination is set (":tbt") and write of pr_debug()s is enabled ("T"). In the latter examples only trace destination is set (":tbt") for later use. When T flag with argument is followed by other flag then the next flag has to be preceded with ".". When both T flag and ":" are provided together then ":" has to follow T flag in the form of "T:". Use of "." as a separator between flags allows a later patch to treat ',' as a space, which mostly eliminates the need to quote query/rules. And this in turn avoids quoting hassles: modprobe test_dynamic_debug dyndbg=class,D2_CORE,+p It is particularly good for passing boot-args into test-scripts. vng -p 4 -v \ -a test_dynamic_debug.dyndbg=class,D2_CORE,+p Signed-off-by: Łukasz Bartosik Co-developed-by: Jim Cromie Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 201 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 162 insertions(+), 39 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 6668f265f2c3..8a81356c52b3 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -72,6 +72,7 @@ struct ddebug_iter { struct flag_settings { unsigned int flags; unsigned int mask; + unsigned int trace_dst; }; #define DD_OPEN_CMD "open" @@ -84,11 +85,17 @@ struct dd_private_tracebuf { int use_cnt; }; +#define DST_NOT_SET (-1) + /* - * Trace destination value 0 is reserved for writing - * debug logs to trace events (prdbg, devdbg), that - * is why buf[0] is not used and we traverse bitmap - * starting from bit 1 (bit 0 is also not used). + * When trace is enabled (T flag is set) and trace destination field + * value is in range [1..63] then debug logs will be written to trace + * instance whose name is stored in buf[trace destination].name, e.g. + * when trace destination value is 2 and buf[2].name is set to tbt then + * debug logs will be written to /tracing/instances/tbt. + * On the other hand trace destination value 0 is reserved for writing + * debug logs to trace events (prdbg, devdbg), that is why buf[0] is not + * used and we traverse bitmap starting from bit 1 (bit 0 is also not used). */ struct dd_tracebuf_tbl_info { struct dd_private_tracebuf buf[TRACE_DST_LAST]; @@ -126,6 +133,81 @@ static inline unsigned int get_trace_dst(const struct _ddebug *desc) return desc->ctrl.trace_dst; } +static int find_tr_instance(const char *name) +{ + int idx = 1; + + for_each_set_bit_from(idx, trc_tbl.bmap, trc_tbl.bmap_size) + if (!strcmp(trc_tbl.buf[idx].name, name)) + return idx; + + return -ENOENT; +} + +static const +char *read_colon_args(const char *str, struct flag_settings *modifiers) +{ + int len, idx = 0; + char *end; + + /* Check if trace destination was already set */ + if (modifiers->trace_dst != DST_NOT_SET) + return NULL; + /* + * When both T flag and ':' are provided then the T flag + * has to be followed by ':' in the form of 'T:'. + */ + if (modifiers->flags & _DPRINTK_FLAGS_TRACE && + *(str-1) != 'T') + return NULL; + + if (strchr(str, 'T')) + return NULL; + + str++; + end = strchr(str, '.'); + if (end) { + len = end - str; + *end = '\0'; + } else + len = strlen(str); + len -= 1; + + /* destination trace events */ + if (!strcmp(str, DD_TR_EVENT)) + goto end; + + idx = find_tr_instance(str); + if (idx < 0) + return NULL; +end: + modifiers->trace_dst = idx; + return end ? end : str + len; +} + +/* + * Maximum number of characters which are being displayed when + * printing trace instance name, longer names are truncated + */ +#define FLAG_COLON_ARG_LEN 24 + +static char *show_colon_args(struct dd_ctrl *ctrl, char *p) +{ + int n, len = FLAG_COLON_ARG_LEN; + const char *str; + + str = !ctrl->trace_dst ? DD_TR_EVENT : + trc_tbl.buf[ctrl->trace_dst].name; + + n = snprintf(p, len, "%s", str); + if (n >= len) { + strscpy(&p[len-4], "...", 4); + n = len - 1; + } + + return n < 0 ? p : p + n; +} + /* Return the path relative to source root */ static inline const char *trim_prefix(const char *path) { @@ -137,9 +219,28 @@ static inline const char *trim_prefix(const char *path) return path + skip; } -static const struct { unsigned flag:8; char opt_char; } opt_array[] = { +typedef const char* (*read_flag_args_f)(const char *, struct flag_settings *); +typedef char* (*show_flag_args_f)(struct dd_ctrl *, char *); + +static const struct +{ + unsigned flag:8; + char opt_char; + bool always_show; + read_flag_args_f read_args; + show_flag_args_f show_args; +} opt_array[] = { { _DPRINTK_FLAGS_PRINTK, 'p' }, { _DPRINTK_FLAGS_TRACE, 'T' }, + /* + * We don't reserve a flag for ':'. The ':' is used to provide + * trace destination name and when provided together with T flag + * it enables output to the trace destination. When ':' is provided + * without T flag then it sets trace destination for a callsite for + * future use. When both T flag and ':'are provided together then + * ':' has to follow T flag in the form of 'T:'. + */ + { _DPRINTK_FLAGS_NONE, ':', true, read_colon_args, show_colon_args }, { _DPRINTK_FLAGS_INCL_MODNAME, 'm' }, { _DPRINTK_FLAGS_INCL_FUNCNAME, 'f' }, { _DPRINTK_FLAGS_INCL_SOURCENAME, 's' }, @@ -148,22 +249,31 @@ static const struct { unsigned flag:8; char opt_char; } opt_array[] = { { _DPRINTK_FLAGS_NONE, '_' }, }; -struct flagsbuf { char buf[ARRAY_SIZE(opt_array)+1]; }; +struct ctrlbuf { char buf[ARRAY_SIZE(opt_array)+FLAG_COLON_ARG_LEN+1]; }; /* format a string into buf[] which describes the _ddebug's flags */ -static char *ddebug_describe_flags(unsigned int flags, struct flagsbuf *fb) +static char *ddebug_describe_ctrl(struct dd_ctrl *ctrl, struct ctrlbuf *cb) { - char *p = fb->buf; + show_flag_args_f show_args = NULL; + char *p = cb->buf; int i; for (i = 0; i < ARRAY_SIZE(opt_array); ++i) - if (flags & opt_array[i].flag) + if (ctrl->flags & opt_array[i].flag || + opt_array[i].always_show) { + if (show_args) + *p++ = '.'; *p++ = opt_array[i].opt_char; - if (p == fb->buf) + show_args = opt_array[i].show_args; + if (show_args) + p = show_args(ctrl, p); + } + + if (p == cb->buf) *p++ = '_'; *p = '\0'; - return fb->buf; + return cb->buf; } #define vnpr_info(lvl, fmt, ...) \ @@ -221,17 +331,6 @@ static bool dd_good_trace_name(const char *str) return true; } -static int find_tr_instance(const char *name) -{ - int idx = 1; - - for_each_set_bit_from(idx, trc_tbl.bmap, trc_tbl.bmap_size) - if (!strcmp(trc_tbl.buf[idx].name, name)) - return idx; - - return -ENOENT; -} - static int handle_trace_open_cmd(const char *arg) { struct dd_private_tracebuf *buf; @@ -383,7 +482,7 @@ static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_table cons * Search the tables for _ddebug's which match the given `query' and * apply the `flags' and `mask' to them. Returns number of matching * callsites, normally the same as number of changes. If verbose, - * logs the changes. Takes ddebug_lock. + * logs the changes. */ static int ddebug_change(const struct ddebug_query *query, struct flag_settings *modifiers) @@ -391,13 +490,12 @@ static int ddebug_change(const struct ddebug_query *query, int i; struct ddebug_table *dt; unsigned int nfound = 0; + struct ctrlbuf cbuf, nbuf; struct dd_ctrl nctrl = {0}; - struct flagsbuf fbuf, nbuf; struct ddebug_class_map *map = NULL; int __outvar valid_class; /* search for matching ddebugs */ - mutex_lock(&ddebug_lock); list_for_each_entry(dt, &ddebug_tables, link) { /* match against the module name */ @@ -458,7 +556,8 @@ static int ddebug_change(const struct ddebug_query *query, nfound++; nctrl.flags = (get_flags(dp) & modifiers->mask) | modifiers->flags; - if (!memcmp(&nctrl, get_ctrl(dp), sizeof(struct dd_ctrl))) + nctrl.trace_dst = modifiers->trace_dst; + if (!memcmp(&nctrl, get_ctrl(dp), sizeof(nctrl))) continue; #ifdef CONFIG_JUMP_LABEL if (get_flags(dp) & _DPRINTK_FLAGS_ENABLED) { @@ -471,13 +570,12 @@ static int ddebug_change(const struct ddebug_query *query, v4pr_info("changed %s:%d [%s]%s %s => %s\n", trim_prefix(dp->filename), dp->lineno, dt->mod_name, dp->function, - ddebug_describe_flags(get_flags(dp), &fbuf), - ddebug_describe_flags(nctrl.flags, &nbuf)); + ddebug_describe_ctrl(&dp->ctrl, &cbuf), + ddebug_describe_ctrl(&nctrl, &nbuf)); update_tr_dst(dp, &nctrl); set_ctrl(dp, &nctrl); } } - mutex_unlock(&ddebug_lock); if (!nfound && verbose) pr_info("no matches for query\n"); @@ -698,6 +796,7 @@ static int ddebug_parse_query(char *words[], int nwords, */ static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers) { + read_flag_args_f read_args; int op, i; switch (*str) { @@ -716,6 +815,12 @@ static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers) for (i = ARRAY_SIZE(opt_array) - 1; i >= 0; i--) { if (*str == opt_array[i].opt_char) { modifiers->flags |= opt_array[i].flag; + read_args = opt_array[i].read_args; + if (read_args) { + str = read_args(str, modifiers); + if (!str) + return -EINVAL; + } break; } } @@ -724,7 +829,7 @@ static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers) return -EINVAL; } } - v3pr_info("flags=0x%x\n", modifiers->flags); + v3pr_info("flags=0x%x, trace_dest=0x%x\n", modifiers->flags, modifiers->trace_dst); /* calculate final flags, mask based upon op */ switch (op) { @@ -747,7 +852,7 @@ static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers) static int ddebug_exec_query(char *query_string, const char *modname) { - struct flag_settings modifiers = {}; + struct flag_settings modifiers = { .trace_dst = DST_NOT_SET }; struct ddebug_query query = {}; #define MAXWORDS 9 int nwords, nfound; @@ -763,20 +868,38 @@ static int ddebug_exec_query(char *query_string, const char *modname) if (is_dd_trace_cmd(words[0])) return ddebug_parse_cmd(words, nwords-1); - /* check flags 1st (last arg) so query is pairs of spec,val */ - if (ddebug_parse_flags(words[nwords-1], &modifiers)) { - pr_err("flags parse failed\n"); - return -EINVAL; - } if (ddebug_parse_query(words, nwords-1, &query, modname)) { pr_err("query parse failed\n"); return -EINVAL; } + + /* + * Both ddebug_parse_flags and ddebug_change have to be run + * with locking because ddebug_parse_flags->read_T_args verifies + * if a requested trace instance is opened. Next ddebug_change + * sets the requested trace instance as output for debug logs of + * callsite(s) which matched a query. Because ddebug_proc_write + * function can be called concurrently then without locking we + * could for example run into a scenario where ddebug_change uses + * a trace instance which is already closed. + */ + mutex_lock(&ddebug_lock); + + /* check flags 1st (last arg) so query is pairs of spec,val */ + if (ddebug_parse_flags(words[nwords-1], &modifiers)) { + pr_err("flags parse failed\n"); + goto err; + } + /* actually go and implement the change */ nfound = ddebug_change(&query, &modifiers); - vpr_info_dq(&query, nfound ? "applied" : "no-match"); + mutex_unlock(&ddebug_lock); + vpr_info_dq(&query, nfound ? "applied" : "no-match"); return nfound; +err: + mutex_unlock(&ddebug_lock); + return -EINVAL; } /* handle multiple queries in query string, continue on error, return @@ -1466,7 +1589,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p) { struct ddebug_iter *iter = m->private; struct _ddebug *dp = p; - struct flagsbuf flags; + struct ctrlbuf cbuf; char const *class; if (p == SEQ_START_TOKEN) { @@ -1478,7 +1601,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p) seq_printf(m, "%s:%u [%s]%s =%s \"", trim_prefix(dp->filename), dp->lineno, iter->table->mod_name, dp->function, - ddebug_describe_flags(get_flags(dp), &flags)); + ddebug_describe_ctrl(&dp->ctrl, &cbuf)); seq_escape_str(m, dp->format, ESCAPE_SPACE, "\t\r\n\""); seq_puts(m, "\""); From patchwork Sat Feb 10 23:49:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199337 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1701049dyd; Sat, 10 Feb 2024 15:54:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUqCh61btsUZJMoHnLgiyMlpTZyWElNyWp/LRAdscQ2dPq8u7WT2VSASSJAx7i1aWhBrWQ9wY/zPbT6xHj9IRx5LD+UPA== X-Google-Smtp-Source: AGHT+IG2jwi3nVLkvlNz1YVzmDFauJUFyNuXlv1u/wMpCdloLbF0jUBfZrceBUR+OZZpYqL0UKz/ X-Received: by 2002:a17:902:fc50:b0:1d7:7edb:e9b9 with SMTP id me16-20020a170902fc5000b001d77edbe9b9mr4265077plb.37.1707609259699; Sat, 10 Feb 2024 15:54:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609259; cv=pass; d=google.com; s=arc-20160816; b=DJkg11l2qJXn5k3Y+Af+ysxS1EQqS5yWYr5HWn1t/qoSKXqaS4sS3U4ODFjjKZaNds 2FnodAKlHm5tAWnhykbRjwdg4Ok6xJjPbdZYfPBCDHNZhPlM4Tl8k/9EcDnqSnrkpZMP dP0uzOFqcEOCkcvDqkDt9Jz9XL/OjB4daQMgkfMtUwddb7YER/d0pMlHRATZKUvxhmJL YGmj475RPTam/1/4PpG8SHPZ5ewHyBG1guNkGKkx+COTy9vXgW6YPD38S1ccFmePSoUo eRcIlihvRopF0ubztAq4tDouQUKe3znipkyF7VmZ0HUBrn6Jau/X6jeDP9r10btF2jcy XuCg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=EK4jXgQTQp2lbOreR5SqRb2MAnJAgwo9xsz57it33Vs=; fh=jK1DdXtN0SSTBwheC0TFYLNJC/fSwszuoIjLVn77ego=; b=lRL2xUTL/rn1TuJx3NdS3BB1lO105RBgY2KmOxwntfGHUhDI/Pv/p0j9WHyJDLKWgu QScCYh3v69x2bjZbx/lfpX6Z2qVxbtLHWVZPdWTHRa68oup5ftwSo6wCSDij2xJrcL+H OJrADmCImnPsii+Ikzuu5tD4DuYvJ9FkxNjGMenyvIwKLXifuVG5u9AdpG68/Rx3j6fr Q7syFi9RYg/ghMbzQlEcRBJxcE8sLFbw+IXnov1zygHUA+1QDdid0VMDofDsFxDM6CSG cs0dTtaYt79lC4w6Hc3EbTZjJTUWPQT1ecJZeiG9h1pt8L3RKmuY0jiTfl/kGOCdfEOA cO0A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=RPIx63a4; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60596-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60596-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCUOQz3iAqx4ZYkisIjBwPwQctBXbq3DoAEod9hTQ0mw59DM4+zrV8LNNny0tdNajRuicOT/2qhhspCDqhDbmO2uprs/jQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j14-20020a170903024e00b001d88f9c14a1si4199371plh.377.2024.02.10.15.54.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:54:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60596-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=RPIx63a4; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60596-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60596-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 44BD8281C1C for ; Sat, 10 Feb 2024 23:54:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AC0AE612D7; Sat, 10 Feb 2024 23:50:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="RPIx63a4" Received: from mail-lf1-f66.google.com (mail-lf1-f66.google.com [209.85.167.66]) (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 DEB1860DDE for ; Sat, 10 Feb 2024 23:50:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.66 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609055; cv=none; b=p8w+kqPb5+Ml4woWBwO3+vQLhI6DWd19TM4ozKJxo2I34tbDz34zJfi+ggIBaOYP75QEhgRZUi87bG/QJbTAoY1GXfD9i7Jee9mFFrniDVWqEAIZz2BQFWapHeUWsw5zCUhjeZaw8gBnI7ezkBac3y3hMUTJIrEfz2LQAFbBJEw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609055; c=relaxed/simple; bh=u2qVSn/FGDyWuMOo3N00MhELB4fJ8yoJ1hYXCFG65Mc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nfZQN9IfnQJdSEhWDVIDzql7sRKog9X2lrQGNPBNmDHb6WM1NeBrYHJf6F83XBymZcnbTJEb/zzHNL+59Kdf4odng80gBjgvvpZJG2Lc72WsFqT1zOOkCMH8UEWmkr+bn2UmtWsX9U45C7T3BqIJ3ut9xK7BF1wP9Fse0bdp61Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=RPIx63a4; arc=none smtp.client-ip=209.85.167.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f66.google.com with SMTP id 2adb3069b0e04-51185c33626so552146e87.0 for ; Sat, 10 Feb 2024 15:50:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609051; x=1708213851; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EK4jXgQTQp2lbOreR5SqRb2MAnJAgwo9xsz57it33Vs=; b=RPIx63a4o2BwKHCauRs0zajXqZzO05H87Cf197Aznr5wRPT9O11Fybmhyg29gUWolY YhutaMRuh+AfO3t5Uhrml1yY6WbA1DBPuJcz1y+QXqEMNzskS8fzZIyFHHWFIotVC3ex RTQ4rsOXdSE5Dr2mu5LW+YBu5PkdSbO4DATxI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609051; x=1708213851; 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=EK4jXgQTQp2lbOreR5SqRb2MAnJAgwo9xsz57it33Vs=; b=uwiqmM8j9Ntf3t0d4t+fSdrmiJyQdLq6CkKHCpGhe6nz4cMw+kEPGpVrmiec9aIcFl UTI70GeebWoDMfgYkTNkIBjN24ICQnTsmQxzpkEQ+uGS1qzr+sktaXVFJWncRziFCKbB hCELKDNgwkRQb6aNJoPNZzMcS2JkQm5r0CyFCgagygFpX7LquOLNgZJHxgegnQSdHHci SLnHY1K/7omhRI2R3vlfj7MuArHanrh1j7FqgC1Abn9iSUG5qaUidoQR7LWYEeOFWCra c15KH5vU1k65joiJe8z5/e4Js8v36CTFHdTkNcyH1JNnmwPMhCXhMb9GxBj4xs+vegWH T8tg== X-Forwarded-Encrypted: i=1; AJvYcCXl7K9UygliWZpjECmNXGU1a0ReNbQ9Tpe+q5M+rYZtlOgOXZQ42ajESlwnmK3AeGoNJBBWZZY4nbyuOahTO1zL4Z4pO/cdhsCEBj3P X-Gm-Message-State: AOJu0YzolMMSCgLU2vp5/sl8DKHHaymksmohi1jAI8u+ep/hYyU+9fJR v27owCWfEMLUNaX2iPXzUvsz3OJwzYTxDZFfn1v0ypERdiit+UuIUFq/kJ4y X-Received: by 2002:ac2:5dce:0:b0:511:6256:3b8d with SMTP id x14-20020ac25dce000000b0051162563b8dmr1861642lfq.5.1707609050996; Sat, 10 Feb 2024 15:50:50 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWz64HlI6AGfZ/sg9YFNQ4r9IRaz51l0COS2ktSKlNFhr7W0V+57It/68zPPZYOi3b+T58YayTS4SGlyBG2nUEe1Y21Sh8Bm0zI9Ha8QNRXWiywXUNoOKG9N2kk2sNiiqYyKuB2OxNEzcPftzzcsAWQbtVDX5duGKoxDPm74OqHlR7F1OU7IugwqXLroTdXyaGsPRxS08HfjuN5OsLMJAUy2baG3/pJmFxrtEVjTMoBrO0ackMCCE8PczEQM/dRT/sod0ZnpyQrnaxRmd5UcU/8EiWyY0FcAnFAreJ0WZOZlZIOOn+zIgy7k2XdoT00gSXbUnlFynhWTWYLnHMy8vEQOcneSeY9zJmqcI2bEDTz4p2yJwth2RC5648GHfWjc6IqsH03B1+7GZF9jBwZbWfD5M5b+nLxoIMQ3+97eEthTT6aS6jRXoz0gkiMuNz9eirm4heAEWkxcWSEgW/c7QVgvbRjhFyk/y5URbsZXHFSDHViwXIoXfdGo6KYYA7ZYm4jjaiw9v4BxpBrVFOeWqD+eF/zxISMwPR0mDJ8yb3yabnjEahZApNyoIVD1bDG/7xDgtBBwx8Q7NYgUbMyBHL1+EZiU7/Dg1kzXBGelg1+im5bFw== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:50 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 13/39] dyndbg: add support for default trace destination Date: Sun, 11 Feb 2024 00:49:43 +0100 Message-ID: <20240210235009.2405808-14-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790558087048633395 X-GMAIL-MSGID: 1790558087048633395 Instead of repeating trace destination name explicitly for each command (e.g. +T:thunderbolt), this change saves trace destination provided to last successful open command as default and consecutive commands which don't provide trace destination explicitly will use the saved trace destination. Signed-off-by: Łukasz Bartosik --- lib/dynamic_debug.c | 69 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 14 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 8a81356c52b3..f41b0b0c8b47 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -72,7 +72,7 @@ struct ddebug_iter { struct flag_settings { unsigned int flags; unsigned int mask; - unsigned int trace_dst; + int trace_dst; }; #define DD_OPEN_CMD "open" @@ -85,8 +85,6 @@ struct dd_private_tracebuf { int use_cnt; }; -#define DST_NOT_SET (-1) - /* * When trace is enabled (T flag is set) and trace destination field * value is in range [1..63] then debug logs will be written to trace @@ -101,6 +99,9 @@ struct dd_tracebuf_tbl_info { struct dd_private_tracebuf buf[TRACE_DST_LAST]; DECLARE_BITMAP(bmap, TRACE_DST_LAST); int bmap_size; +#define DST_NOT_SET (-1) +#define DST_TR_EVENT 0 + int default_dst; }; static DEFINE_MUTEX(ddebug_lock); @@ -111,7 +112,8 @@ MODULE_PARM_DESC(verbose, " dynamic_debug/control processing " "( 0 = off (default), 1 = module add/rm, 2 = >control summary, 3 = parsing, 4 = per-site changes)"); static struct -dd_tracebuf_tbl_info trc_tbl = { .bmap_size = TRACE_DST_LAST }; +dd_tracebuf_tbl_info trc_tbl = { .bmap_size = TRACE_DST_LAST, + .default_dst = DST_TR_EVENT, }; static inline struct dd_ctrl *get_ctrl(struct _ddebug *desc) { @@ -147,7 +149,7 @@ static int find_tr_instance(const char *name) static const char *read_colon_args(const char *str, struct flag_settings *modifiers) { - int len, idx = 0; + int len, idx = DST_TR_EVENT; char *end; /* Check if trace destination was already set */ @@ -331,6 +333,24 @@ static bool dd_good_trace_name(const char *str) return true; } +static const char *get_tr_default_dst_str(void) +{ + if (trc_tbl.default_dst == DST_TR_EVENT) + return DD_TR_EVENT; + else + return trc_tbl.buf[trc_tbl.default_dst].name; +} + +static void update_tr_default_dst(int trace_dst) +{ + if (trace_dst == trc_tbl.default_dst) + return; + + trc_tbl.default_dst = trace_dst; + v3pr_info("set default trace dst to idx=%d, name=%s\n", trace_dst, + get_tr_default_dst_str()); +} + static int handle_trace_open_cmd(const char *arg) { struct dd_private_tracebuf *buf; @@ -382,6 +402,7 @@ static int handle_trace_open_cmd(const char *arg) buf->use_cnt = 0; set_bit(idx, trc_tbl.bmap); v3pr_info("opened trace instance idx=%d, name=%s\n", idx, arg); + update_tr_default_dst(idx); end: mutex_unlock(&ddebug_lock); return ret; @@ -410,6 +431,13 @@ static int handle_trace_close_cmd(const char *arg) goto end; } + /* + * check if default trace instance is being closed, + * if yes then update default destination to '0' + */ + if (trc_tbl.default_dst == idx) + trc_tbl.default_dst = DST_TR_EVENT; + trace_array_put(buf->arr); /* * don't destroy trace instance but let user do it manually @@ -556,7 +584,8 @@ static int ddebug_change(const struct ddebug_query *query, nfound++; nctrl.flags = (get_flags(dp) & modifiers->mask) | modifiers->flags; - nctrl.trace_dst = modifiers->trace_dst; + nctrl.trace_dst = modifiers->trace_dst == DST_NOT_SET ? + get_trace_dst(dp) : modifiers->trace_dst; if (!memcmp(&nctrl, get_ctrl(dp), sizeof(nctrl))) continue; #ifdef CONFIG_JUMP_LABEL @@ -845,7 +874,13 @@ static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers) modifiers->flags = 0; break; } - v3pr_info("*flagsp=0x%x *maskp=0x%x\n", modifiers->flags, modifiers->mask); + + if (modifiers->flags & _DPRINTK_FLAGS_TRACE && + modifiers->trace_dst == DST_NOT_SET) + modifiers->trace_dst = trc_tbl.default_dst; + + v3pr_info("flags=0x%x mask=0x%x, trace_dest=0x%x\n", + modifiers->flags, modifiers->mask, modifiers->trace_dst); return 0; } @@ -1614,15 +1649,21 @@ static int ddebug_proc_show(struct seq_file *m, void *p) } seq_puts(m, "\n"); - if (ddebug_iter_is_last(iter) && - !bitmap_empty(trc_tbl.bmap, trc_tbl.bmap_size)) { - int idx = 1; + if (ddebug_iter_is_last(iter)) { seq_puts(m, "\n"); - seq_puts(m, "#: Opened trace instances:"); - for_each_set_bit_from(idx, trc_tbl.bmap, trc_tbl.bmap_size) - seq_printf(m, " %s", trc_tbl.buf[idx].name); - seq_puts(m, "\n"); + seq_printf(m, "#: Default trace destination: %s\n", + get_tr_default_dst_str()); + + if (!bitmap_empty(trc_tbl.bmap, trc_tbl.bmap_size)) { + int idx = 1; + + seq_puts(m, "\n"); + seq_puts(m, "#: Opened trace instances:"); + for_each_set_bit_from(idx, trc_tbl.bmap, trc_tbl.bmap_size) + seq_printf(m, " %s", trc_tbl.buf[idx].name); + seq_puts(m, "\n"); + } } return 0; From patchwork Sat Feb 10 23:49:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199336 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1701030dyd; Sat, 10 Feb 2024 15:54:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGDvjcescEWujlddGV9BfaHnFv7JC8tPj+4uo+Op4Llwu8pvpUIKJ2nevf2YJsPjlhvySW X-Received: by 2002:ac2:4189:0:b0:511:3bd4:6a97 with SMTP id z9-20020ac24189000000b005113bd46a97mr1751279lfh.7.1707609255476; Sat, 10 Feb 2024 15:54:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609255; cv=pass; d=google.com; s=arc-20160816; b=rdSWVozzRqNgWhcwiilX4SG3VM0InYrGXZ4iyBbP2vamCdGq+eQ1Hresid86YLTyhp CUs5HPlJVmRwr1yaUFNmKBIXL3+4LBB5W+wS1rxL/pijlJiSILSLV9GIUYxtfr2ebp4i HGRw335o3jXYpUPz+AbqfeqnuEOrXDza2BJk/e24PExCu2JgoZAgJyNNrpiDeyi8dMoj C9pq1fT93ey0mysVCX1A59ieC0sjpFtj9bKtHexnelfqaeEgDfPk7MSTHtB8i6KPAaTL i/sFsCiB1SILJfnrJv7bAKzlmRu/PKVkLYhnJKaLIB/n5t8KhgfGt92KC9Bb7yGEKl6d kMSg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=m0C7d9TR7oCLKiGX51PIEVgdXmMwdwdVpasUDDkUmDA=; fh=HgJFe1YARO9U4Hszhg0ENOJhooLguIS0MG7VQkhp15A=; b=cCIGdAqKlMmr9KbMZHkLBHgH2+UVM1aqcpZxd9e9bdngAOseqJBfjZ5WzmWACv58Or FoJXVHkdVu46pbsjcx0h4xlSXPoYqncmkPOLPDSeJWaoylq0GRvqq9t/PV4YU+Cvds/0 CY4k4LLfPEXx8ouOfiTpMm5GzYfu9pEXpfWQh84MQDtEQ49yQhrQBSUNWl0zqEE0PWYV g/O8c4pQfxsVWaVFtrRtMvy30l4ZLbeLx2YYv5JKaEUJVW5JDquwoN+Ms/r4hfBciA3w gt1fh0kkDvGaKHTd0YTPFKoX9Xaq4EqChG8UCcy1PLzretYLPFo/CEXsrs16zj9qVJvl hWeQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=P0YfpGtR; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60597-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60597-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCU3t0eYosTpFkAt0VJBzWmurKgY38ZkQO+H9Skw20DT3gJdxYLOpzVosNd+K4TaTXzhaELevVRobAquU6Yz+6rrvdcgfA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id rs10-20020a170907036a00b00a389a9f49f1si2386420ejb.660.2024.02.10.15.54.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:54:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60597-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=P0YfpGtR; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60597-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60597-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id E331F1F21921 for ; Sat, 10 Feb 2024 23:54:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5BC18612EB; Sat, 10 Feb 2024 23:50:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="P0YfpGtR" Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (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 9831060DD8 for ; Sat, 10 Feb 2024 23:50:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609056; cv=none; b=LICE+LxI1DtWCo7H0vYfSFlhZAY/n1/UUXyQ+cKcQLqr/9LEOzgq+Ljex2j9NoM5K7bl+nNQY32r1BXl/qAIw/EDiN48EpjGrjaGHhBY85SrX6Gk6493uj+C+wKy/QaERXQvIKbTDcVbE8Z/VaDsLiXa6js/Vu2Xub3GztsrCIw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609056; c=relaxed/simple; bh=svE0ydmRhksE61Jfxvr6jlgMjC0XYATtTVPi+1xPOKE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UMj1Exgd72kIgQ1WIDXDErtx9Eg9KfC4wX0EZKaZ2gCkoJc3AvFTp4ZklyARPxZcr4xs8G9QLQFxogQ2P+NUP11ft0yAfcL4p3EMUC4sSkXaw3TjMb5rJGEvn6mm5a6xu1Ou06uhXcu4/kKYLLw7JK5RLAz+yF76+LBslgkIOGI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=P0YfpGtR; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-5116b017503so2861643e87.1 for ; Sat, 10 Feb 2024 15:50:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609052; x=1708213852; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m0C7d9TR7oCLKiGX51PIEVgdXmMwdwdVpasUDDkUmDA=; b=P0YfpGtR2+eCi0IIqVbftRscTbJjJy9hrTF50DkXLhGDGBB8vXd2gzdGHxvwpq4ToS q3DcKqQhXCgHCKy77xnV10SoTTpvfB1PXBWeyimoyvLmmAezJNEJlW0loNLHzajq5hyl b3zwJ5zmuVuxYE5qPUr7eB/XBofXzUC5xHMr4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609052; x=1708213852; 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=m0C7d9TR7oCLKiGX51PIEVgdXmMwdwdVpasUDDkUmDA=; b=ZXhV42CfC/una1z/IIdLmX9NtpH19g664nNPbmvTS60dmfjTWmnD29zKmBgvf3gy2C Xz8IP8NjK2qidh5fwaEscRPvko4E3QUvfWPSpOqLlputyvYPpcwK1MMCOBqnZQcJyqcs Vm/tgjxfDEEXmB2exJgn5+Vx2C6u/HtISQuJjQ8fFeOFnJkQ1g+74ua2t8kj0fbC2HiH kI3nBV6seJ5wlz7fwlEmZF7N9Ew2YjmaMqT/KYEupIYYErEd0zkaTjXae5jrx9qUoxyU FexfifUN9ZaF8vtUVSWwUXlLQCHcfXC8EM+huYQSHsYiijpQ9wbebQU/jwK2+C1ohvB6 3FAw== X-Gm-Message-State: AOJu0YzvresigdUUC1aNpW+/bH923tfwQsSZQCuKcB1THY04OjA/7CbW wIJbcPpQXoPhBK3qPLWmzJD8OSYt6cLwLGZ5LfoUDGKeBUG2DhK2Hw38ldyS X-Received: by 2002:ac2:5dc8:0:b0:511:62ab:5f03 with SMTP id x8-20020ac25dc8000000b0051162ab5f03mr1878907lfq.60.1707609052801; Sat, 10 Feb 2024 15:50:52 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWfdpieG7Xq0wJgEwvOp+MkQV8u/MwIyUikMGTNVVNK+dwp70vbTGfyuvR/QCLrvUxKN+egISXAcQRkIktfSY9x02li3nO+Dwlg91zKlh2LiY4awAbjA35s4xGLTsTJEZbZ4VfNHcstvRhRKHv1BmtBIWQx52FEDhNHxH7RqkhP5KOiEqGxzzKaIlovMvMkP+2clrjrnab/+TshTe0O6uT9G1FYmSRycqbWUwFmvSQmxXZVwtx8pBRi+rQGxtyT5yu4ksJ8Aj+zacXk7OU6VOgz6UFc+HC6klD7wtgOrSrFr0rBqPfXXoaC4rQeaKibU4+bnyahEvFkgoOJM61CzUqetuejAP0EQvH+iX7l/UuDlHYoUx7B1J72ndUNEGNtiUmDYbao2iG9+ibQF5RLGXzQnbZsYR5b3ZtRXDl39hdFtNfb6O/Pek8c0w9I9kvMMMDO5QLY4cNTWbZ7wf++Zh77gPd3LNye+3H/0gZUbgNs6/mzmkQ6LTD17bYozOMTJW2HPSYY/cuxfREu78CGiBqM3O9dVWdPYbH/6e1jvHD54Hj0CA1zXj+WNj3hP3KzBWk3cdPt6xTT+N+MqHZRUXz+/dXuq2xnnwoeax6k/NYcmpkAig== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:52 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 14/39] dyndbg: update default trace destination on reopen Date: Sun, 11 Feb 2024 00:49:44 +0100 Message-ID: <20240210235009.2405808-15-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790558082913212335 X-GMAIL-MSGID: 1790558082913212335 The change updates default trace destination when a user requests to open '0' ('0' writes debug logs to global trace-events buffer /sys/kernel/tracing/trace) or open an already opened trace instance. Signed-off-by: Łukasz Bartosik --- lib/dynamic_debug.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index f41b0b0c8b47..f91c51234456 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -354,10 +354,21 @@ static void update_tr_default_dst(int trace_dst) static int handle_trace_open_cmd(const char *arg) { struct dd_private_tracebuf *buf; - int idx, ret = 0; + int idx = 0, ret = 0; mutex_lock(&ddebug_lock); + /* + * request to open '0' or an already opened trace instance + * results in update of default trace destination + */ + if (!strcmp(arg, DD_TR_EVENT)) + goto update; + + idx = find_tr_instance(arg); + if (idx >= 0) + goto update; + /* bit 0 is not used, reserved for trace prdbg and devdbg events */ idx = find_next_zero_bit(trc_tbl.bmap, trc_tbl.bmap_size, 1); if (idx == trc_tbl.bmap_size) { @@ -371,12 +382,6 @@ static int handle_trace_open_cmd(const char *arg) goto end; } - if (find_tr_instance(arg) >= 0) { - pr_err("instance is already opened name:%s\n", arg); - ret = -EEXIST; - goto end; - } - buf = &trc_tbl.buf[idx]; buf->name = kstrdup(arg, GFP_KERNEL); if (!buf->name) { @@ -402,6 +407,7 @@ static int handle_trace_open_cmd(const char *arg) buf->use_cnt = 0; set_bit(idx, trc_tbl.bmap); v3pr_info("opened trace instance idx=%d, name=%s\n", idx, arg); +update: update_tr_default_dst(idx); end: mutex_unlock(&ddebug_lock); From patchwork Sat Feb 10 23:49:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199339 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1701108dyd; Sat, 10 Feb 2024 15:54:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHiYoteS9py5S16D4b25aTzPgmAVQb6CJwTwUmCtTJQyaHQNK4yR6pLqwjP35PF7eyPaZVt X-Received: by 2002:a05:6512:400c:b0:511:3b8b:6eb2 with SMTP id br12-20020a056512400c00b005113b8b6eb2mr2555241lfb.42.1707609271338; Sat, 10 Feb 2024 15:54:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609271; cv=pass; d=google.com; s=arc-20160816; b=HIQTHfVmspHZ7YK5npPfnOg0HdD7Lq9LuvMc1b5kd0sCuOwfN3sylldebah1eALekW 7KaKK3RUKU4r+ednfV0L90ltEVKLSYmw68rh9s/zmpnByNRfQAx4HjEUPq1ae8T07obh 7IvEVHcrdFJYmhilu6MZ9ixqqAQTRFvRmVIIaOMfh2NHNTBwLBIPm4copymDErcqVa+G TSbkoIhGe8KrnNBHzWNxu9Mxydz7Z+Ms8N4R+8thmINjgB5Jhyz3GSrq1hCGU1S0X9vV iUwXLYNYKjrC9b5VScpA7d+OlFI7JH66qkMM0QNv5qqPlXpR64PIWWox7+mpshQUQoLk nqwQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=lhSJOrwG0vPx3/FWw5xBrBZ2OkHe0Kqn1x7V968tGh8=; fh=HARV2pM79Op9paiNT75NAZQC67dvtNmyh0xZNTuFYbg=; b=Ve+k9xQ0JVpcwq9tclg3EDz2ouC03KfMFYgngmz/h0Eot6UypaAFGOTp8N4bB8I/Fm vqF9yx/APbRDvCdwkgIQMDBTvSkPT1gUQZJ8lCupBzCjtALn6qMIOigzLAxMtbPs4WOF msswViSelnWNiEMLnvqmVLAqtdNVIrY0hzKQpVmjvbJ+2WSlDtJZhV+uX1T0BqtfOdwa 7jprIPhfqNZ9UnRZ6kIdfr0F/Q5pglLIa2V/cQKlwBwGq3quAr1hP14Z5hHPBV3DI8iK LpVVD6AI/onPh8hiCEjDfxPFyxfVnoyLfAQlhK7ylc8iNSomxlgizeXJHu0oijaL1B0v V8xQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FEuo4wYp; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60598-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60598-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCWsno7hMFh8O5OMpj4lvyrhTAxiqBncBg/Ac+HPuIyJpv8FoZyqER/zdwVUt2biknSUPpF3yHJRS4NJJUSBcNavaRDNXg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id fx25-20020a170906b75900b00a3adef2e240si2326539ejb.360.2024.02.10.15.54.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:54:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60598-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FEuo4wYp; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60598-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60598-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id B545A1F2134B for ; Sat, 10 Feb 2024 23:54:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 249E56166B; Sat, 10 Feb 2024 23:51:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="FEuo4wYp" Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) (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 2E70760ED8 for ; Sat, 10 Feb 2024 23:50:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609057; cv=none; b=TX2LhWQ3lZbVgCBPhX88m8ILwAAjVac9oz5x64CHnfAfJ9qGl1cZHxkSAsHLuGPLkVa/Cdyk3qo2VT/8YROZbdUe9jvU+z1PRHlgiP8rcOxQFal5yeZ9/w9TGkYo32Lh2uesW7CcJkJ5/eQLuCdgMeTRk/dB6t9UTcGSu+fz5q4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609057; c=relaxed/simple; bh=ohE6vU5kodAgmE00a94Fey2CKuwVGGZlFNzAOgDt1Ro=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=J2OWdD0ymtW0Oecbh65ZvhkuagMFeT/nb1zpVH0ee1+zIUdOVCn2+EAH3u8HEP+zQHWaqVgrYZPqmI9tA18V3IUZYNX0UPFMk89Uy2JISiu4XrUAyy2JRIYqaNF2fW/pYDZaL/4rlU4bYBCCGRxinj0k89il5l93Edckg92BntQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=FEuo4wYp; arc=none smtp.client-ip=209.85.167.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f65.google.com with SMTP id 2adb3069b0e04-51167e470f7so2650927e87.2 for ; Sat, 10 Feb 2024 15:50:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609054; x=1708213854; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lhSJOrwG0vPx3/FWw5xBrBZ2OkHe0Kqn1x7V968tGh8=; b=FEuo4wYpS8rla2cWJKPp6UE+l+B9u8gvZxjSDlRiDTuWeW6OgPIn0R4nY3Cb8uHKXz UJGlrg8CVeHH3PapjJcDzL0qTss4+4D4I6bxPPLByBAbxRIqgFi38ptVWH2LnFETxvEB 3xb/g8fZShy9CBDcTSlc5lhB7dWlP6yNF0Gw8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609054; x=1708213854; 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=lhSJOrwG0vPx3/FWw5xBrBZ2OkHe0Kqn1x7V968tGh8=; b=VxK6WyqiGMjIyrT0laExWD/0KJ/plncE43mIyE1A5663flwVbpTV4T4ul2bpgDw7z4 dyQLP1ngvae6diZMoDhR8npSRKIC/eC8iE938fEL/zoO3VCOxd/BcW0RVuH1bylZAV/s wWqczo9vLngQaWarnWnn704aODYyvAkdgAKOxhajT/5ySoaF8ZiaTOfrvEWDHI5ANehU 4HmCo5Amgjcsc3xOX1/SY8Axo5hBC3/hxpEZMjUHSMbPEs28PpA6y9rk04S7LTDV0o5B KJXDUr+GALU9jcP77HrNUF/KTg6gda2uoIG0gnUC5GWGPDt274TKM1jSfw0oAWVa7ATe 8bQw== X-Gm-Message-State: AOJu0Yx9Xd7/+jFSzTzhdjRrHJGQhs/3JjTgiofFlyX+4rNzMqm8okEj WN5VLr/Nk9jrIwNkCOdySR/8MKZbk99dMY2QHFQD0bEgymkg2S88YNtaMmkm X-Received: by 2002:a05:6512:3f7:b0:511:8697:c66a with SMTP id n23-20020a05651203f700b005118697c66amr741665lfq.31.1707609054364; Sat, 10 Feb 2024 15:50:54 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWjjmGHSLBbQRDcbxOiGOhju/B6TdFQLxsbySRXM0XJrf6IuBtPEYUoAyCJRsZuLnU7z5N0XkTmoXGNIU8rd1qCHUIICWd36lpwMMMTdFUURd9HXm7PE5jZUE9Wx7I55RAYsBoURRS/W//1kRudDG7P4HM87sWZcAVUd50kYCXRVxZHh2TmhYQR1s9SRAt+/VEAg8bGBj6wwl6GmMKkZTBUTfgjj8L+le0lQ3v819uY5fIUcQnHBK0lT/60BddaYVyZnhtlghfx+Bs4rLDgfi1N88gtJO9Tkx6YIhBVs7sfX3MaEXehzTHyCdOxZ4xXi38lrYwAqKNq8fCGaRbrS6DmSZ7pLr9bKU6PxttxHRJ6j9dcExuPuvxeUKmiQfKly8mzwtUEMOWe2R8dcWuSChVA3jZmP9OmOagWGyab7CzMOD7WfxEoRUa7Lv21gmgM/uqwN12epL/6kvVJ8Avz+0OvQZVqhJKCRUV86Njn3M5eFsj8g08iQaSNcVcOx4A2lyMOWAdeSqI17oJ26LUzWUfXzonfR+V7QR1nrT4ubGCX6jrElNaX9t+SFwcxaHnvgCZ2RzTn6qMigZsvUxZq9lNjqZfMUFrzc8zxZ5ki+G3PjACF2Q== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:54 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 15/39] dyndbg: update selection of trace destination Date: Sun, 11 Feb 2024 00:49:45 +0100 Message-ID: <20240210235009.2405808-16-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790558099569460101 X-GMAIL-MSGID: 1790558099569460101 If callsite's current trace destination is '0' and user provided T flag without trace destination name then set callsite's trace destination to default trace destination. If a user provided trace destination name :trace_dest_name with or without T flag then set callsite's trace destination to the provided name. Otherwise keep callsite's current trace destination. The change main purpose is to preserve trace destination names (different from '0') set previously by a user which can be later enabled with 'label' keyword. Signed-off-by: Łukasz Bartosik --- lib/dynamic_debug.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index f91c51234456..172497954e00 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -480,6 +480,27 @@ void update_tr_dst(const struct _ddebug *desc, const struct dd_ctrl *nctrl) trc_tbl.buf[ndst].use_cnt++; } + +/* + * Selects trace destination. If callsite's current trace destination is '0' + * and user provided T flag without trace destination name then set callsite's + * trace destination to default trace destination. If a user provided trace + * destination name :trace_dest_name with or without T flag then set callsite's + * trace destination to the provided name. Otherwise keep callsite's current + * trace destination. + */ +static int select_tr_dst(struct flag_settings *modifiers, int cur_dst) +{ + if (!cur_dst && modifiers->flags & _DPRINTK_FLAGS_TRACE && + modifiers->trace_dst == DST_NOT_SET) + return trc_tbl.default_dst; + + if (modifiers->trace_dst >= 0) + return modifiers->trace_dst; + + return cur_dst; +} + static int ddebug_parse_cmd(char *words[], int nwords) { if (nwords != 1) @@ -590,8 +611,7 @@ static int ddebug_change(const struct ddebug_query *query, nfound++; nctrl.flags = (get_flags(dp) & modifiers->mask) | modifiers->flags; - nctrl.trace_dst = modifiers->trace_dst == DST_NOT_SET ? - get_trace_dst(dp) : modifiers->trace_dst; + nctrl.trace_dst = select_tr_dst(modifiers, get_trace_dst(dp)); if (!memcmp(&nctrl, get_ctrl(dp), sizeof(nctrl))) continue; #ifdef CONFIG_JUMP_LABEL @@ -881,10 +901,6 @@ static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers) break; } - if (modifiers->flags & _DPRINTK_FLAGS_TRACE && - modifiers->trace_dst == DST_NOT_SET) - modifiers->trace_dst = trc_tbl.default_dst; - v3pr_info("flags=0x%x mask=0x%x, trace_dest=0x%x\n", modifiers->flags, modifiers->mask, modifiers->trace_dst); From patchwork Sat Feb 10 23:49:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199340 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1701167dyd; Sat, 10 Feb 2024 15:54:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWB7GhtfEYQWN0wDiQRebohuR2wYTEtyXP88J0LgarU4y12YvSdohIAJBxDe0ovFAPqm3N0OengoVpZY3YsOADXIXJ2zw== X-Google-Smtp-Source: AGHT+IEJunElHmlIromHlkUVjI+9AbixmP2M9YG3QTvb/ocJ6ow2C0ETy5SVhcpjKynMJcFlFSRH X-Received: by 2002:a2e:7a15:0:b0:2d0:ab46:77db with SMTP id v21-20020a2e7a15000000b002d0ab4677dbmr1958819ljc.50.1707609285853; Sat, 10 Feb 2024 15:54:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609285; cv=pass; d=google.com; s=arc-20160816; b=Kk/Wi9cWFqyfzHSwM+mrEkzPrdKmGX/899F/9r50offpHGejh2jbfZ4iasPUDvSeGs HHd1FB96B/1OgeQDJF/p3w7aHDHKViSBAkXUDCxuE7p4aJgw2bQNkXWlL7hvgbYNJJf+ TTw/vcSnTapzWordU4LKaVLcjIOtlvDQY4AkEjHEYJENE179CWFstrON1PIX6JX2Z0cj gSDnUXb/Rrh6Lr2Xf6Q5iPi6YuYIhl4XL1IrgCZaV/lUf23GbLD49/m8i9Mp5VW0hmth NnaiOSV0+ngpWW6ZRAZ+buagZ4/QqMKoGf1LBbBxw+2QSv2SpWmVcHR77ITJ93pnwYq3 /wjw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=+meeM2Vk6l0WdNE3+wNvpjDW7+uOCSnCzAIE4DVZl4I=; fh=5qX9tBI039k5WvR0aiSAj7ygE0PnkcqoA7gQMXHCBnk=; b=XxMsxsaViS6iUf9l8FEqWGhpWeeJ8LCYaE1XT9U6FBVO+p4icIi21Fo+kwC4fRiTMY iXcVD8NyqDr9WbB+bWJM1njPCW1rVk9iHjNC+ea6dMpLMxPIlDEdsmJW/Z0iT4TkbY0i EWdBpyMd4NlnyFL0ADSHtM5KlIWDVsuCSRIHxhdntxOuBgRevWxgm4ysZ7k4PF/K+JCE ITwXOQQlbhCdf6TNB5iSO/IaMIpfB2Y7+hXdMUerVtounRkfpFufsIUdIDifP0GPdwGk 9fX4Mdq9UEcikik/ps9HGQoWIkoDUDkBcOQx+iufwtSGptgSYg0RQD66z0+2JzSkwC4H tIUA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Maz/Aw+f"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60599-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60599-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCXspL6OElP8V77vDY/u8TZkg12Umc/YBtm2Y6Zw5hHih4VJpA20oFQhzRPer+T2gAhOWsnluIYmO23jPwKUodnhlRHNlA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y8-20020aa7d508000000b005601f742708si1215817edq.415.2024.02.10.15.54.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:54:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60599-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="Maz/Aw+f"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60599-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60599-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 48BBB1F214C3 for ; Sat, 10 Feb 2024 23:54:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E48CF6169E; Sat, 10 Feb 2024 23:51:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Maz/Aw+f" Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (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 C39DC60EFF for ; Sat, 10 Feb 2024 23:50:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609059; cv=none; b=C4lw047jrvxR/1qAiBdFo8S8e8mIXLBW691IVrduJiMe31BndE8VB00KrMfExH8adcsR2UgFarwNtTGm9mOpWto2v4AFn3D6Zthp2F2DfdY5u55xRPEkxkx5S1evMDhWqXN7AnY3JYyIKnJhJvV/SA8wMdNoEXR+ap07Krg1DnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609059; c=relaxed/simple; bh=l1V9QLXGLN9N14rao8E4GzprXYURIUrk6mdW5/cLkEg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pyOLM2rqH1TJQw5k+uCirWZNRO9727oghulxwT6GyJWGeTTaBcrp8fTkE13afppxw6x+c2AWMiUIe08n6fUZI9IkyJx1qd3OiCS2RnbUCzo3NAjrJX76omtQH+58veKrF7y+Vx09RxHQ4q8lP4QAhB0r98886cGJFDfDEjnEFk8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=Maz/Aw+f; arc=none smtp.client-ip=209.85.167.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-51032058f17so2603074e87.3 for ; Sat, 10 Feb 2024 15:50:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609056; x=1708213856; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+meeM2Vk6l0WdNE3+wNvpjDW7+uOCSnCzAIE4DVZl4I=; b=Maz/Aw+f+MtIWMO3kXDK86OaiWrIskcdmUC4785M7ShoVh3YeuZ1I+V0XpDcxDAoc4 GV7lx6xZV3fwC9i0/CUkpzc567m6INWWTp8gjHgd9BHcWbDxmccrSFnmt0xpPiw+7f7I whMbbAaaf0h8Qt8oVwstoROutq9aCnw75wXDI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609056; x=1708213856; 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=+meeM2Vk6l0WdNE3+wNvpjDW7+uOCSnCzAIE4DVZl4I=; b=Ncg2XPxwVLR7WUFKiXazOHs2XUBcpqM24ia4XzxWNjeRG80Y1fA1AZm4ns4FZ9nsbq OIFi3/EfDNmlVy9jC6wvhOMYhXG4HnbZr8jkFyaIXA3+6Pvdhg1A8mCujrmrIfHGfBuH 04R8yDfJubZANpdr3afSwAF6erbaVZ6NmydxAufW57mVE8c5v5Q7WsrgH+qTwz8cucDc 0+FERDJ80h2zwc8IZ4NighDG+PsQkBXpUHFgFiu5J5x05HNaoYNY0CrcaAI3pnTWHcVw b1E2jqprlQZqCmdNcHrPsinCVl55sxYCtqkwurY6DUGh/rtyR5ANMzwPDpv0fgGTkhlJ SsUQ== X-Forwarded-Encrypted: i=1; AJvYcCUwOhkOR37sqTL33iKXpBpBYi2yaSX1IdJ2QCANXzmrG11FwJkFM79Hn5RaHWieVnPsSlIm8i2CDwBFj7EmmEL25SyIOYDGjnq8cHql X-Gm-Message-State: AOJu0YyKp6dHFPl52CssX0WlN/LORfbW3I8TsPlj2mP3Z6EAvRhSgQJY 1A7i4aflyTZTNAQQl8FaKP8DMec4RY3+18R2sRaooeivYv2xPErscPwasZIX X-Received: by 2002:a19:2d47:0:b0:511:49f8:b42f with SMTP id t7-20020a192d47000000b0051149f8b42fmr2044506lft.8.1707609055904; Sat, 10 Feb 2024 15:50:55 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXWzrYynI29zRZZDkdrYySf/qdUsSiTQf0Ck0ApIde4uN+FCjcPut2uLF3xYRFs+ELUnxwYHdYIGi416Vdua3k0Ang9Rm43hnz+3INTmLm8vt6zzQEbYliq4yyxib6UA/MhQrC+JdRDVVSI0x8KY53x0inOi4frTEz0gusZuefCd1zk2bSxsWDJH1xWbd5Fu/hs/p31kzf5Er82S7O4HNPcFGqUbXrpbeR12TxEvmiS6v7vSkYuYj1xOJX1rbWg/Mn+vzv9Z1fQfPIujUjkFdsUS1HpJ3tG1whBCAsPO9p6AsO4nW6bC/alYxI+Sy860j61y9czCyCL07H2etcmaZcDX0ZoLmjiW/0WR8pjJds8hIm/lAD+vMbAUmzvKdYzO7+Pj9A//WhNbz33cWHxpwXk5Mqs/uhGObCYxQsaw/SqtKEovYJl6wd7/eAu3FGznt5Hi5eLkM27/g7ITHwAGDdsgu1fw21CG9VfQ27ul2u7ajQoS/5j/oWghvBMszYJGLZEj0PEu7/d06hCOuIscCdzcBDgeTrdKmFHzL6BfuJ2fAXTnE3a0w/OfHmcTE6uKM5HLT91dqxcVaTBMjDuZaw82o1kUUDKd2OsMkjZxeAW1gNxTg== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:55 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 16/39] dyndbg: write debug logs to trace instance Date: Sun, 11 Feb 2024 00:49:46 +0100 Message-ID: <20240210235009.2405808-17-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790558114418958677 X-GMAIL-MSGID: 1790558114418958677 When trace is enabled (T flag is set) and trace destination field value is in range [1..63] (value 0 is reserved for writing debug logs to trace prdbg and devdbg events) then debug logs will be written to trace instance whose name is stored in buf[trace destination].name, e.g. when trace destination value is 2 and buf[2].name is set to tbt then debug logs will be written to /tracing/instances/tbt. Before using trace instance as a destination for writing debug logs it has to be explicitly opened with open command. Signed-off-by: Łukasz Bartosik --- lib/dynamic_debug.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 172497954e00..d379e05837be 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1278,8 +1278,8 @@ static DEFINE_PER_CPU(struct ddebug_trace_bufs, ddebug_trace_bufs); static DEFINE_PER_CPU(int, ddebug_trace_reserve); __printf(3, 0) -static void ddebug_trace(struct _ddebug *desc, const struct device *dev, - const char *fmt, va_list args) +static void ddebug_trace_event(struct _ddebug *desc, const struct device *dev, + const char *fmt, va_list args) { struct ddebug_trace_buf *buf; int bufidx; @@ -1310,6 +1310,18 @@ static void ddebug_trace(struct _ddebug *desc, const struct device *dev, preempt_enable_notrace(); } +__printf(2, 0) +static void ddebug_trace_instance(struct _ddebug *desc, const char *fmt, + va_list * args) +{ + struct va_format vaf = { .fmt = fmt, .va = args}; + struct trace_array *arr = trc_tbl.buf[get_trace_dst(desc)].arr; + + WARN_ON_ONCE(!arr); + + trace_array_printk(arr, 0, "%pV", &vaf); +} + __printf(2, 3) static void ddebug_printk(struct _ddebug *desc, const char *fmt, ...) { @@ -1322,7 +1334,12 @@ static void ddebug_printk(struct _ddebug *desc, const char *fmt, ...) * All callers include the KERN_DEBUG prefix to keep the * vprintk case simple; strip it out for tracing. */ - ddebug_trace(desc, NULL, fmt + strlen(KERN_DEBUG), args); + if (!get_trace_dst(desc)) + ddebug_trace_event(desc, NULL, + fmt + strlen(KERN_DEBUG), args); + else + ddebug_trace_instance(desc, fmt + strlen(KERN_DEBUG), + &args); va_end(args); } @@ -1344,7 +1361,10 @@ static void ddebug_dev_printk(struct _ddebug *desc, const struct device *dev, va_list args; va_start(args, fmt); - ddebug_trace(desc, dev, fmt, args); + if (!get_trace_dst(desc)) + ddebug_trace_event(desc, dev, fmt, args); + else + ddebug_trace_instance(desc, fmt, &args); va_end(args); } From patchwork Sat Feb 10 23:49:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199341 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1701221dyd; Sat, 10 Feb 2024 15:55:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IHi/VDx4aooB3HAiUp6Y3YWEAv5+T0Rvnxc+TZKXCSuMb1Zx60/7YIdac6nRVikHywlkN6F X-Received: by 2002:a05:6402:c03:b0:561:998b:878f with SMTP id co3-20020a0564020c0300b00561998b878fmr102068edb.16.1707609304301; Sat, 10 Feb 2024 15:55:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609304; cv=pass; d=google.com; s=arc-20160816; b=WH9ZQ9PtL8q3Is1RSOQAcdaSkh5bUQjW95XAghgGQB3TuXlh1Vvx6Nq6vsvWZMHIJP 90lzfw8wC36fRJQ10EIk1IXjGyIGruM9kYGwE0IoT7Ihr1FNQoyrwyj7BRyLeuHBuJXX PN91phEJ0WeCHht3EaFM9pbmfaqP0sZtE85nY6D9rLtBaeEF6czkgQZceEN6NnIIekej OutrS8Kj/5ds9mQHloEw8y0rVGHiV0Fz8ZIDd+BZ/TXLEIqQU2uk6r/2rWtDfpfm1qCc e+FE9dzeNzD6PIYEMYMv+jJ4DjNZel9GwBYRHNp1OVpUNpiptMTGBV9l7DtD37CImwRO n+NA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=GcUhkZrXlF5pRwcMyaOQX2HOmfuyNRPW8LUolF8mADY=; fh=ejf5IFup4zu7PrZ8M0FHyAcUCWMQGMvAdoP67OO7Oi8=; b=CgYuV4AJMj9G7G6SGbri5+DzI9DBI0lTKdANTrqrm6GUGRCGqrYpd5ONmOH13xn2AV 7d4bxiYIBtZSMT9Htvit3DPP6LLjYgHrjqpNyy/6T5rUA45IX/gljNU9xPwBphtPTuXb HRB3qIHFcusaLw/hAXufyfnh9Aqva6nvWKGh3B/3ALu74uNhpvqe+ORmKMT31ov42BaX Gooa6dmhJTV8ddzTHTyUA4SlIBvIDyXeE2JXby9VAXA2HWuT1GPEJ1BlEdPhAyyQG3rm EXr+8PAnI1aQHvGb8ERk1z/MBpJ9W20IZFuPXIpT7iBC6kusFVI80x+htmTj23+cLMAR hsOg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CPIYffui; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60600-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60600-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCWcug1pkFCzjU+oKIKu2+HlMTXFF+214eriOjn4aJzlJ+5izMIANtLvreDUz5UBvwETFv55+HGdGWCHz6PREWZn56En6A== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id r10-20020a05640251ca00b005619ccb4bddsi6568edd.612.2024.02.10.15.55.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:55:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60600-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CPIYffui; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60600-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60600-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id BA47D1F21B8C for ; Sat, 10 Feb 2024 23:55:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C004F6216A; Sat, 10 Feb 2024 23:51:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="CPIYffui" Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (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 70B6C612EE for ; Sat, 10 Feb 2024 23:50:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609061; cv=none; b=WlJjYXNwHQ5W2orhEPZ3FT22FWNrKBHGq5ggegtq9je7h4Xj6WpIvWfcaoCzHt2fOA0uT4LofAIC8WM7iQTNS2OaiziYnieeYVUyELYCMrStgh9PFGzPtBWxRpofmqDe3Atfe1O8vUIgNiVUPKTTfC1O1B6qZbUMfPiKMN+K6/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609061; c=relaxed/simple; bh=xaGmcsjd+lkOWUksrw9hG2GtCYA1l7WNpGBbOaK1l7o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nIuQW5U7xOIRYjA6wM5h34zUGDTAQJ1x4u3UMMZU1oo0CzK2o7pzQ2YzB8h4yRj8p8nScQdhC+6aU0ZXkJSwlPwjM5M3LMY5l2r21mJ6EAQORtLx0af3bDAS3afOR5qud1DHQhOU2xEs7STKPwcaqySbfSuLXzKsN7MmxZqggdE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=CPIYffui; arc=none smtp.client-ip=209.85.167.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-5114cd44f6aso2840942e87.1 for ; Sat, 10 Feb 2024 15:50:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609057; x=1708213857; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GcUhkZrXlF5pRwcMyaOQX2HOmfuyNRPW8LUolF8mADY=; b=CPIYffuiExah5o8/w1W4dH7kwyrLP8oCPHOTmz9hHRvAwYKIA12VgqBo5F7CBC5AHC 1xKmAuRwCTsFPGDgIsWFyU3NzYfCMhA0ortwVZdcTkb8Hc02fIH3I6XU0DqEcJaE/l2i Vo/4NhwNW0g2/bwKTKKaafMLja2804uFWFGAs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609057; x=1708213857; 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=GcUhkZrXlF5pRwcMyaOQX2HOmfuyNRPW8LUolF8mADY=; b=V48JXzB0tsjfIej67/ES25qaGLMzyHAXh0Uy6OmLWCFOtQTfNjsdpTw0z8dkTMwvd/ faxsPgC55PRcBmIhbOfeYVxlFleLx9I5gB3MZ9BtHAeK21s7DsY/vIEkfJx3wsuWaFGd 0m7t2fI9IlIBj2pydDfeHqrFiN085K2NSlqxckyhasdKLOQ5t7TH3GjVfPqtsv8r4uMr mVVQypyV8QIqjHR71ypeV5bauEPbCMcJ6DlDcGTX8VC2k+cWx5Z8coBj7EHXhnZCeMzK +jr66s/TydiM+rOkaqqbq+X4cscCO4hiripAxMxkT4fyBWvpm0f7m4gKMvfs53YxdwR5 6/9A== X-Gm-Message-State: AOJu0YzBTjNFSYRs/cRoeGXyK3Mbf2v+Hf1VgUjayoAift/8ZtVUIUV+ VLesPtpCuKcQUIg+buduXk0YKLEwIZE3DmYkFkNI5pLAccVI2nI3tByDKuBRzCnupM24f3aRZQ= = X-Received: by 2002:ac2:5eda:0:b0:511:55fb:2405 with SMTP id d26-20020ac25eda000000b0051155fb2405mr1659223lfq.50.1707609057566; Sat, 10 Feb 2024 15:50:57 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUMvMLuG7XWucjAH59S42BW92allZjpZHUiTZ04ZDytLeYM3qAkBnJsfwWB+mu9HTVVqkcciJ2PvdqAXL+Lw/CxLX016E2mfnFbGVXnY4elEdNKDkGpNxiUOYCSisgKf1x8g/1rvNOyPKkE7awdV/V2tNXIMG2+eX+vwEd0vj0I++44WalYTfoi/iz01iuR1a0rZc+lwoApvUQa1jeTb1+/LkdZtduzXmRkb0QP59tdOhrsYomvHmv8c1bwMsUTMrUWncRoVJiOLiQnvCIc/qA+VLmZ6SgoTbTSFzwVizQOyAQfL2y9lQp6EPli4UFC3Ij3o16Rw8+VofwvhZ+om7zvHg3Rg1sqrIHuXqKOzECasCWmLw56VaIkVsECEHXf2qNT4UfbAA2qgpA49xvATtvbzfeiMVoqfWFLEv3R7aiZBEs7BOWbzmOFFmklDvv7MGT8wmtLB+RZmmUpnMPYKMdjk82ZwKMCDAC0ZabHDlsdJcMq/Dv3jwUWxKyAWB2L0NbjC0Xhz7u09oheM4IgOzkEQCrUAACCyBEnNg9MmNx3rSju6D8riT7ffwLW2W1cxlSEwquJ5ugc8Ok5p9QiHTL9IdBfRru3ucbuEaCUhbERMoJCog== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:57 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 17/39] dyndbg: add support for hex_dump output to trace Date: Sun, 11 Feb 2024 00:49:47 +0100 Message-ID: <20240210235009.2405808-18-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790558134002340272 X-GMAIL-MSGID: 1790558134002340272 Add support for writing hex_dump debug logs to trace. Signed-off-by: Łukasz Bartosik Co-developed-by: Jim Cromie Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 16 ++++++++++------ lib/dynamic_debug.c | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index dc10c7535f13..76eec3f05be9 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -298,12 +298,16 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, _dynamic_func_call(fmt, __dynamic_ibdev_dbg, \ dev, fmt, ##__VA_ARGS__) -#define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \ - groupsize, buf, len, ascii) \ - _dynamic_func_call_no_desc(__builtin_constant_p(prefix_str) ? prefix_str : "hexdump", \ - print_hex_dump, \ - KERN_DEBUG, prefix_str, prefix_type, \ - rowsize, groupsize, buf, len, ascii) +void _print_hex_dump(struct _ddebug *descriptor, const char *level, + const char *prefix_str, int prefix_type, int rowsize, + int groupsize, const void *buf, size_t len, bool ascii); + +#define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \ + groupsize, buf, len, ascii) \ + _dynamic_func_call(__builtin_constant_p(prefix_str) ? prefix_str : "hexdump", \ + _print_hex_dump, \ + KERN_DEBUG, prefix_str, prefix_type, \ + rowsize, groupsize, buf, len, ascii) /* for test only, generally expect drm.debug style macro wrappers */ #define __pr_debug_cls(cls, fmt, ...) do { \ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index d379e05837be..dbae1ed6ab5b 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1377,6 +1377,42 @@ static void ddebug_dev_printk(struct _ddebug *desc, const struct device *dev, } } +void _print_hex_dump(struct _ddebug *descriptor, const char *level, + const char *prefix_str, int prefix_type, int rowsize, + int groupsize, const void *buf, size_t len, bool ascii) +{ + const u8 *ptr = buf; + int i, linelen, remaining = len; + unsigned char linebuf[32 * 3 + 2 + 32 + 1]; + + if (rowsize != 16 && rowsize != 32) + rowsize = 16; + + for (i = 0; i < len; i += rowsize) { + linelen = min(remaining, rowsize); + remaining -= rowsize; + + hex_dump_to_buffer(ptr + i, linelen, rowsize, groupsize, + linebuf, sizeof(linebuf), ascii); + + switch (prefix_type) { + case DUMP_PREFIX_ADDRESS: + ddebug_printk(descriptor, KERN_DEBUG "%s%s%p: %s\n", + level, prefix_str, ptr + i, linebuf); + break; + case DUMP_PREFIX_OFFSET: + ddebug_printk(descriptor, KERN_DEBUG "%s%s%.8x: %s\n", + level, prefix_str, i, linebuf); + break; + default: + ddebug_printk(descriptor, KERN_DEBUG "%s%s%s\n", + level, prefix_str, linebuf); + break; + } + } +} +EXPORT_SYMBOL(_print_hex_dump); + void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) { va_list args; From patchwork Sat Feb 10 23:49:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199357 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1704920dyd; Sat, 10 Feb 2024 16:06:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IFspVHOoCERm/a+aKqg4rWrYREKOSAv6o6ywirchCoeAjNqEhEjceaB9cSHQ7xgJ6VZ8J0B X-Received: by 2002:a17:902:7401:b0:1d9:9f86:3c84 with SMTP id g1-20020a170902740100b001d99f863c84mr3371468pll.23.1707609991386; Sat, 10 Feb 2024 16:06:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609991; cv=pass; d=google.com; s=arc-20160816; b=ftnUtTn/v6pHb1yECnRlRLTUNUi2eNwkG0VxrBJ6D5r3LZ/sk+gwofHDOdB+4QSUY5 iwH+J3GAQFBlRlcdVaTpY+fgS2RY6cd3JrprfHSPFitshDamXXzz1rGxCcba/LmkDfpc dU8cMEGZ8tJiYhUlAHlVZ2A7X8Wc6p2nAsSGJM1uHUAsWUmLltEt+RvVYi8E2ItX2kP4 kbKdK46dqDOuCbgh83kbFrKaWZQ9j9DW6dmBa34C5+uaEDFkx4tq5/lOPT1eKl8P2M8s XqNn16GrN3BN+31CGAbOP0k9OHmTseJpWSiIruVvK3djDsD0I1QTHcsuTCCKhxOQ3cnZ MVvw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=f2CTMmybaxg0dOtHmB7rXgRA/borZ7XgGMz9viO7lBc=; fh=me6Sx26zWbWdOyRXEDeSYSYMf8P4rzG3HwbRxEyjkrE=; b=eT536Pan6J/ckLCFEmIuRfkr9bqPCjr6C0dm0c4hXqa0rP4t5alahtxu+Jx7BgDC5Z K2w5Cbr6UN+czzMX42lzdI46rrl+HIpEiSGxvJwbqleBP2k+x02ka2LECce7xyOR//rV jgp5aq41vFmmqn6KtUYqXIlChge7ChKwQRmTP9Hi2oZCiwh01gKtNDv25zQ7vh022jfk KzfT8xkv8cEl8uNKk0raNdq1cY/hi5PR0GjJplQnC0pVHDqnAM7SVa2Rc7ww6UJa75QH RsP5XtPAhgDtAiM3NsJw4lC46kRPzfyfxNbUFW6hhoM2oqLYvoWyoMusuxK4tk/sOaYc zRPA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hPubffDm; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60601-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60601-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCXJ30GSQTQWDKldtj8g2f0SA5vHuYJ+O753V5EYX0mW0nl9i8+JveKWd32yKGsrNxbTdelvAkZUjQ+JjKdWEFtkRNFQAA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j1-20020a170902da8100b001d7587f372dsi4191991plx.213.2024.02.10.16.06.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 16:06:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60601-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hPubffDm; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60601-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60601-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 06708286D08 for ; Sat, 10 Feb 2024 23:55:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5627626AF; Sat, 10 Feb 2024 23:51:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="hPubffDm" Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) (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 00ABE61677 for ; Sat, 10 Feb 2024 23:51:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609062; cv=none; b=TCK7+f9K0Dm+LOdtiLZCOsDAhgShbPNsVYhvEUKixMlyRYGGfBBXe4HoyZ1RxlaUls8hk2IvrNeB+itCB1Z1CtR2CaAIy566bzsDc+AjZ2jTuDA9kVE/2QzGi3QkbFpKiSRGo24VzvNpNUI87ulYskd/M23LHdhhGSEJRd0JKco= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609062; c=relaxed/simple; bh=38I58GgEEuvwOX95RJ1mNCPWP76DGHxflbVS5gA9xhE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b2EgzlBaGIB2x8/rxyCqtiKF+GwLh/vTqg9xABkkzQQUpUMT65eLGHfpmplhXm8SVLEMAQBzldaDcT5HENdqvuMEJqakMwa6J5/HTnmF9Re1VzLS42VsRgHxDSwnBO0t5dOR1XQHOBTbG4gbvkln73qgjeLJil0w7SoqQs6R7HI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=hPubffDm; arc=none smtp.client-ip=209.85.167.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f67.google.com with SMTP id 2adb3069b0e04-51147d0abd1so2384578e87.1 for ; Sat, 10 Feb 2024 15:51:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609059; x=1708213859; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f2CTMmybaxg0dOtHmB7rXgRA/borZ7XgGMz9viO7lBc=; b=hPubffDmJ5Odq8LPxPhhzmcqxd7gcGlAA3EL1sgmsRpLQy8QwmA2WR4RpiPsLNcFWb 6Ea2XIvEaidlKXXcjkFnCdNYoeoaG2XBiyaBJz0yWGIe3lz5HrMnlbMobLZAWof8g0ay qYUKNizCYiPnQin+YVat1IKJEWqfZ5/FU5qU4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609059; x=1708213859; 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=f2CTMmybaxg0dOtHmB7rXgRA/borZ7XgGMz9viO7lBc=; b=dXyZx5xzXgiAgaYOU81QqZlTd2vCu+LGfomY33SqDss8W2wiYqTA8uF5JtAaoKABjq uz2Jy//fpOuFOAPGAEI7ojXFMBgXmwe3EzqEE8zfdLCM71zAJRTBulAolk610vsmFVUX kMTw2PFH8NRK96/drFKRT/v4wMcRbJn9ITTc/ix7svehBWmsDY8ptp9mHOuMtFJ8B8G0 p7NlyYgXjSGDU6DHsuDBK2hS/pjK1v9U9jY7V3A+bFoGH09X5I4IgyAj0NAmJ1ddz56u HBJVNd0scvCsvR3Olys8QBwG2QPih8DN6zlZv8yXxOU16O36PQzyIddWm9GuTo5PWtVG AhSg== X-Gm-Message-State: AOJu0YyENLuw6IyCZtXToHBsLtka/3ZhCil/CufECHpAKq5SwcSdvsQT cEZ9sdB7F4wPQVkTAqDcLTmHdz+qiON0OHdPWS/HlcWFcez7OS6zdSovBVbG X-Received: by 2002:ac2:46fb:0:b0:511:79ac:2d78 with SMTP id q27-20020ac246fb000000b0051179ac2d78mr1847074lfo.39.1707609059268; Sat, 10 Feb 2024 15:50:59 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUwY9QgQWBv3mqmXEOiAqOyF2ZXgQZL51x6zCMlF3rA9kaeIjjxX4WV8W+tU7uU3bK3T5QCGqKacFR6Lm4Y1KMiFafq8X+P692nGbcsnH1T7UbAyvneXsakqxDZqrZ5NRtjIHKz1VzLdyaNeo0nLtRShcG3xVyA4goGGXDYrO/kSwxOtuC6CJkX4Lph08GFRxvjG9KttQPGgGKCO18y1paBNOTam+SHnNkmAW+SROUQdx9yJ7Ab5sGbJgRyFP0bJN9x7OuYvYVK+KYdxBu7SRqSQpRl9n5ys8w9Ya3p7eQit0LQnmwVO+tcmWv+bFZ/6Y3szDethzuM4aD0YsctshLo5S7hen9Z6CzM6uzkrJ0p9tgFAs86c8nt3edwHXYZcRt/S4ZDrzyoaf53s5SleHYz148Ey0FCfhOOtKnrdVaBSY+mihT/Mhq4n+wNAOYQabilSgdrBng8nPwtVGyoMmvuMrEJ6LvbhaeHBqLNfafV0HdoVFArmHPa7sdplz+uGmFmcblJTey4nbGhPtWjiPVg5styQD5oqn6BE2llt8G7bOZVAMGIvxwpcbbn2ozReyWnTXFXZBSp5kl5WiDduOlymbNrxwZltgRe+LRRnvr+Nk7uSQ== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:50:58 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 18/39] dyndbg: add label keyword handling Date: Sun, 11 Feb 2024 00:49:48 +0100 Message-ID: <20240210235009.2405808-19-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790558854497194306 X-GMAIL-MSGID: 1790558854497194306 From: Jim Cromie Add a new user_label field to struct ddebug_query, label keyword handling and saving to the struct, and update ddebug_change to test if a given user_label is found in the list of known trace-instances. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index dbae1ed6ab5b..17df4bf6863a 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -61,6 +61,7 @@ struct ddebug_query { const char *function; const char *format; const char *class_string; + const char *user_label; unsigned int first_lineno, last_lineno; }; @@ -300,13 +301,14 @@ static void vpr_info_dq(const struct ddebug_query *query, const char *msg) fmtlen--; } - v3pr_info("%s: func=\"%s\" file=\"%s\" module=\"%s\" format=\"%.*s\" lineno=%u-%u class=%s\n", + v3pr_info("%s: func=\"%s\" file=\"%s\" module=\"%s\" format=\"%.*s\" lineno=%u-%u class=%s label=%s\n", msg, query->function ?: "", query->filename ?: "", query->module ?: "", fmtlen, query->format ?: "", - query->first_lineno, query->last_lineno, query->class_string); + query->first_lineno, query->last_lineno, + query->class_string, query->user_label); } static bool is_dd_trace_cmd(const char *str) @@ -574,6 +576,16 @@ static int ddebug_change(const struct ddebug_query *query, if (dp->class_id != valid_class) continue; + /* match against a given label */ + if (query->user_label) { + int idx = find_tr_instance(query->user_label); + + if (idx < 0) + continue; + if (idx != get_trace_dst(dp)) + continue; + } + /* match against the source filename */ if (query->filename && !match_wildcard(query->filename, dp->filename) && @@ -770,6 +782,8 @@ static int check_set(const char **dest, char *src, char *name) * file * file * module + * class + * label * format * line * line - // where either may be empty @@ -825,6 +839,8 @@ static int ddebug_parse_query(char *words[], int nwords, return -EINVAL; } else if (!strcmp(keyword, "class")) { rc = check_set(&query->class_string, arg, "class"); + } else if (!strcmp(keyword, "label")) { + rc = check_set(&query->user_label, arg, "label"); } else { pr_err("unknown keyword \"%s\"\n", keyword); return -EINVAL; From patchwork Sat Feb 10 23:49:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199349 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1703211dyd; Sat, 10 Feb 2024 16:01:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IFoOJFiVE1WbPgDs7eoJdTVSZAnxhEp+0lbPC4pWtJDLDkL3dd5/Kt44WTfoAngwLtxvmvE X-Received: by 2002:a05:6402:33d2:b0:560:8fb7:a720 with SMTP id a18-20020a05640233d200b005608fb7a720mr2038308edc.24.1707609703039; Sat, 10 Feb 2024 16:01:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609703; cv=pass; d=google.com; s=arc-20160816; b=RLwBVR8DdPE/Ke6W6jGOjBOVbB1DEN4E6DitOe1/ynfn4ECq+kumTvZLyLSzVP6Izq DmoGLv3XwgAHNOWKU5F9mXj2QcsNVQtweA1ZwIXNnG/Tp5+GeMO2O5vwJvNH878LZK3k IR+YzoIWyB4VOpS/Q6/LwWI3vZsM+uWx9ZuLQqFPvwFTOxeAqJVPTWaeG5bZwOHfd6Y/ 2J7CsCUkWvpuoLHC7C9kQXT0hfB0954D+LfDT+JIoQ5rB3DhAmC3X7WsznsiQS8LZwYF s2LzluJiMbucU+n3irO3X8AqCMTEZ4WioE1CESJDYhHyEth8uUQhGQ5nHTneJU7NYtuj Xf+Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=87LdGKdo1o52qqAOMkU7XUi8d7iSZPf2NI4GoJJh05A=; fh=7DfwOjwhKk2sZSZFY3JwPsTjoaNKrifwJEzWliX7E6Y=; b=nXGsYrTpyjIMvFGziuF+MRw8JOVoDPWcZ+v6j8v7WK2BMqiu/8aL5aMIMCeGMhoJkK X7+V6Uf9bQg3JXNGJ2h+uZbW5Np6/XCv1sBEGyT3ZgMwz6BXiTW2zn+a4o1oMqhFTipr Q6L4e7NT6AjfuQf3dkVzI2qWtcrNA5Xa6IbYd/HWKRJBMw1SFeqNQ5C1HsQpdf8mRKpB oLlPFFwc58sDR1PvCECT+l2ovSSTit3pIOc3E6zbZYEM/WIlL8QMIb5pD6UEdOjJL3I/ pw2+rtcJcoGIQsVjB68Hic+ihSneUpWcc2xVNMRbL/L2xi45tjB1+B6qzH3BdTHoKhkJ N0hg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=InQ0Ny3W; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60602-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60602-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCW8Eww3w2HAJQt9vcGyNijcW9mARQYMObrmK9EREN9+g0uxHL4NA8CZxXH5db+LEgwReBxVoKjYJQ8FalKTlZRyCh8VbQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n8-20020aa7c448000000b00561351b6317si1293913edr.635.2024.02.10.16.01.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 16:01:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60602-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=InQ0Ny3W; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60602-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60602-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0D92B1F2523F for ; Sat, 10 Feb 2024 23:55:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 108DD626CD; Sat, 10 Feb 2024 23:51:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="InQ0Ny3W" Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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 9813B61690 for ; Sat, 10 Feb 2024 23:51:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609064; cv=none; b=c6SsVd722LEuFaqN0OqREyI8VMPuceF+L4yTLiNkyiaRWaTMhVXhPg76QOemJVNVL2m2pP17cGm2Pp//qM6yMetPlZn6FwnbRC2mcWBJkCXB+Id3jFtzAh1FfegR55tStJBEFrxBtlA+qOarv39I4HWEI/mCNLdODh2e9DTYea8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609064; c=relaxed/simple; bh=nXECD65rD0s/P1xvsdNfQSv3wCJRkijHf1Q3X+aDxVg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tJM/pvSsyhwBgcoK5Unx2HPkVBnJXdz/t4V3lpYBAdz2wBWkBL8YcVnSI/PAbDcDt8FpzvvtGmZMQbpSlLZ3pbuR4mRSPPjCbQJE/TQ8K2IUpaMvx2vMf5ejyqdSiILJZVEuztr4uyJUBxSeEz3TwsSFDikPbv8QJAPPrmXtJ64= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=InQ0Ny3W; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-5101cd91017so2348537e87.2 for ; Sat, 10 Feb 2024 15:51:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609061; x=1708213861; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=87LdGKdo1o52qqAOMkU7XUi8d7iSZPf2NI4GoJJh05A=; b=InQ0Ny3WiA2AX0cY9AJSXCQsAT8+oL9ynyFUM2gwDvCaGl+RLZpIyx4LPjKrwzjJMt VA1vCRmvrotwX+WgLPty8kb2XIdk91O5VC93PJDB0M0aSYRfEw/nBo5Yrh5e7hJ3ngbp a7nguu46RnboBWEoLeCi1aFAFOf10964XjlOo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609061; x=1708213861; 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=87LdGKdo1o52qqAOMkU7XUi8d7iSZPf2NI4GoJJh05A=; b=cIysG/J2S4uk3MhTS4TWXg3MMQO4ud0fcN919nuejquwSvlVtyGHbLkzpIqnAygwWB I0gcfCrs+Rqjd94o0TiDVGrcR/ICDWV80Fm/PIbVcYUI46yafCrtpsMkq1MJofGZmexc 7NYRVXhJhqEU696S0nBEw5FQWfqHFtd+qQhYk824x6X5ZzbYejW3UpTiSCmWSJJl443u oHxi359JnguYE3gilzdTvbjKDneqkYyLCBHSVdY6VW2F0XGaXEb7AQEGnoNzAqkdhehd yjxkp96PBYM4Uv9U5CAP9zuDyX/7tSmwR7PC2AyXC+ybOs5Ynp4yzeuh1RBjp0fzWcuv S4Bg== X-Gm-Message-State: AOJu0YygGFeboC395oMjwFBj3PcU3AtjWEacs84/k8Zb9yFtiFM/tT2F /Yw6iqge+ulrpD4iseUoJScDRg8WygbKbzm1nq2o+yFeEQ6tIkhN3vflWXnt X-Received: by 2002:ac2:43d5:0:b0:511:4eda:2563 with SMTP id u21-20020ac243d5000000b005114eda2563mr1744694lfl.69.1707609060849; Sat, 10 Feb 2024 15:51:00 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUYfeFXNc7BY13yOy/AaBbGoVRDaAbyI/u972bYmkBYD3ubr80foQ0xWNpFyqSy8H4iUDoKibWQ2Wb2pSv+sdq2XstMdzS1skZyxrwy+y6jYySz9/1MadhsyKafE0gPqKgcbVCkVEYUglZZ0yJ12yrJEWaGrV+vPL4+SA4hy7yQIciI1njiyhZrzp4uJ57qdaFdc92ckoivTd6t2r7xcWSNnNnps8D5GrRz0pZqPCk9hTZ3XWQJ1Umg9huBIsZYJeXMxxidlZAkUtEArXutsJZwB7AlIsdHiMtIKaflYXXP4MHOEV1xiDi86eOumYiGpjqzZRMD0MXP+/WJlBtm17IzR8PgYVNpkI1DabfLIoUeAmDMjWq6MM25EuAE/qvp5JEAP5hK90m4M7QVaaoPvV+zkaT2ZHM8CnTXSOUzPYl8D+l6fCcaoQAkgPPfKV9ngznFQQfSxBC8pYz/boHlenlHSbGk+Lds03vJ8S32oKdBfYy5kkwh4EclDUzVDV3Vg/P02+JJUYCMtna6OHznYulnu7mSoYVUqOHg4bL21dW5TSCQjsMBrpJD9CriGBwRD9susUUU9jSpedBWWpXY15vfnu9W5+F/01Hijx42Kx7E/TYxKA== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.50.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:51:00 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 19/39] dyndbg: fix old BUG_ON in >control parser Date: Sun, 11 Feb 2024 00:49:49 +0100 Message-ID: <20240210235009.2405808-20-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790558551866027628 X-GMAIL-MSGID: 1790558551866027628 From: Jim Cromie Fix a BUG_ON from 2009. I have hit it while fuzzing >control on some other patches, and panic from user input is bad. Replace the BUG_ON with pr_error and return -EINVAL. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 17df4bf6863a..20bfb6de2404 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -682,7 +682,11 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords) } else { for (end = buf; *end && !isspace(*end); end++) ; - BUG_ON(end == buf); + if (end == buf) { + pr_err("parse err after word:%d=%s\n", nwords, + nwords ? words[nwords - 1] : ""); + return -EINVAL; + } } /* `buf' is start of word, `end' is one past its end */ From patchwork Sat Feb 10 23:49:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199342 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1701362dyd; Sat, 10 Feb 2024 15:55:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IGgQsGetd8QP6ZD0bjL2j/bKwCc1PG1mTxnrc3qrfwPhnGwDhTcNMeTV52OULgkvok9D6/l X-Received: by 2002:a0c:e290:0:b0:68c:5027:4cf9 with SMTP id r16-20020a0ce290000000b0068c50274cf9mr3579748qvl.62.1707609345593; Sat, 10 Feb 2024 15:55:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609345; cv=pass; d=google.com; s=arc-20160816; b=eJebCjT4F6kSbchAeHapJGZStSS+nx85kdB/jfD1xUjOsJMI/aiqtpOLCowT9UQk3z 7k6ZUD3ALo30VFdYl3V21TMFT0Xy+78YJqTFaftqSEEwNt80zla2WQ2N4+z1L4WdUCz4 wcdx29klFAxAMcSf0ECbV2vALExR+fLYwNChscFFI3bj7O6LgDuhjOZy5b3/UGZtCrE+ q35RvNxrnj/TZlqXqVlup22fbphI5IX1YG0ScWjNEw7Ojp4zvgZebLD3BwcfFX0UeaCe 0lOUtxneXbizS5gBgj32yb1wDMtR1aTxW7+cs1JCTi4TBr4pQyeHh69qhXHVkilEkDaG GdzA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=y2saDJqjVn0V5IZnXz4myO9Pbq5U3qhHJ6QVZDbJVX0=; fh=oNcZXGWiN2Q4XRxTrjw9HdArmBqWj/vZnEBTkFpwlqk=; b=b24a/QgfdbenpjWqbjQk8io06IBoqNRPqmIamjLT7ITXuFQRFPe5MM6J5unVUrqwTx sqrr6yJtwrtdCfiYHxWHuo3EmyeDdJBRyDFNGrf5AlzljuDSga/6RE0fuTsXjF92K4X4 p6+jWqRoec0613eyj20xtpVH/DAAhe/gVftR0AzDz14+F6zLWLTKKNEDCGNOVoBp0Elq ugZnLZWXxKWm4gDwuaCheNuu4RJAZ9t9vqVV+OTh5o2j4N1y5Nl633nZypaWgaBeO6g4 USD8yZLwWrE+A6XlT6SGhA/CCLhRzPhH3/UZY0TLIwqL05UJ9Xv0jrozHFCrRu+OBDw1 0HCw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JgtEEfJY; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60603-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60603-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCV1vk8lzURHMllths+BYlLwDvKPRcDSyupzHQag9j7WX2SWZfSUfxeVku85lgBcHdIlznqZfiK47Ux2GOPwb9QGzKqpIw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t13-20020a05621421ad00b0068cb7b24a38si5295759qvc.339.2024.02.10.15.55.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:55:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60603-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JgtEEfJY; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60603-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60603-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 534A11C20C8A for ; Sat, 10 Feb 2024 23:55:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F715627E4; Sat, 10 Feb 2024 23:51:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="JgtEEfJY" Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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 1A4CE62177 for ; Sat, 10 Feb 2024 23:51:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609066; cv=none; b=KIKPHb9xZyDsrqE4UUaSHUKEN9bWq50ysdurwA6nHQrXKwXhHwzPRO0kiK3ru7cx8uBkLoypIDR4vdEdHePpDjwJ6uCyTKm6Qg6iVAgCyq80j6GZsK0itJhexKK1QpnMHpxog5LbL6avpR53yDAyPovyIq18X2lHmyn04Ge+P/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609066; c=relaxed/simple; bh=KhSOeCx7N/HjioQXr6VqOtlhnK8h3fsvUF59nf4Ak+Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uzvXtESRefTS31Vxl2Og/WVD+dL38kHtOPpcCiWjhRpvHUwmNKOuF5iThLWxDnojAiF2iI5TNPQrt0HIA4hOLe2sXrWEY3JR4LD0fDu1B55qZDtPAA0Nqin3yZCfXJg3Fx8q412y1YGiQf8pvVxACRxc14KxCw9gcfxAprHaGCs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=JgtEEfJY; arc=none smtp.client-ip=209.85.208.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2d0e2adfeefso14518731fa.2 for ; Sat, 10 Feb 2024 15:51:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609063; x=1708213863; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=y2saDJqjVn0V5IZnXz4myO9Pbq5U3qhHJ6QVZDbJVX0=; b=JgtEEfJYtRFkoEjycFdphx86txP+uvU4CJ0Ksb/8JyVirt6rS03cSfN6nSA4zwWpsP bzmE+z0ZY18ZjohBQKqNscGIq/6FJ3KjDewQE/snzxKmp5P6SmLsPx9lrQvUlrcZJLVt LwuA9QQNFwM+IX5WG7YAcW1lecomXgKGnn+7M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609063; x=1708213863; 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=y2saDJqjVn0V5IZnXz4myO9Pbq5U3qhHJ6QVZDbJVX0=; b=Cp1osaH3zuVqjKuFvIXio9qp8gMqRvw9ohzi5NUipy2g5oaY0j8ROe9TF0C4GltXLP QA/U0qZHakRIV4U7JROOvEeynFZBBNMAGr74QBQCKsifoe98DannqcvN9zdUOUwSgHC3 COhM9187t1JYK2cWVEDvBUQ2LCa7U6AKdL9dAsyzNIvHbo7LqjXSQg5F/tQvK6EJGYQo lwJ0McPGGmABiCZn/O/I/KRgkSKfAMGZXz8fybbh8VYr8p2iaKGuMUQGhTk+6y3LDAE6 9G+LNwG86E8W5PaO1JHDjGbQvY9c5HxxxXGbQ6icKbtRfMO1f4gtU2UZRdRTDTkAwJym uxEA== X-Gm-Message-State: AOJu0YzYPaCoUgN+2mGpKBW+PxRVp8ukc3fpyis7t/b0hLDZIF7iN5qn TFfq/swUafWjxffWHBisuos/RnTxB7619gsdNzxmyA/FiuO/H/fntIWBA76X X-Received: by 2002:ac2:482e:0:b0:511:5411:1144 with SMTP id 14-20020ac2482e000000b0051154111144mr1786082lft.14.1707609063219; Sat, 10 Feb 2024 15:51:03 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCX++7P2W3N6FZzJcKeOJnOS15wNbWMLQrLZgBmpkFjbPCzYsjHvgareXCm8sqvzowGcAFjyy+PlVoI1IzTzX9tqQYvEEz+mt6aK/5sbhKvp19Z2eezssNY/tXOkhYLE5xOPkH3WOJ7Hkp+79WWx7w0mQvQlDvmjBV7ENmwLLccICJVGIhqICd4FjPTUEOa4nDhYT8RR7aP7nVI7LjDtmBAphSaKvwTH16m58s6zl11Q6Qg59dJExOK2Myw/oHfP1XgesQ4E8CCDrMjhEI/CLIbzSwdHdx6swy6WdXtqS7QVhPpzHKlTbPJrKI1LYWyfKPcNTi4n9DckbcLxEbD5Npv0Gxpwz2RVHHNHcKTy+BPPreF0bJrnz3gJPQ3di53KeflmYqWQZdtRUmGGeh9zSPNXPtyd0wN8AQ7DxCRQlo7HEU/wP2bvSyKMnWLmx4t4BanahyIxt+fWB1AOQZj6q4FAUixGk9Wdb6AkuiCWhum6clLK5l8XpGPQbqpR6dfnVLaeoj+OMoH3IoukDiPl4VKag3T+aB0lM/sdacWdqNM7Z0s2ki4qoZ6tVbVaQ+INTOZvy+95HplmJ3Vw6OgSTfEWnfwymnvpByR7QumgVkhinaFODw== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:51:02 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 20/39] dyndbg: treat comma as a token separator Date: Sun, 11 Feb 2024 00:49:50 +0100 Message-ID: <20240210235009.2405808-21-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790558177141756450 X-GMAIL-MSGID: 1790558177141756450 From: Jim Cromie Treat comma as a token terminator, just like a space. This allows a user to avoid quoting hassles when spaces are otherwise needed: :#> modprobe drm dyndbg=class,DRM_UT_CORE,+p\;class,DRM_UT_KMS,+p or as a boot arg: drm.dyndbg=class,DRM_UT_CORE,+p # todo: support multi-query here Given the myriad ways a boot-line can be assembled and then passed in/down/around shell based tools, if the >control parser treats commas like spacees, this would allow side-stepping all sorts of quoting hassles thru those layers. This change apart from existing query format: modprobe test_dynamic_debug dyndbg="class D2_CORE +p" introduces new format: modprobe test_dynamic_debug dyndbg=class,D2_CORE,+p Signed-off-by: Jim Cromie Co-developed-by: Łukasz Bartosik Signed-off-by: Łukasz Bartosik --- lib/dynamic_debug.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 20bfb6de2404..78b06a617918 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -650,6 +650,14 @@ static int ddebug_change(const struct ddebug_query *query, return nfound; } +static char *skip_spaces_and_comma(const char *str) +{ + str = skip_spaces(str); + if (*str == ',') + str = skip_spaces(++str); + return (char *)str; +} + /* * Split the buffer `buf' into space-separated words. * Handles simple " and ' quoting, i.e. without nested, @@ -663,12 +671,16 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords) while (*buf) { char *end; - /* Skip leading whitespace */ - buf = skip_spaces(buf); + /* Skip leading whitespace and comma */ + buf = skip_spaces_and_comma(buf); if (!*buf) break; /* oh, it was trailing whitespace */ if (*buf == '#') break; /* token starts comment, skip rest of line */ + if (*buf == ',') { + buf++; + continue; + } /* find `end' of word, whitespace separated or quoted */ if (*buf == '"' || *buf == '\'') { @@ -680,7 +692,7 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords) return -EINVAL; /* unclosed quote */ } } else { - for (end = buf; *end && !isspace(*end); end++) + for (end = buf; *end && !isspace(*end) && *end != ','; end++) ; if (end == buf) { pr_err("parse err after word:%d=%s\n", nwords, @@ -993,7 +1005,7 @@ static int ddebug_exec_queries(char *query, const char *modname) if (split) *split++ = '\0'; - query = skip_spaces(query); + query = skip_spaces_and_comma(query); if (!query || !*query || *query == '#') continue; From patchwork Sat Feb 10 23:49:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199348 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1703008dyd; Sat, 10 Feb 2024 16:01:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IE2i4069EvF9ZfYG3/s0rZXVikSihTHyOIqmBQDP6XE8ob+VJXguRmnXktRAwDup9ZLLCuL X-Received: by 2002:a05:6402:31ee:b0:561:347f:ec52 with SMTP id dy14-20020a05640231ee00b00561347fec52mr1936922edb.30.1707609677488; Sat, 10 Feb 2024 16:01:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609677; cv=pass; d=google.com; s=arc-20160816; b=LcMK4JQC3fj7CfoHaKoYvYEBpD7x0lhe9l3fssZJgC2Oe0vYBnd2WtXB2vC7DToiaL kTiNAEfYeCFufnsy6tbkW2EyruO5IeF+a2CpJaR25cEvQtvyvKhObWZJ/CADhfAZetUD qARS1i1S9j165MlERQfv3P0d71gF43ETh6oxROq4oUUWyVjJGp9IDNTixS+JZrurDNnQ uPdF/mURf5ZchVyCXnbM+5nmoftxqfpoEmErT8Z/UChBJW6fRcSup1xyhlnrRNx1U97U vqw3MgXCY96DFv4iEni5l/e+CxTNj9l+Lpfp94JO7SrMj9aNXy3LgILcsJoKD/KDkVe9 W+Bw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=T8V9Re3rorVQytgMEZlbpA/2LnF/BQwNBihKNd98pUw=; fh=clH8kiF9iEHil025hk6LjcXwlBSD8nHLD3WlPt6kJts=; b=HVirkHwkZtapw6QIq62P2hSqTk6aPDMGQDGN79Fk7rOJ/Kx6zzHHunqF7zeqB/mgoE t0qnjgMY9aEE4zWlpTJcrTlE6uAzkFFOJu5V3fP4+OaDCYZNCerGDJut+xeqbh3hUaBN 7UMqNNHiU2i+roKdTfDEC5gqc8sXSyC/PDtqVWyhidonp1qUtVHgnmNCW7KTUmLlN61i 9EqPgAG33LTkCuXrpaHzj4KxlQtaOKA9CvBIYFzeYx8cyAYOA8O3rNY6/CscRmf0jvry +T5Pqi7b512o7WcTeJDosiuNSI4M0vaCZLYs1mzk434ZvZ4+TIWv1zZUgfA/ytKRAq6H Mupw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="A/nIjTre"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60604-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60604-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCVKf6XYT2/DSk8Awnq2NaAdONjWjvN3/xO96P4Yf9QQlHWTYoYVrtPBUQdiAqfkag+jOMVEs8xWmDH0si4SSfl3avCCfQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h19-20020a056402281300b005618a1b0066si407268ede.4.2024.02.10.16.01.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 16:01:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60604-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="A/nIjTre"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60604-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60604-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id D47551F25DFA for ; Sat, 10 Feb 2024 23:56:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ABD40629E3; Sat, 10 Feb 2024 23:51:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="A/nIjTre" Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (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 9D452626C7 for ; Sat, 10 Feb 2024 23:51:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609068; cv=none; b=tdcCsBvK9Rv+MFAmi1n1Lz22NX6qwwUh0uxBtKzJWpsjpIxCeO9+ugh+T0Tw3O2zhjL7la0ze6YAlGuW3f/Xo+E3YZsuAZNY+t868qD5K0anxOSCue2Hn0G8XYenUhjo4nqZqS2wvkpuWTM4SZbNcXjDZxukx6tQY4uEXaTSCpc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609068; c=relaxed/simple; bh=wAxPq0zBe7IpEyDOvpmRO5TFTuGXvH5YMnkbzDZC4fo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OU6XmyQAf6nxU2BFDJ7SUtkwKuM5m5D5V5cXrQuY3tfik1zOz+WbcucSw8W/9WaVm18ZzC2q0GC11XbIGjwzTWjUMXeg0HXZRB0DzQZxn8W9uqoEMpg7solh63a7YhrL/bgPt6/EoEPRh8zoJfYeA3H7pnW73DHBfPoAmE7L0Xo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=A/nIjTre; arc=none smtp.client-ip=209.85.208.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2d094bc2244so24261021fa.1 for ; Sat, 10 Feb 2024 15:51:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609065; x=1708213865; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=T8V9Re3rorVQytgMEZlbpA/2LnF/BQwNBihKNd98pUw=; b=A/nIjTrepdalZmxzQPGEhAsrVjU1YoSqVbLilfcwHP4kBC4rdwwQZFQuoG7EVCsikb z7gOL959TxhgZgyyYVQx0eYzFag9hhJZtvwGRdAQP51ER6rleAmBE1ddlghEkG1ZPOKD xfFztFEgS3xtGHJVll8HTqg4FxpNIA3MmhPaA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609065; x=1708213865; 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=T8V9Re3rorVQytgMEZlbpA/2LnF/BQwNBihKNd98pUw=; b=rE397TVEmaeU0RNQvOtNaN011tTQJ42dGsG6rCdKUWdNvwRuFakum4wByzh/pbKLHz qfC1hZmQ/3vq3usjbwXWbn74RT43D39ytybMrNsZ+ILSCKhY0hqg4F3jgsJGsxgV3+Ip phwuRItzqFYO4cGdajc9Tr+VEJNjexAP7PpOtJR2FC2UTM8UKs5+TmD4pOm9cDuO8+IM cNW9SaIWYaWe8aOMDc2aa5mIkRrEs4IfPBWCiNSxvRwl8vqgv80LZM8lUXP0wxqJHryt x3JIysJPDT1bv/QR6gCd2ueT3ZrDw7QH3MQGdYri5OHF2mhvpw3DWrvIaxwyzja+uQ6s gLKQ== X-Gm-Message-State: AOJu0YyL1pdaIqTyGvYInAj/0bZnRc/cLpjuZjXlshjVv1DckcdQ7L/7 TT0+TBGQluQ0DNIspxlrnWEhESmvGYrP2iH1QBW61KkwP60Qs5XONMf/3clb X-Received: by 2002:ac2:4315:0:b0:511:4dac:f1ab with SMTP id l21-20020ac24315000000b005114dacf1abmr1671617lfh.40.1707609064808; Sat, 10 Feb 2024 15:51:04 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCW0HS+00HYoxQiogyr9WBwa1uNU3+Oy3nx55i3YZhKZAHCXUgScNtcchyYsVTu6aQdITZI3UN8DjYpzIMWvemBBq8+8pI2G3z/xvDtxlbYDwZDZU3KkXoAvUQ5B0rRwYDxFZjiZ8mDgcDkIHaYNSHdqQGGVLf162YypA+RZS36OBUf05ynuMAaNEI8JYomOPqd+qDajC6q66LlG7Kt8FvyGtY1f2Ydi/vLASFek/r4PmF1EjiZmIZdwLFmJPwn5HBG17Vco3nK+wmv6FA7Dy7vJWvMF897vGI3ry1swlBfoL8mcN46FG4HdXPiPkfR+F8tMFGeJv4jAt2T8YaTEU1QKq3ai9djg5HsSmWzf0u1IjcqvYSxZ6XBc7cNztIJhdLGc+Ahxw5HmGYdMQGlfeTv4dpKjSvzgxGqNrQyAFcWBYlM8+kjZRdO11WXfstQCUOfVTNIf+6W6leCzsQeTt3TfV1mEk9WUuFAfzR+emn1zUvVcbIibJHUTdKJMhjh9jWnVm6BdcbyqbfX13B8KCDXQcB3fMploK4bjyMmtVmrzNN+v8sKVJE7ujybBppbuT4+1IhLiBR7Uc/XUkVUtt98Ag9eNdvi1mqjO/dgfTyN7j0LErg== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.51.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:51:04 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 21/39] dyndbg: split multi-query strings with % Date: Sun, 11 Feb 2024 00:49:51 +0100 Message-ID: <20240210235009.2405808-22-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790558525271877002 X-GMAIL-MSGID: 1790558525271877002 From: Jim Cromie Multi-query strings have long allowed: modprobe drm dyndbg="class DRM_UT_CORE +p; class DRM_UT_KMS +p" modprobe drm dyndbg=< [ 38.173791] dyndbg: query parse failed [ 38.174141] dyndbg: processed 2 queries, with 0 matches, 2 errs bash: echo: write error: Invalid argument In trade for that minor format selection limitation, we get to do: vng -v --user root -p 4 \ -a dynamic_debug.verbose=3 \ -a drm.debug=0x15 \ -a i915.dyndbg=class,DRM_UT_CORE,+pfmlt_%class,DRM_UT_KMS,+pfml modprobe drm modprobe i915 NOTES/TLDR: In this example, using both drm.debug & drm.dyndbg is mostly for testing. Using drm.debug is preferred, because the drivers all explicitly depend on that input/control-point, so settings there are propagated to drivers. But more to the point, drm.dyndbg explicitly limits the query to drm. In fact, you could pass a module wildcard in the above, and achieve the same thing: vng -v --user root -p 4 \ -a dynamic_debug.verbose=3 \ -a \*.dyndbg=class,DRM_UT_CORE,+pfmlt_%class,DRM_UT_KMS,+pfm%class, \ DRM_UT_ATOMIC,+pf ':' would be a more natural multi-cmd separator, but is reserved for +T: to designate separate tracebuf instances. If '%' is distasteful, the backup plan is ",_,", since that would never appear in a useful cmd. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 78b06a617918..a6c6392cde3e 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1001,7 +1001,7 @@ static int ddebug_exec_queries(char *query, const char *modname) int i, errs = 0, exitcode = 0, rc, nfound = 0; for (i = 0; query; query = split) { - split = strpbrk(query, ";\n"); + split = strpbrk(query, "%;\n"); if (split) *split++ = '\0'; From patchwork Sat Feb 10 23:49:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199353 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1704867dyd; Sat, 10 Feb 2024 16:06:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVwV/lyU3jdzNz2clKN4F00763C8LXGSfi1yJG3ctD3JFklGaBaGxz93Ks3kITEBDpekGTUwhesvAypFpyofNDssGMlHw== X-Google-Smtp-Source: AGHT+IEs7DWezA49T+84WNYRKtrOKAeDB6ZZJWEfORISYbieut62n142dqKNf87jnu5Ou4h8FtrD X-Received: by 2002:a17:906:27cd:b0:a3c:660:6a4a with SMTP id k13-20020a17090627cd00b00a3c06606a4amr2041511ejc.49.1707609981128; Sat, 10 Feb 2024 16:06:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609981; cv=pass; d=google.com; s=arc-20160816; b=qMmIRr4sv4n6LRd2ZL+JqX6wHc7IPjcFdIJm8MmX8JQsnLRJLFh4o7pm71O2iLlcFv YCfs+uyxlWgR2hUKcW3loF+Ly0GfDG4/gVCXLlY5U6cxKDv0e0YxRxWFVSMuAZKDyzIJ 0kyODrGJLE1Nr22C17Kd+h5eLLo07v3Ky+0pOc5urF9ts/q+3POVZB+0F8+PdZ1voMph rMt+w11GhfChnH6pFKEmEgNBFYCV2rEMaiDn0iFmkgoDCVO40EuE6LjB+g8Ie4H4nTnh qsHXohY909ubzG+hXVRQnmwePQUTDUdNZeCgnvtsoqOAQblSNhZVwx2AB6X0oFpEgt3o +DIg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Ns2ZlXdsr7Utv/ToBSlS0u0tX/sChblP3BD9+95vrrw=; fh=BE7PLtJq/kgSGHgHaTV7YvLnVII4KZDowZR2s1+GBGM=; b=aztUsnLoSw/t4jxnulT0/VbsGOO/C9WFm0D19+DV+pRj6pbyiSJZ0+85KbVdWIPFUM 2elEwF/R/fHSZ+/9lYGT+s50+lpfxNurC8uJW44m2UN4cUC/OE5b8e1xxjTLx6m1Koxo 91fgx4JKgsd0xY+FKXOys2rJzWhvI3Vh0ENMurzrRWMm+jcvXc0DA6oJOh5EbxuyDySp BhDzysb07M0MZT1R194iCFP8sPVk+EYLjjA2etC4NE4pc/aJbF8fP85uUhXz2O0cWT3A 5OXudxr7Zfimmdgvji/amlUgQoXb83T+hqzdIbkEwVMTnr2xvSi18wrx03zkt71YjDie 0oJw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="F0yf/GS5"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60605-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60605-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCVjO/GRcgnVSusIdRCHs50Bd/l1iScPD59OiY4bXl/cXdt3V3l0dDYmSHDatZ3xc31W6g4OGKAbK84TmkVnfprFw1bDKg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id lj14-20020a170906f9ce00b00a3c4d999fa1si579351ejb.92.2024.02.10.16.06.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 16:06:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60605-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="F0yf/GS5"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60605-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60605-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id D57221F26087 for ; Sat, 10 Feb 2024 23:56:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 244B262A00; Sat, 10 Feb 2024 23:51:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="F0yf/GS5" Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (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 4669E627E7 for ; Sat, 10 Feb 2024 23:51:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609070; cv=none; b=h0wK5FHbEJuwDy7YmegulSgv80yef4STdCE3eiN/YeRepBYAVo/5NgExaoIJX2z5mRw5K+wCEuqL8iC9aovxgUZJpd1ieGZNbOuYhKVm83Lf/S7J0ttaEn0CUI1Tdogj8+c+zUsnzOrA2q1u/l/0hd+sorRbDLcehMl0NxEA9ow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609070; c=relaxed/simple; bh=e2HkgHzrnxkaozeso9X8OpimgMJwsOA48wio9rSEU5g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=erG+UoVW7c7v3FiAyAjCnjIhg5Sa31w4rugMFNTSBliAzA/WEXb6GtyxMVvOe6XH1aYqFzjVP1FftickXKUgn1mgWTLMBDfj7EqAej0Hd+M/sbTqQ4PYrlJ/CYckFcNpQ2yXRDM5G06bBBn1a8nZrXFAyVGmE29F9GjQWmRtbos= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=F0yf/GS5; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-5116bf4dcf4so2602396e87.0 for ; Sat, 10 Feb 2024 15:51:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609066; x=1708213866; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ns2ZlXdsr7Utv/ToBSlS0u0tX/sChblP3BD9+95vrrw=; b=F0yf/GS5FIAwigHoSFmBwrq9a76GZT5vN2oWhFmpTJnsnHO+LVXK2pSQmWoaJ6/Uh6 xZzaL2fqJUTDN4szltM4ruZIkAMNJ65NHc7CQjyMqXP3PM8qqh0GVkBqpVDkvtQFeBw7 ISuLWsRBeZ5s/PHz6CXHAby7dvdjkWtXr9VwY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609066; x=1708213866; 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=Ns2ZlXdsr7Utv/ToBSlS0u0tX/sChblP3BD9+95vrrw=; b=BLMbA/tT0wJd/PCvunEheVFjEfTsVnNEYurMoEOpVdF+FVajpn4RzXSfaFyznv0hq3 Gy+den/nRYYY9fNDrGAh8CLzNr1X9kQTlvxqS7xr7Ix0bNsaGl3xggarWznXS472ZdVj mzD3Kp0E5DOiC7Lgp5BeVDRonqpj9vCaOBWf9ydzcVvOKxKgzPB0U1eTFOW3pup3gSna NM+eKRRV60let9Wj6DsfWKTV2ABfv55tROPPI/5xNiSXHPgtSP3+wisZKT8yjsAVEDMk OKCQAc5HBpascViJqWEULVUIIfFMEGd+16g5sfg7AJyvV0PYWTeTSfPR4ptouqStaXlr tICQ== X-Forwarded-Encrypted: i=1; AJvYcCXrPaO4z/xqcg6lWyH9mepWyyvFcZsfXeo57Swh2p2L2JTnlz6HNTTUGHkuXNGzmLvNCQSLzBtHpmJabf5SPLG9Q5YLgt81IVsDgDVv X-Gm-Message-State: AOJu0YzAlrPmiImDBDR2E8R1eAcG6bwxr4Ghl0lAd4zqnEZea6iVFECT Ansrfc3F2v7XkOKRn8vKIFttJpd7pQvicIyQuqCQ2EueAyIpFLHwp2zAmB0l X-Received: by 2002:ac2:5924:0:b0:511:312d:6761 with SMTP id v4-20020ac25924000000b00511312d6761mr1882020lfi.47.1707609066447; Sat, 10 Feb 2024 15:51:06 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWz2FwLx9omz+tWms88s4OYHo/O8PSui851Mih+LNW5OyhYTV3MwgvMWwjdnA96xAXAB2gx7x0KPy/06Kd90Q3zQcy09AzjVPmihWjg6EcM9SMPoWdTxQZz3YrudbSkYPmtG1KzqpRJy3T/wuXP3UaNMPaMBhtkUpPo1hAWmKxdb7vJgKD7quoqRycte4VTZOAmbLseN4WwBNNgQHD1Dsizj7h3Zmc6+CHu81p0eoBgztQ9sbofkspX4g4OTo0h0x2zHyoHHwilz3yPmiiuImi9qYaKl0V/JcEt8z5NJVrPDCOvCuNhwg08svpNp4e1gmVkxtFpq7Jv5xPkc0t8zaNFIlUDfr/ELTBVMZ57fxKg5vNX5h252eXes9r9GeLN47tkfsOTtPwx4dpJrR64+esSytnY4w7ydjHpDKaFe0azEWHxMqYwSdKi0gDoJ2WPufrLTuE87tQTXNsf7OFRiHt9IBYCgL7JBMGLqI9BzP+dprkcQcLU9Eqa4yo/J7KtWhdTSVfZVAob9fMJPvmiyWAomKm3L3lW6se3lCf+hT1uF9vaB7OkpWXsimpK4PCgBHWFqnSoVZ83xb7xqJFu749k7dXzT5MsywJKu+29rmVBh6C2LA== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.51.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:51:06 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 22/39] dyndbg: reduce verbose/debug clutter Date: Sun, 11 Feb 2024 00:49:52 +0100 Message-ID: <20240210235009.2405808-23-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790558843563177274 X-GMAIL-MSGID: 1790558843563177274 From: Jim Cromie currently, for verbose=3, these are logged for each query dyndbg: query 0: mod: <*> dyndbg: split into words: "class" "DRM_UT_CORE" "+p" dyndbg: op='+' dyndbg: flags=0x1 dyndbg: *flagsp=0x1 *maskp=0xffffffff dyndbg: parsed: func="" file="" module="" format="" lineno=0-0 class=... dyndbg: no matches for query dyndbg: no-match: func="" file="" module="" format="" lineno=0-0 class=... dyndbg: processed 1 queries, with 0 matches, 0 errs That is excessive, so this patch shrinks it to 4 lines: dyndbg: query 0: on module: <*> dyndbg: split into words: "class" "D2_CORE" "+T:foo" dyndbg: op='+' flags=0x40 maskp=0xffffffff trace_dest=0x0 dyndbg: applied: func="" file="" module="" format="" lineno=0-0 class=... Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index a6c6392cde3e..4954d3e5be5b 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -871,7 +871,6 @@ static int ddebug_parse_query(char *words[], int nwords, */ query->module = modname; - vpr_info_dq(query, "parsed"); return 0; } @@ -896,7 +895,6 @@ static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers) pr_err("bad flag-op %c, at start of %s\n", *str, str); return -EINVAL; } - v3pr_info("op='%c'\n", op); for (; *str ; ++str) { for (i = ARRAY_SIZE(opt_array) - 1; i >= 0; i--) { @@ -916,7 +914,6 @@ static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers) return -EINVAL; } } - v3pr_info("flags=0x%x, trace_dest=0x%x\n", modifiers->flags, modifiers->trace_dst); /* calculate final flags, mask based upon op */ switch (op) { @@ -933,8 +930,8 @@ static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers) break; } - v3pr_info("flags=0x%x mask=0x%x, trace_dest=0x%x\n", - modifiers->flags, modifiers->mask, modifiers->trace_dst); + v3pr_info("op='%c' flags=0x%x mask=0x%x trace_dest=0x%x\n", + op, modifiers->flags, modifiers->mask, modifiers->trace_dst); return 0; } From patchwork Sat Feb 10 23:49:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199359 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1704996dyd; Sat, 10 Feb 2024 16:06:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGsL7ONp1t2O5LjqhhQsFolEW5wdOGZsVcH1J++VHaXlzlhT5UGcunQCfx6yhiaVen1UL+v X-Received: by 2002:a05:6358:8a8:b0:176:55c4:ad94 with SMTP id m40-20020a05635808a800b0017655c4ad94mr3998717rwj.8.1707610003523; Sat, 10 Feb 2024 16:06:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707610003; cv=pass; d=google.com; s=arc-20160816; b=xA4BlzkYqPc1/0nN3f39oRgDKVzcjrZ/+3QOHOSG64XwR4KPmihVZbziqTO9jTQy/A XA+G2VSSfs3l1NPuueyflVsqFxHY0T6pidEA/XCGaV2icjSXRv8gJhAVvyP65Vf0umdw QJxA2y0rzvzwuGVq1dyfT3XM7bNK0f/gqB6IzhxB++Tq5qYWFsXfoK4SKSys1dI/SAVO LUq/SAR7H+mQwrx4amSLN+U89qG3CTx/vUnHZsWbhjw/m5efgNbLdRqh5Gnq1ybFAe8L nA8DzqLRjMb9tRKMm8BTfVDK2Q89ilV0it7ANqOkZ6cip1U6/SoeWqyf+MY4z/+MoMuA rBGg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=eFBKfV90tnVCKuDzo1hfvS3bOF2HEydpBXLRzyT1NsA=; fh=IE9baq3ULDx21swCSFXXzatP2VnugTTWwenTl0gB9hw=; b=SqVvcQMj2QRzdLmEkGP7Jfqpq63DZ1fNHK7SG6IFbDXrwfsC7bb8gJcsGSg96/NoI9 INtvOIDR33kutXMYd7fXYofnHXUplnFEUvjFC7mwlbMWasY8/6Ti7b2bWDGpAu7mbEoe ah2X9JR5GILaWKESfRiMmC5wuxBsnxPuxI7lekd/IAtOSCMCmpMHbjwAO2qv6n+cjw5I U7FxuZt0Pbj5Gokwn9I0/3o/9kXLekIQG16DkDb1K5ERRUaYVBwEhxBqmuetOGGpyyjE Qduy9/sctiGz+NZBcEsW7EcG5nDmHY0MQYj4Dkkwe8M7SraL8fv9Ssz5TM7PI+r7Yyvp aIfA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TKZ+M8l3; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60606-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60606-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCVTqKNnIEhZcOzoGNkDjlzonVjotXBmUMFSJCU0V802yPAGHCu+o0mTVQ/uTl434U/lhE1OZBhwDFaAOIiwdQEQ1CDaAA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id o17-20020a639211000000b005dbec0a0adfsi4027952pgd.320.2024.02.10.16.06.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 16:06:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60606-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TKZ+M8l3; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60606-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60606-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CFD9928824B for ; Sat, 10 Feb 2024 23:56:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 885DF63100; Sat, 10 Feb 2024 23:51:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="TKZ+M8l3" Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (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 1163162802 for ; Sat, 10 Feb 2024 23:51:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609071; cv=none; b=F7AZS3H3+mL4yjU0MEVf7aBG/AIVFcx9TOkVVeDRuPkUEMttIHfM1D3Q+6H/XPyDIWGQZAMGl/RZlSQ21NDklLwImiyeioN3R918T/ln3iReWqjyiEFKaKU98QOeCKXXTkBu0CLqAlX9yywVhy9DLM+uZm26h8F9kwggSUWF3Zk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609071; c=relaxed/simple; bh=jg05zPtAl9j/yTZ1g89+XrwMdlHjTcXit8rTUQ5mFfE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JtFC7tGl9NPqNd3fQyK+4LvdEW/xdmlzP5L+jE754942Ky+QONa9csTqaK8KecoTJE9mxZuHc/jD3+tFDWwHi2OUMwL57ENMLc7DZOxfXKrX9hf2l4oYzkV4IMHjNEtlusuXLqzQty/taPxZ6tQmvdg2BMNS28Ey1CRpg6oCPMM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=TKZ+M8l3; arc=none smtp.client-ip=209.85.167.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-5116b2dbd16so1948428e87.1 for ; Sat, 10 Feb 2024 15:51:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609068; x=1708213868; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eFBKfV90tnVCKuDzo1hfvS3bOF2HEydpBXLRzyT1NsA=; b=TKZ+M8l3jqCFmiJdbMxuoHcGsdAiwIB7s2LTSrhZIrU4tconuaVdwuGI/wpDquyq3P zBFpEJdpbWs/41vhTSIkj5TBN5sjjhrzfruSQnJqxfD+YiARueN9cHjkq1xFL4UfpCAj pzQ+qK9cZd7vPu1ETaYHLjgizlSOYYtzjw6ls= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609068; x=1708213868; 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=eFBKfV90tnVCKuDzo1hfvS3bOF2HEydpBXLRzyT1NsA=; b=ltSVcnUo3gaffu2LxsBqOY2sWk/zQ7TX83/mbKpB/LcQBLl0k8cWVSsCupvkx8pfY2 K/p1FxNbnGH0HNXzorKxovOz3NDnoYJrNP7wFqjOlI4qV7pRoxf8Up5BwCeMPywJZ6O0 U/E+x9q0+/skOeJquwxxg5chaNjm5mAN05r3SBAK5MPRZ5/uHZ5WEXpHMEpFCSxVWLJ1 zq3T+oKZxQ0Pq8jxU5/2Dxb+e0OZcoH/pbQpJJojNGSjw1+RxrcI/dCft0GZQtAY4KF6 IDNQfl7uoJercBJfLiJGAw1/3N9aWULNlkKUeHv2KDx0JfcFq3IGrKb53xlhDHSithSs ZQNA== X-Gm-Message-State: AOJu0YytFRi69k8Oj7egFI3yQah43S77T1W7wLWnwNqh+9OJh5hp14Hz QYIgt7Dr5YkPKUbCpZNUCJs95+vCaf2geS1u3JlMnxgbb4tJWhDw31eptHqT X-Received: by 2002:a05:6512:282a:b0:511:7b35:9ba2 with SMTP id cf42-20020a056512282a00b005117b359ba2mr1214823lfb.0.1707609068114; Sat, 10 Feb 2024 15:51:08 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU4rfk+26klrsWpzhO0rtSX88PTmmTRwQgnnwezWXQ1kVKVHZL4WhA9+WoWu8qabtVcLE7eaa9eti/qXsWKJV300T6z8WTYnEB4CQH0ic2kl/DbndJ5RAuLDn+3QhlQx6Vix2J6LMWqRljM7ZHI3vLvQzi+bzKg6MwwP4Lc9ANt2t13jEUkwq2doCRCM0NdBckpeK2MC7sc7S9lgRFdY0a2pyxBWVSE0YOr3KJzaFNj8kWeWRNPAElz3q/FaQAYVbOmwN/PmnUExx56gLMaySxBD8pduS61FWQ4oSZimX6hnlNSEn9e9L73RxyHTOM8b1mQ8ZWgy1AcGlJxYJql8PrL2eqEdepClkTRblys83EW4zKmDFL6YiCzrFQdPwMKpuwOuqhl6cvwEGhSN9Lna1P1PGUURvne/pFzCGNTsyKKAnXMyHUVppdJedMChac5jbMepkc2lggiRs1oaxBLpMJEdMg4UqatV9vM4xMJuzo3O/rtVeWaqu5QINhBq0HDUlfVKN2mq8OFFxCD78J717o/8EzhsHZGJTvsdZEQzgPlg1OfWZGwnbNLw9msgz4YpU5GhtDQGi2TLM+pv2rVBjZ8/zBtgHsyxDaSDF5c70AvxKjXIw== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.51.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:51:07 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 23/39] dyndbg: display the bad flag-val in parse-flags err msg Date: Sun, 11 Feb 2024 00:49:53 +0100 Message-ID: <20240210235009.2405808-24-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790558867465667510 X-GMAIL-MSGID: 1790558867465667510 From: Jim Cromie If ddebug_parse_flags() rejects user input, identify that input value in the error message. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 4954d3e5be5b..089765afc972 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -973,7 +973,7 @@ static int ddebug_exec_query(char *query_string, const char *modname) /* check flags 1st (last arg) so query is pairs of spec,val */ if (ddebug_parse_flags(words[nwords-1], &modifiers)) { - pr_err("flags parse failed\n"); + pr_err("flags parse failed on word-%d: %s\n", nwords-1, words[nwords-1]); goto err; } From patchwork Sat Feb 10 23:49:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199358 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1704991dyd; Sat, 10 Feb 2024 16:06:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IGHWMWCtm1q6sxxYFYZH1ooVkqp2dwr790HB3BtpOdGSSbtPcOQVvxOzg3/BtTqFkvB8sHn X-Received: by 2002:a05:6a21:1646:b0:19e:5517:c33e with SMTP id no6-20020a056a21164600b0019e5517c33emr4156790pzb.39.1707610002446; Sat, 10 Feb 2024 16:06:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707610002; cv=pass; d=google.com; s=arc-20160816; b=tyv9eu6XkMdId00fWcJZIevWlfL1wJpR+dsLo56+nArbkDAbVC1I2GulRjXBH8yZUc bfGpouRTpcofEEEP7E2uGNDTXABOXUv+bVXv+V7JYUmqtikV5OBi8Ip0J3lRuIslF9x1 KSmVMKDA15y5CN96d+RLpE2hSJmuHPcSTZQvIMjr584zKRE5RDckOooL4zIfl9qT0m8p 9M4fTwmb49uLAYs4lePpmz2RDsxWUErZj+I0GI3L5ylXBuhelWCO+Gqvnkb5i0rRo5yB RHnwqgV8G97BJ1VGKiFP6Pmu6Z/ztMjSMOMbkzy3S5BZ/eseRVL/7R/xg5N52N0yS51y WsKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=WZ+n5vQl9SXL8QPoIUHsB3HUrPVSipwhNEZ+uqM/u1A=; fh=+j2ttQ603WX+alwLi/gD58bBmlGkvXk/62IfHj09lpE=; b=aoEMui5cEmdxuNxkglpDgXE8EFnvW7qwQ6PRlmVCXDUayJuIhOYmXAgNaNnhFaeovU iM6bLAIJbrSZmwi3sRXJNq2+oICxSCG9ZPJWWIyRKC5x2NSZoU7grm1pNjI4taiEOHLD 9sQ1mjtHSzCBYWf1+gj+ZC6I7HOouu6j3VeUA5lHg5867/EM3aEUD2hmbN1M87lJQ1Fc kQVmpVkxVKhtSgYlk08/2t5B86Yn/JwvB61aqdavnMHaAtB/F+iLMaQWVPIAA5FSIEWq beUfEbEttZWWrV2fAz0ft34Y+4Ivw01BwnXRp0I/fK4IEa2RrSzqzGbHe+KOrjvUC2dS yeLA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DH9efwl5; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60607-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60607-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCVX+lVb9IaDg2aICKGLQvsjU2qU+LnTM8M6RYElLanOzfKXT5oBHpRuz1/iZyovqoCvsefC+fbcoM8po4j5PjeHDSjyVw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ck15-20020a056a02090f00b005d8a938910bsi4228654pgb.429.2024.02.10.16.06.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 16:06:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60607-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DH9efwl5; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60607-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60607-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C6CE3288567 for ; Sat, 10 Feb 2024 23:56:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CDF4F63119; Sat, 10 Feb 2024 23:51:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="DH9efwl5" Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (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 62D5B6281C for ; Sat, 10 Feb 2024 23:51:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609073; cv=none; b=dlbOfd5Up4x2euhqQoCbkoGEus3OUp2Gg+LRNqyNLzG1s8ZCYqLyP9IxAVhGj6DH/sQ5LroyNNxcPzVbdJtVa+0aOvM0m9wec/EeR3/Rqlwdalms5/NJB2gfm0TjwJmyJWljc0B6fX7P8LmrOTQsSRvyYROvlAXwe9aAW/d8DnA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609073; c=relaxed/simple; bh=Id7179WCdgrN+FSm22opqsAgq898l20m29SsJvJcSX8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WFQz7aDbJJdJQdLa6OtfzNZfoUqwXiedJIqg1o38YwqxNhp55tA77Cf49aZ9cUAt5zg9cDCu3YIZr21nhH6YToGqXK+oP/fokqoX55VXMNG032sZxOTheXapyit+xzVeFg2KsSWm7xUHgwnxtcsQBsW1Xt3+Hs15FFJ8Crvl+UE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=DH9efwl5; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-51182ece518so659242e87.3 for ; Sat, 10 Feb 2024 15:51:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609069; x=1708213869; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WZ+n5vQl9SXL8QPoIUHsB3HUrPVSipwhNEZ+uqM/u1A=; b=DH9efwl58sNiWSlsa7aQtkipzrw+KI6G/A2+z5DY0t+KDmGhvIaz1sMzbqLOJ+Hpoh zu6qSzVyXjJBT5ExOIuzZN3NKPCudrpSO1m5mSGuqVdLZi4sMwrLMFQT58QsbFe/xxTu TWbDu8yPqYztIqcdrk9Jzky8l1pAg9GhScmCg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609069; x=1708213869; 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=WZ+n5vQl9SXL8QPoIUHsB3HUrPVSipwhNEZ+uqM/u1A=; b=E2umSh/Y+dVH1/d7V6Q/0pc6Y/L9YKQPdt7obkjcVWgoB9g7xNWtGrkydfc5Op12ZJ ckhCV3x9493D1/h4eLfd5IShBcJ3IuIDbeuFg2jXjJVUUyAEWP5G1Fsc1kT1VagPiTN7 BUy1L1P1IQzphDmNUPG0WuhaSG96uOs1o/anAydbuH/XM+a0wldUn065zi9z5FzllD+z iLS75ObENK2e/2JcZpaKOREUsyXR1Qz5SS9YtkSJGZ5j4fXeXBchir0Ppq6O8T3PwtNX ESrbqpWw6Yuzru63V+kL0wHYy8UgEQGAcAAMWX6jRuoT+g5zOU+GV8cC5b35w4XJMSyW CtpQ== X-Gm-Message-State: AOJu0YxVwyuscdIxzm5H9v4FzHUZQ8IaZ20aQtaVwLgLjLtElCJVQ1W0 gSku+Tc7nIzGhGaVaTbvsifywfe79p1q1VajIjBdQ5UfjZ6y7xIXARzcRaFt X-Received: by 2002:a05:6512:400c:b0:511:5eec:9b9a with SMTP id br12-20020a056512400c00b005115eec9b9amr2585367lfb.52.1707609069628; Sat, 10 Feb 2024 15:51:09 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU84YU62Gbc/sEoczwbwEueJdzT/vpIAqq0rJ3WslSyzSBLDrnvQfM974LIVoraHFAOYB951XUfArwYNDnheW1sLxBt30Yk+lwPwom7izbVUaBQgeArK3qBTTP24bfn4RkvSKhSkLlg4fs25h2yP5G3hbBpWsmiYbhn1CVT8yEiR5kSrMRulJ5aSjSeStP8wgD7a9qcS5uEl2MQECGvwTg4qKqWPidfZJhGAJ6JsuJzQDBApAT6g8udBuwPZ4VMVOpP1TBwdrdSxmZW4ms/nyIQGb2yDpw6StIFbVbXTfqKp4QFcpvqFBUNqul9WKAfVN6b94gs28nhxltPSykpKMnWZ80k9lID2elJXPE3Y2o4rDskSow0m/2P0BazOHBNNDv9JAFXT3sMblBvhXyJiTft6QaOzMDzxp/pKok8fHkcm6ZJAu8VktI7hMOm/9241kY/75+13IAS/1Q5Qw7fcvZdtSZGRpRPylrHZmiY/XYnFEGi/LfAHrQOV9YeBse+nPi566IsDXwe2oJMHmIurBHwxFZYUQDorGAzaoYSm9ObUUEk6sFLljVub/QpLtoQOvxRqAYzhy6z6ehuzxtHnWNuuXSsQDTZ4lDqXOvF3OxhVnEKKQ== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.51.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:51:09 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 24/39] dyndbg: report err in ddebug_parse_flags when read_args fails Date: Sun, 11 Feb 2024 00:49:54 +0100 Message-ID: <20240210235009.2405808-25-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790558866146800420 X-GMAIL-MSGID: 1790558866146800420 From: Jim Cromie read_args() fails on '_' (the last opt-char), and returns null. report this against the opt-char. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 089765afc972..3d0c6b5faa31 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -903,8 +903,11 @@ static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers) read_args = opt_array[i].read_args; if (read_args) { str = read_args(str, modifiers); - if (!str) + if (!str) { + pr_err("err on '%c'\n", + opt_array[i].opt_char); return -EINVAL; + } } break; } From patchwork Sat Feb 10 23:49:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199360 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1705105dyd; Sat, 10 Feb 2024 16:07:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IEKfQHw2g0ViWRZt9HU3+3vrvRcZPTWXE+fvKgG20jzLH3+/lGa7uRa6jJlcsAlfgzX62r8 X-Received: by 2002:aa7:d6c5:0:b0:560:c364:2cd9 with SMTP id x5-20020aa7d6c5000000b00560c3642cd9mr1969925edr.17.1707610021872; Sat, 10 Feb 2024 16:07:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707610021; cv=pass; d=google.com; s=arc-20160816; b=rH42TrhEARZuAIZk9arjsdSl/ZD1QcsaH21igrrg0gR346BniYVXQghNtH0T6mb0WJ Uy+rq3qR4RHpBR03yt+e5l2ppuiBHeoN2b7Zx40r98mQYHoaEKkDbcVv+1a24sea04eT 2d3eg95/eMtGEHFa1rX2F4Pc9ZUnxkM1we87yunKYiuEDuLKl/HheJcgq1xxZzYrrDKB 3iNQOU84wyRx/MXONIlrEd5olJYiI91z3JsQzk0cj3vwyj+6Pn6P1sBR7WwLQYx6ZIQF w4aZKHTWaXpRDD8ALg/ebIpPphdcKY2v0+bbL6LiezWmOi5CIspnwA6hO/3J0CSwAml7 cDGQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=zmhUVgCdk+qI3t9KK3oQMBouh6tU/rMtsVjdtdgFFTw=; fh=Fq4PZRNYFOroccVnoFOeAae3bRwGDc2CKn54Mg99mS4=; b=GTxoUJt7Tbo3FtNiGZnjcGatvZtScS7cAS85zTU23H5pOVLYYXL2JFd+7WIuXSxK73 bVbFFIYEftf8XUmdIW/fb7LN4QpRjrfrE6kNAsWaBJVl9yPblOhGMQHp112wOsT4g3p5 G4+icJS/0HpesZadnwvexA0lFsohQCeVy8o6TPAiXtmRGHOO5k64NakxnCkLr5qynJIj PQiaWqnkHY/I3Y7+HnoazmhLB7Jf0ghx4Bm/JozpMDHEi+WeuROiBlNTaQC5bMEv56Ll 9sd/XKwYnL9waKeOKBCoIQlNDaZx0xkkg94rTh88cLhrMfayI8UaC2yC/pMgXpd4xcxi ORtg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=oQ8n6kz2; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60608-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60608-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCU4w0te5myk3YLpjDenWa/pOZMsaBtCEQJYUv0EeffmqMuL4PmyetDadIHHRaal07HXc9DZMw7rQus4YudvF393sUIF0g== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cz26-20020a0564021cba00b00560bae23c2csi1306370edb.3.2024.02.10.16.07.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 16:07:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60608-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=oQ8n6kz2; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60608-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60608-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7E84A1F26A6A for ; Sat, 10 Feb 2024 23:57:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 12CE3633F1; Sat, 10 Feb 2024 23:51:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="oQ8n6kz2" Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (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 0DEAF629FE for ; Sat, 10 Feb 2024 23:51:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609074; cv=none; b=lKYeTybRPl8uPV3tkgKJagWo2q9Bh7PcNqRa/GQLlnVXXPfmU7lS2ZkreULrYk6y0SQz2ZczGVEdDn/+Dws+2RaZXRyv+lA0HqS01VmZJAa2WkqDOLUCSVGJbYyrvpLmYg2QausLHhXKmHLB2NPDPw+vncx8Wj5X4uXKZwCiO3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609074; c=relaxed/simple; bh=32mpD1IVHOqTValUWgcEdGTVskgsJqtMGFjqMVc4u/8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=otLgBgS/7AM0XZS/sQeeRFtwKnhzhuyljk6s/JwCEZXXP48sx9VVsJPmD25IROTTGJhz5OOlPk+WxiJpn21YblvZFLZMKq+iXs8nzuzuskkrFo3x1hjlpfE7seyC01dh6y2AzfuwratnO8JOV570ZfX2qUZcgFWVPXSWzhDCUUw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=oQ8n6kz2; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-5116b017503so2861773e87.1 for ; Sat, 10 Feb 2024 15:51:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609071; x=1708213871; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zmhUVgCdk+qI3t9KK3oQMBouh6tU/rMtsVjdtdgFFTw=; b=oQ8n6kz2hTq9NAxDYpVXRBqEkqp4V4B4wkx7uxBqJOpyG7sgp+0+iDmCeejgUKwPQT OpRtM0D1V5qZlUGQDE+gZHrNazE8EpILKn7m+Idg39GJVGm/Atz7VGdduVGnaIgpPQyp QTlEw3jS1R+hcC9pf+Kn594lGqwio/amWW1pQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609071; x=1708213871; 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=zmhUVgCdk+qI3t9KK3oQMBouh6tU/rMtsVjdtdgFFTw=; b=ZGwvbPPrb69FiNc4xgoqfpAzfrpqxFmG6yTeXLSpMM7Emam4dJZogUM1TiiBNN23D5 1EfqLfLsWaTVa/OFccNfzJXiqjwO4vj5Tf3OkzZFXGAGMoCHCcbSH4ErxnFxb67pwfjS FTYXKOhESWnIV/svBbMDBqzb87eem9t1quV0HPqfh5uO3XtbzqbLQywtwByHBK9UQEss Gbth3I+Rs7ZZBcO+5pu3koqLIu3D/Z5UA69BV5zINwZVe2NTVcNTklXUfHattrXxVmEe e0xUNwa8uA7nOT0oT/Y34KjMCIzlyoHX43Bkw1dUFI4GVnaFSN3fnWYA/SiN+PHzrFAa a+wA== X-Gm-Message-State: AOJu0YxoIrPCQ0a9fSinVIind8mTJy+/CiYOAJwmeleiAB6VOS7yU2mY m/9KVlq4J2XVJ8mVB0qLgAEeaC1WvWAlRXmycz4DoFBnYfEMcq3Mm3ZnHSY2 X-Received: by 2002:a19:e002:0:b0:511:5a9c:c9c9 with SMTP id x2-20020a19e002000000b005115a9cc9c9mr1917171lfg.16.1707609071329; Sat, 10 Feb 2024 15:51:11 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUFk5okXDi1WEVQdBUJMHlW02yUykfeDQpGNrpbCjqT8LDj1fDrB3RNq76mvm7/DbhbCY1KYUPMD6sXwodtifxb4LEHnndRSiV9Mn1iEZKPuc+RWiOBA6ioX9zBjQJgdrAZ73EuzuEiw4G1Wps9nSIiLmTdrExBGNxaPGPyhF/+slIe4VHb6kgnGIH863+82tiPGvi9ZNuV8b90kv4aMdrIMlQ6joe86hzIJr+Y9bXI2KC564pm7+kXOS906CsDcp/j8b8mIl6Dd9Fvjv1xhp2gpDOg7C1wIDnnyg6c03RRwjAMm3U9zHMvt3rudq3FuSSboWDe/hEme0Z5IXKDawdEFQvvaN1j/rRQKpfCqdWtCOW/Cumzk0uWXLJAUY3xutTfmLod+GIqDd8HSfFb94+vUIretMnLXDLSyS7G9i7bGuhliBRCdi1qFvLa/bn5cMjtLiqDCDnjRjB6zHvuzliqsKEHOxm8V07uUExQO29F2UUVkQOccrSzdDL3xWXpnd1qVsCCk1yt9O31HQmUixw0LLB+W8daokmECaMc3sUsyZsJo6eA0ss5Pfh81/4Ax0ZMwpJueD1RazBtaVPBDMugkJOvIVEVpnzbCrPOb4Ub85Iucw== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:51:11 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 25/39] dyndbg: don't process queries when trace cmd fails Date: Sun, 11 Feb 2024 00:49:55 +0100 Message-ID: <20240210235009.2405808-26-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790558886013767717 X-GMAIL-MSGID: 1790558886013767717 When trace open or close command fails then stop processing next queries in multiquery string. The rationale behing this behavior is to stop processing queries which might be dependent on success of open/close trace commands. Signed-off-by: Łukasz Bartosik --- lib/dynamic_debug.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 3d0c6b5faa31..d8cd40faeb4d 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -939,7 +939,8 @@ static int ddebug_parse_flags(const char *str, struct flag_settings *modifiers) return 0; } -static int ddebug_exec_query(char *query_string, const char *modname) +static int ddebug_exec_query(char *query_string, const char *modname, + bool *is_trace_cmd) { struct flag_settings modifiers = { .trace_dst = DST_NOT_SET }; struct ddebug_query query = {}; @@ -954,7 +955,8 @@ static int ddebug_exec_query(char *query_string, const char *modname) } /* check for open, close commands */ - if (is_dd_trace_cmd(words[0])) + *is_trace_cmd = is_dd_trace_cmd(words[0]); + if (*is_trace_cmd) return ddebug_parse_cmd(words, nwords-1); if (ddebug_parse_query(words, nwords-1, &query, modname)) { @@ -991,16 +993,19 @@ static int ddebug_exec_query(char *query_string, const char *modname) return -EINVAL; } -/* handle multiple queries in query string, continue on error, return - last error or number of matching callsites. Module name is either - in param (for boot arg) or perhaps in query string. -*/ +/* handle multiple queries in query string, continue on error with + * exception of open and close commands, return last error or number + * of matching callsites. Module name is either in param (for boot arg) + * or perhaps in query string. + */ static int ddebug_exec_queries(char *query, const char *modname) { char *split; int i, errs = 0, exitcode = 0, rc, nfound = 0; for (i = 0; query; query = split) { + bool is_trace_cmd = false; + split = strpbrk(query, "%;\n"); if (split) *split++ = '\0'; @@ -1011,10 +1016,16 @@ static int ddebug_exec_queries(char *query, const char *modname) vpr_info("query %d: \"%s\" mod:%s\n", i, query, modname ?: "*"); - rc = ddebug_exec_query(query, modname); + rc = ddebug_exec_query(query, modname, &is_trace_cmd); if (rc < 0) { errs++; exitcode = rc; + /* + * if open or close command failed then + * do not continue with next queries + */ + if (is_trace_cmd) + break; } else { nfound += rc; } From patchwork Sat Feb 10 23:49:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199355 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1704888dyd; Sat, 10 Feb 2024 16:06:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUVm3Fx+XaChx10ehIIyObb9O/pHAta++lQeFIHbXivKrtVHLnrElN7bKOBzHvRPUUbZEejtuE4l9o3VTUPrKS6t6Rz5w== X-Google-Smtp-Source: AGHT+IEIv8PVALRKI+8wvS0mQEwoZYtuN9mS0ccTI7TdvrfsHVBh5Z4hZQ0Dp3KNzY8khv5hmrxb X-Received: by 2002:ac2:558c:0:b0:511:4ff5:4dbc with SMTP id v12-20020ac2558c000000b005114ff54dbcmr2021150lfg.60.1707609985093; Sat, 10 Feb 2024 16:06:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609985; cv=pass; d=google.com; s=arc-20160816; b=jlWxiRPdENQwcr22Lnmoacsuo83NZ/bMSfAnZBKxfePTL0g8SXLdUXI4QkBNUJXbIL WY01wq4g/FeGEcU8vWjtUgb9lvN90LZTWp11/ObGqkOK/fl+sieO9emB6NcsQzGcyKu8 Y8zp3HdPnceKTnsV2UtzneZMm1LwqKxX1MsqlK8S5rN77IH0zTqYqigshSl6TNLlXwGh xicveQfPXUzyj8lxgCSaZtt5ILivRJvgsAu4HqNT5fNPv6W+aqxA2GQfAWrw5Tlk3IVR X7dtSKT0US+H5s30ZY1eMNwulxTYbZV5O/xyePNANEmNvNhSjhnub4dxv59/hccSAJbo gZSw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=SmuP22pE2p+4QTMWxcu2yqFJ4oYEpoJdJHaC6boMHYo=; fh=llC/bH9jOvdbuUgLfKy334RFCn8+HwoRNOxxMkbwlJI=; b=eOeTjuh86e1aHMHfHgZ0FosLZaMp9/sxc23rZTER1Gdtnu3bP1E3dMUGh8Tp6eM0C3 +8eWzhEYO7KQ766fS7f9K/7peRzICofzBhNu0H/AwziRi8V0v8xhe/nyG4KDIH5IpPef IjHClSMS+NgVoRXxs4av57QukbvLG+f0Un+wXUNsJ9/p44Dx4bQrP/OuwzrFwWRkLtVy 4lbG18t+X5VXi4sff5Qv6OZnXBcYH68bmL3EW+KUD6H66jc/8Nh0kjk5ZsyIvwZA+Tdo BPvGm+NmFp63T5XbExgxE1xphi7Sm8wzlmFsDeiLyb1mQMhoxEJn6GiAKQLuM6/hn3kn qPsg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MtyjvORI; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60609-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60609-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCXLtXr0pVtIoy3i+S5j4mdEeec7uWIqDDsOcvP/zLlujvXBC3QXVXOvLXFFecFOkpHYX6WbSEa/cmiwF2EfmEc86S8fqA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g27-20020a170906395b00b00a3c551aca35si461167eje.626.2024.02.10.16.06.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 16:06:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60609-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MtyjvORI; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60609-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60609-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id D74781F26DAA for ; Sat, 10 Feb 2024 23:57:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C787633E5; Sat, 10 Feb 2024 23:51:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="MtyjvORI" Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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 A079C63101 for ; Sat, 10 Feb 2024 23:51:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609076; cv=none; b=FXi7MAehCdyZ24ds2CWicRH5GSXe8WWWSDkHBALdoffbJzUHU2oDKAe2HCUGbCGx/N0Ini323cPd/CbPXKSqqAFZobOTJdJmOJzvdK+0YYDZXEubhAqsqa/9jEcrvbyLYndZGvCsrip6LnXLDp85Z1T2RB5yBreew40WOBMngMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609076; c=relaxed/simple; bh=Q9a02DWXVcGFESvWK0VJZsN0BHwc8jj3rMZ5PtMrKP0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sD5qSLEMfvVUDv4RWmhjZLFymAtTrV3x6YlRwfuz0TuZB3neiltDzfVlEz8YBisdXd/uBnF3m8Ir8YCx3iRsDsAj/nqh1kafJBo27TWKkjJ14wg9+9bmI9Rgd1KwuddRAEf2vKpNLckSih5HVsJGi5dJAUDzBklC8pYpr3FR3EQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=MtyjvORI; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-51178bbb5d9so1840857e87.2 for ; Sat, 10 Feb 2024 15:51:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609073; x=1708213873; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SmuP22pE2p+4QTMWxcu2yqFJ4oYEpoJdJHaC6boMHYo=; b=MtyjvORIqM841/h/dJwlHtto/2wJkB/UbXh+voayItWdH2zaDzjRlBaE5Ia1EMYmUf oLLVewGMVOpw2ZI1N5IHl9zCAk7PJnpLetVJfco6t+nQVzXKQrLcZNPe+4cXtckcfagv Mzd7BTfl1qTUEaacv0E1ryjV9Bbcylc+ohlTU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609073; x=1708213873; 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=SmuP22pE2p+4QTMWxcu2yqFJ4oYEpoJdJHaC6boMHYo=; b=t/LwbYRKTz7R9+3zxeOR7WEcQBvzN/YAcMoWVwEDf18btlBGbG09IFAhbXTBgU7P/w uGHlDQ8kKhd8uJCdedqnJjBGOykVJJODu+E7NgZsVk6Ux8Sax/ohtHVQvpVEq6+zOufU kP+Pe4gUnS1RWqgI4RLEyMxe15Njj9W7qvNnXXrnC5udv4wL/KjWw0v6Yh1KKGx7wK3n I7SrXteZD+HTPiICkil4zdTVRYOTHWnbrCHMzaAsCRS35eI2IL2tONGkOGzDv62jlVGs EvAGTxvYqqoLRMLUjZ4BfhKuYZGZ0fyUaO2JMUCfhqArHjGEq1ywdwEpcU/5jIT/8HXh 70Mg== X-Forwarded-Encrypted: i=1; AJvYcCWT37yv7Xgn4LE1Cgcx9K/LCxwUDIdzaYULZLR7dm9hI+PHg39G8Nx51IkHGVVcNBjPy8w6AS5j5Fciq+tKb1vXF8bt/21G7eUf8OVM X-Gm-Message-State: AOJu0YxKgo8o5CmNMuxd4FBkm14+jN8fGhjY3dGO3Srx4vxgXmmAMcrb XHueah2UdlKZYN6FADWNkQFCbv1EKDlYHBM1/sL9Rw5P1E/hiEc6PWcBBGdf X-Received: by 2002:a19:ee0d:0:b0:511:6158:498c with SMTP id g13-20020a19ee0d000000b005116158498cmr1743792lfb.64.1707609072918; Sat, 10 Feb 2024 15:51:12 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVdcCf9GIrQOCWCgWqiXFAhcblouycJxj7aTC07HVzNWnvPjVO6yFPsJdSQtUxtjl++i798B5luFdzW6wqNB2ajAOmv8v4ltPx+Nm1y4jLq5preWH49bk+Kw5I1klfo0l7DXmyT2FnncIFwxOdPWrcWNYM25xKsxg1pbYWqJ8KkLEn/EhSkiwxnJwimHdjQymqPeUqpH3hPWyRlBa3JSBAfdg75P9pdhL3E/kvuE8h3QCf4QjmlJJg6gmxof357Rs2H7THPGH5OoWDq6HnZcLPwMOfa6wCRUSfDpVgvSzlDHVP/8/816fP848mLPNoodIQcFeisvHsbG6B9gi7wJwopBIAlmRvu1+i3XHQIzse4YlnuioUxCIque7IvXxorIyIgd0jc+rV3Q1ZQJS5nhwE+R12XhNgC87f/rml7yB2rDdSc2hX8Z/aqMa/shegt6tGRJi54A3NZGq++ScvZZq+qrT2ngGajMmLuD+1x6YrHlYwN7EnM0a/q1zsomTLJv3mBWNqGyVf3qZj1AbFQ3fssjIdpD7n2wAsQhou64AS8JkTWx4CXK2dz1lk2+VLEM3IPIL7Q55MOzhxv7/5YB8FA7u4Yed7CFZt0ap6RQD9Gtua0Bw== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.51.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:51:12 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 26/39] dyndbg: warn if no flags are given Date: Sun, 11 Feb 2024 00:49:56 +0100 Message-ID: <20240210235009.2405808-27-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790558847973182441 X-GMAIL-MSGID: 1790558847973182441 From: Jim Cromie Since [1,2], ``cat control`` has displayed callsites without flags as ``=_``, to positively assert that no flags are set. It also took that as input, and the docs also tried to encourage its use, allowing users to expressly assert that all flags are unset by this operation: alias ddcmd='echo $* > /proc/dynamic_debug/control' ddcmd =_ # assert no-flags ddcmd = # allowed, grandfathered Now, warn on the latter. This allows to disambiguate the meaning of the :