Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1465624ybt; Sat, 20 Jun 2020 11:10:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6bfHQB6qlMEkwtk7QDKBdHLsunyu7AKzfOpjogeStXOFLUKc7jAm+LduAKATNmAvfH+7R X-Received: by 2002:a17:906:7e5a:: with SMTP id z26mr9182526ejr.263.1592676656388; Sat, 20 Jun 2020 11:10:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592676656; cv=none; d=google.com; s=arc-20160816; b=aC6E2Kj4EhPVtz7dF8lPVn20fRLS74gqueCTGY4oRCap2X9CjE/91UqkhJkcNHPhHB e58HE+76FMBcIvOMZcHT7iYwj2O8+nUJxVHMx/9Rw0kuqZyaYpOGi2ncu3KZrU5hwbRn orq1OLYUICg5zHB67ovNiFIMWxYPXEhGBUBe7GATbw4gMeuTONGyxCauYiGZKCP50sud eIFH6aizR1V/lNKShFi5HKVxbVpMWsn7XV18nZNvDvgOxmG1jsRglhAZJ42nUjgNTFL4 JGKphTmcQAuQtszLRy+cbunr7fsmGCgP9RIBrG6FuaSz8cdDBkduZxy2wXU15TaHccwO wJHg== 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=tTzMdBwq+C8/w0jNkBXGzxyfHf7JC4tZwdc4uX+IGGQ=; b=qbm8fwML3lzo3eQQSsumPaoU+PBMZJJgjjcx20E+hqVnzac8iut2QauwwWn1pJIun0 N8A1J2DP1jO3Fb+rdk4VXhSRNk2+8RkIHPd31oZ74eLybWqj0Q1dW0oceCFqDC+tUAQd GNR+RF829Fb6EViVaDx/rNY+fXr8QmeE9eBodSzmqKz/GjfLb5GCtE5LA2hlZAxdQpQ5 wpbLrDY6oSZzwn6fXvcpzEga+YTedjXCrMl7f+vSZ558PlGHPlF+/poPFjRws8Xxnnl5 PnM97zoe39LLY8vNsA1vZwFyZOs1JOMU3EuPvxtFMLOdwPXosjkpjovpSaDlfspcBlC8 uOgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fES8RKOl; 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 du12si8374423ejc.441.2020.06.20.11.10.34; Sat, 20 Jun 2020 11:10:56 -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=fES8RKOl; 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 S1728557AbgFTSI3 (ORCPT + 99 others); Sat, 20 Jun 2020 14:08:29 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:37350 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728528AbgFTSIY (ORCPT ); Sat, 20 Jun 2020 14:08:24 -0400 Received: by mail-oi1-f194.google.com with SMTP id a3so11646415oid.4 for ; Sat, 20 Jun 2020 11:08:23 -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=tTzMdBwq+C8/w0jNkBXGzxyfHf7JC4tZwdc4uX+IGGQ=; b=fES8RKOlm3MoKwpelaJutOmnpbwrNyUaDJGmFGVVhilxjje++OLgnWzGzP3k/JmwfL lirmd7aUGuzy9BRVjfVKmy4kGIoiMPJyLuQt68lfmdd3b/EYs9QEqHXDu3lcmiYoCsR5 CuhkQf7f5kbqKz9CkbQpkpKwwMH4c25pBidYNdxnIlfKbstA+cQVTENCPEfeYUcdil2v y/EeghcLth/QW+jBygLj/5EnRWdJ22gOaUyIMFnBaQ+6vEjjB3mWNJjANDcIYCSrkjsB nZ8kfEtL0KJ5fjeZQ5aSKeWQnB59SD3DH2/5x5ehnDNUNf3aDCldho6L00VPqavJGW25 tLqQ== 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=tTzMdBwq+C8/w0jNkBXGzxyfHf7JC4tZwdc4uX+IGGQ=; b=F4zKTEaLrNiejXahMglPCdS0JHfrs5n+aiET0PeYwvLB6Vc7XHCYEhgTiaa9YN8LgW p9zJA2OELzc4pXdhyvSXg7e7mp2ZxmZIm98zH5hKL7ytmtUaioARHNpx0hvIsdJTyWrD ACFxYZkKuMICJRUwYeJu3OCPHOGtlJYcw/AYPfLduwftjufkZAICgUtJoLASHc7Vh1nk 5XHa0E6hn+tQLrleYIF15evshiLUtFO/zTFxHSU0GAMrX1JHfALQT5xZS4ZzjZHvDciT zR1UyV/z/TkldGx7Deug0AIVIjZrFSj364bbQgmvtuCy11eUaogXR8cn3l/40XKdbuJ/ mIxw== X-Gm-Message-State: AOAM530zG1SQKELfhG/AyU24JU3b5+Yj84vYATRzto8cjs8CmkdT1fqd c6VgCV3x4m0k40STDkb62aI= X-Received: by 2002:aca:d510:: with SMTP id m16mr7487858oig.13.1592676443390; Sat, 20 Jun 2020 11:07:23 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Jun 2020 11:07:22 -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 15/17] dyndbg: export ddebug_exec_queries Date: Sat, 20 Jun 2020 12:06:41 -0600 Message-Id: <20200620180643.887546-16-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 Export ddebug_exec_queries() for use by modules. This will allow module authors to control all their *pr_debug*s dynamically. And since ddebug_exec_queries() is what implements "echo $query >control", it gives the same complete control. Virtues of this: - simplicity. just an export. - full control over any/all subsets of callsites. - same "query/command-string" in code and console - full callsite selectivity with module file line format Format in particular deserves special attention; it is where low-hanging fruit will be found. Consider: drivers/gpu/drm/amd/display/include/logger_types.h: #define DC_LOG_SURFACE(...) pr_debug("[SURFACE]:"__VA_ARGS__) #define DC_LOG_HW_LINK_TRAINING(...) pr_debug("[HW_LINK_TRAINING]:"__VA_ARGS__) .. 9 more .. Thats 11 string prefixes, used in 804 callsites across the module. Clearly a systematized classification of those callsites. And one Id expect to see repeated often. Using ddebug_exec_queries(), authors can operate on those classifications as a unitary set: echo format="[SURFACE]:" +p >control Trivially, those sets can be subsected with the other query terms too, should the author see fit. Using ddebug_exec_queries() from a callback, authors can change *pr_debug* callstates when drm.debug is updated from userspace. They can map bits, or strings, or whatever they want. They could even alter [fmlt] flags, though I dont foresee why they would. Is it safe ? ddebug_exec_queries() is currently 'exposed' to user space in several limited ways; 1 it is called from module-load callback, where it implements the $modname.dyndbg=+p "fake" parameter provided to all modules. 2 it handles query input from >control directly IOW, it is "fully" exposed to local root user; exposing the same functionality to other kernel modules is no additional risk. The other big issue to check is locking: dyndbg has a single mutex, taken by ddebug_change to handle >control, and by ddebug_proc_(start|stop) to span `cat control`. Queries submitted via export will have module specified, which dramatically cuts matching work done by ddebug_change vs "module=* +p". ISTM this proposed export presents no locking problems. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 65c224301509..b00f536d6d12 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -546,6 +546,7 @@ static int ddebug_exec_queries(char *query, const char *modname) return exitcode; return nfound; } +EXPORT_SYMBOL_GPL(ddebug_exec_queries); #define PREFIX_SIZE 64 -- 2.26.2