Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1467045ybt; Sat, 20 Jun 2020 11:13:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4cb8AUZ2lUs1ujLQ89DUM1Cv5pAWpDS3PAGGktOjPXl9lvIZhxJG8s5c/K0sZQWlapFjl X-Received: by 2002:a17:906:cd06:: with SMTP id oz6mr9372509ejb.434.1592676807113; Sat, 20 Jun 2020 11:13:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592676807; cv=none; d=google.com; s=arc-20160816; b=Eb0WjTOYpIVL1TXnjBRveANx2A5wV2mEsEHdjBVmF2KIeNnAeja9lae/EnlYzKrrCM eEfaGAxZaDo5hlc4cQaJmBVR9MOtBv/UtuAFlYlOHyC56WWorUpVwc4LlLUpVB/6Dd2U pXrBUXUaO5yZvnWBp28dGCgkH0Kwo7ySXOjASpBdV+CHkW1aEiV9Rs08fpgOzXLuRlls kCWm0oTxT+c87xPx+4UjpDgsX4liMbunkfrPXwLvlXqC+gQ7schZ2LLHLeiDVFkwvMHq lBAGM4yHMwkNPsXooP19a5IS8Lvj6Ub51DHC6TtT4c/mKAXXWih0DV0V8pCaRfHyopRq ACAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EnXT3PW8nTwygIS14g5I3CFsVSKz8zN/W+2aXewNcIY=; b=nL6tLQ41WPGybIhVf2emgtLbPc/uW7IP5L81/XFlmg2j8+6llSMjmOROdvPPnbYkWs 7xQ3v+OSDAJtIDY5h+RV+Ki0pqbo11hWoz4zJEJ+ir8DT2Dh0mP1hGH/wAgMiEpsvU5m SSokpTb4FK3FJ8Pmnp2mhsTgXCKYPOqXn9Vv0z+bBedxSgYtmkyVH1Eg7MBUzZkanXkV RZGOdkb1ShuX3BWzKOBx6+tQ3WF4Eb3ILr8bacOs6e7peJhqQCeU/BPWnAuF7CQukBxE gBdJQXqNwbDloEhui7QxZ7McEUCflEmZG2V1CMMyAe9ZJAkWZ8+YoyEj843iyBNIF/is nm/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rHoyjb44; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y3si6043104edv.448.2020.06.20.11.13.04; Sat, 20 Jun 2020 11:13:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rHoyjb44; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728598AbgFTSIk (ORCPT + 99 others); Sat, 20 Jun 2020 14:08:40 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:41866 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728541AbgFTSI0 (ORCPT ); Sat, 20 Jun 2020 14:08:26 -0400 Received: by mail-oi1-f195.google.com with SMTP id a21so11623265oic.8 for ; Sat, 20 Jun 2020 11:08:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EnXT3PW8nTwygIS14g5I3CFsVSKz8zN/W+2aXewNcIY=; b=rHoyjb44kmA0/SQbwSkZqc5Qm1Yp9qMWr6j6kehPUPCyDPr4+gtmt4Q6j5xU62dPQh MAmVrwKk92NhwJLkks0yL2LuHUD7KI96+iJi98kXXqqzPajLRCHSsJ/iX+V1tG+7v6g1 BQkTJsDn+E5iYPMWYnyLbjXk1B8aqTOrLpDztIBLhKclp1u/xneI6y3QIjT38/QjUrjF WMblwt3y8qdUANOP6bU/h9ADAowLEDk3nkwzc9K/kWjwHDuGOErSdg5AfHbRUcCnwPmn q6+ZHQ1b3NTlnHZ/PrHX+4Ck9S2bevFJJqCZIOhNeNBs+fviUl1E/CBbLsYE8vPYTLFE z3/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EnXT3PW8nTwygIS14g5I3CFsVSKz8zN/W+2aXewNcIY=; b=RHeeRpGeDhKY3sN1aQebv4v+f3bPkC4kPHRmyKDm7Yt5RnDqG3hqdXvG9ImvOWpD/s OS/GcKcBaXs2PD9COSalzxpbdkaD5dLnBEzmSEa9xXMyjktPwc+cXzMHi6prIXKuttxS yQ/aSM/RF+FcYZ02Sf7zUNMnZIpW3RQhlqT8K0VnoiVNIddC9QYFQjuIZXQosgP463iy gOxCjw6ypiFA/6UCWmmMWRBGu25bbcqLwPpa5R67tLWHrfwneTtOa5IjJoiCmAVFPrTY 9Nlk91LHcat0hopFZeNnbOhEIRsaVWNZ4l+rqk5J0o/fQScskbTq1xrRyEiRAjOlILmO ibiA== X-Gm-Message-State: AOAM530PhmG+FEnJEjWHD3PY5WbP5tHnFwBvr3LFxBUhzyZ/vmA3knL9 KXqCoCMx2MchlKKbDJQkbLs= X-Received: by 2002:aca:5184:: with SMTP id f126mr4576653oib.134.1592676444603; Sat, 20 Jun 2020 11:07:24 -0700 (PDT) Received: from localhost.localdomain (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id y31sm2077901otb.41.2020.06.20.11.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jun 2020 11:07:24 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, akpm@linuxfoundation.org, gregkh@linuxfoundation.org Cc: linux@rasmusvillemoes.dk, Jim Cromie Subject: [PATCH v4 16/17] dyndbg: allow anchored match on format query term Date: Sat, 20 Jun 2020 12:06:42 -0600 Message-Id: <20200620180643.887546-17-jim.cromie@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200620180643.887546-1-jim.cromie@gmail.com> References: <20200620180643.887546-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This should work: echo module=amd* format=^[IF_TRACE]: +p >/proc/dynamic_debug/control consider drivers/gpu/drm/amd/display/include/logger_types.h: It has 11 defines like: #define DC_LOG_IF_TRACE(...) pr_debug("[IF_TRACE]:"__VA_ARGS__) These defines are used 804 times at recent count; they are a perfect test case to leverage existing format-message based classifications of *pr_debug*. Those macros prefix the supplied message with a fixed string, Id expect nearly all existing classification schemes to do so. Hence we want to be able to anchor our match to the beginning of the format string, so ddebug_exec_queries() can be more exact. This gives easier contruction of reliable queries to enable/disable those callsites. This makes no attempt at wider regex features, just the one we need. Since this is a corner-case of sorts, lets examine one more, hidden in the example above; note the "module=amd*" query term. // normal usage ddebug_exec_queries("format=^[IF_TRACE]: +p", MODULE) // wildcard 1 ddebug_exec_queries("module=amd* format=^[IF_TRACE]: +p", NULL) // wildcard 2 ddebug_exec_queries("format=^[IF_TRACE]: +p", "amd*") Now, I doubt that "amd*" is useful here, but I dont see a reason to preclude it; multiple modules with coordinated classifcation schemes is reasonable. That said, a single call can have multiple queries, each with an exact module name. I also see little reason to prefer either of forms 1 or 2. Its case-by-case, judging brevity, clarity, and query specificity and robustness. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index b00f536d6d12..d737c733967a 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -176,9 +176,15 @@ static int ddebug_change(const struct ddebug_query *query, continue; /* match against the format */ - if (query->format && - !strstr(dp->format, query->format)) - continue; + if (query->format) { + if (*query->format == '^') { + /* anchored search. match must be at beginning */ + char *p = strstr(dp->format, query->format+1); + if (p != dp->format) + continue; + } else if (!strstr(dp->format, query->format)) + continue; + } /* match against the line number range */ if (query->first_lineno && -- 2.26.2