Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3070833pxa; Tue, 25 Aug 2020 10:35:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzP0HqU5/u1q/KFffEmCsSZIgZlsA/uQFO2rgr6EKMRsSbtN1DOywdQaT6/H+HSRf/ocfSh X-Received: by 2002:aa7:d284:: with SMTP id w4mr6792280edq.258.1598376915642; Tue, 25 Aug 2020 10:35:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598376915; cv=none; d=google.com; s=arc-20160816; b=ViCUAY+gvtoaPvvIdpWmbSW+0n/35qy5d5sbe7luSTUrLjE+oifK5luzoGgx/RYq8k EMkXEMUGUppfhzLkRbWNrivsTlAP72FIjUHMIJV6DT/UUoaD0ctdxZ3rRJ3tlQ3YoXsf BSEacsWLXdxMoU1CmjsHPlGAi/aOaELhq77c8vn8r1SQHfjHIALwsuiB+I3z5IQEu/SJ raROMFeyTZzub4rMeWv+HWDSqniiwhj0R1W1zqayKZghH2nBSUDf+bKV+GSeqce4h3w6 Bs9UcQwvMLUGkNgYnVRAfYpYVbTDjStebAuQjAAnuZGpwi3ghqjFZzPfKOpA9erqN/1h y8KA== 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=efvC3Unx7QAw8IwTDdEQR++n/Hl+Re4xPSL3PJY90Ss=; b=qjrUUohx8jtv+PjSqY4KHL6Tv9/jAEj5l5aMZxSvGf1hGUKsRUqXRQr+ngGcMtz3O0 71CWPiGjibWW4SGSLx7+BCbu2yqNOZgEp94hHuddU3AbtUw4KAN39oM3ifH+xOnJDoi6 FbZVT+OaoAnFw/OdcvGQP0ciwjT0xU9jkMFYon/t5iLkMGvn/6KTx38h5c8RNdWI1zvs LDTV4hN1G2FFDQveB/DadLjN2NcGlammemdd0kWNFv3YLWKF8b1kzlt32bvzd/bfWCb9 dvyoeT3gE8XbkcDcOuaobHYUFb+HBwpNdTcwELjYZXnfQVtKq98dlLT4QDrf90Y2WFoY GM1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Wr269rF8; 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 g19si1543469edp.601.2020.08.25.10.34.52; Tue, 25 Aug 2020 10:35:15 -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=Wr269rF8; 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 S1726711AbgHYReB (ORCPT + 99 others); Tue, 25 Aug 2020 13:34:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726356AbgHYRds (ORCPT ); Tue, 25 Aug 2020 13:33:48 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64145C061755 for ; Tue, 25 Aug 2020 10:33:48 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id n128so12352100oif.0 for ; Tue, 25 Aug 2020 10:33:48 -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=efvC3Unx7QAw8IwTDdEQR++n/Hl+Re4xPSL3PJY90Ss=; b=Wr269rF8WGTtRm+QzV4cuEZvANncTR1BnZWwJGEyF9ZKAbtZmO9Dfs1RFOSNu7e9A7 9PY38bWfar4Lm9s8Cs+Co7t8uhxDshezSvCXPsf9c9iR2umb6vwLMCVneLp9YZ/VLiAX rPaYDVQ8UklTimXKIy+54rR5VAzpNNPTbaz6Dr2r1zN+NKWoE4imwlMr7rTJM4MMiST3 xrFfgAfSJsBUogJ77ZusdQDxE5pX9KS/nAIfdfRdQvDX7eI0G/yxTc0FnGsocTqTAtpK 0thxhfEiPtcY6N9FcOP7mdIBkyXgV6sQ7QQlxb4v2+kKi3B87rMMvOb6DuYHG9hKLHdj URCA== 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=efvC3Unx7QAw8IwTDdEQR++n/Hl+Re4xPSL3PJY90Ss=; b=HGoTON2eezeQJM9BFBe3BxCePa8a+o6pHVvjDuKm4wj2l7XzQQfAwrXDrWdxlPsBT3 iTCrmCYyr4NCLLcTtUwqOksjy7wWtLxAIWGL/Kp6nKUDKG2H0SWak0RYRawr8mVFFaCx 2iDdLWwrrwNfMi21M+4PHQ8WEIXhF6dOZ+UHNctzRhysZkz09AjrNVdbfv/68uDpAwX2 7ZiNFoU4+FfvT2KEHPhxMP6B5JeBNQA0jTe6dn4Ox6sbjTc//YuTUBShDukHw/vwyJAt /E4S9cObuIxejaNOG9a0DzoTZJrSC59ZuXEkgWfvMyNpwOBZWOK61lCTQIKx2CIR0AMT sH9w== X-Gm-Message-State: AOAM532zO2nnrb8S2LdUM2FBfHUT+VF745N1cF6PRFhnNiqyzMFDJS2j xBmbeuRvF2oy4qT7FayPt/M= X-Received: by 2002:aca:3ac2:: with SMTP id h185mr1708895oia.65.1598376827780; Tue, 25 Aug 2020 10:33:47 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8203:5970::c4c]) by smtp.googlemail.com with ESMTPSA id x11sm3214168oot.0.2020.08.25.10.33.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 10:33:47 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Cc: Jim Cromie Subject: [PATCH v2 2/3] dyndbg: refine export, rename to dynamic_debug_exec_queries() Date: Tue, 25 Aug 2020 11:33:38 -0600 Message-Id: <20200825173339.2082585-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200825173339.2082585-1-jim.cromie@gmail.com> References: <20200825173339.2082585-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 commit 59cf47e7df31 dyndbg: export ddebug_exec_queries left a few configs broken, fix them with ifdef stub-fns. Rename the export to dynamic_debug_exec_queries(). This is a more canonical function name, instead of exposing the 'ddebug' internal name prefix. Do this now, before export hits v5.9.0 Implement as new function wrapping ddebug_exec_queries(now static again), which copies the query-string, preserving ddebug_exec_queries' in-place parsing, while allowing users to pass const strings. -- v2- fixes per Joe Perches Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 20 ++++++++++++++++---- lib/dynamic_debug.c | 26 ++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index aa9ff9e1c0b3..8aa0c7c2608c 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -49,6 +49,10 @@ struct _ddebug { #if defined(CONFIG_DYNAMIC_DEBUG_CORE) + +/* exported for module authors to exercise >control */ +int dynamic_debug_exec_queries(const char *query, const char *modname); + int ddebug_add_module(struct _ddebug *tab, unsigned int n, const char *modname); extern int ddebug_remove_module(const char *mod_name); @@ -105,7 +109,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, static_branch_unlikely(&descriptor.key.dd_key_false) #endif -#else /* !HAVE_JUMP_LABEL */ +#else /* !CONFIG_JUMP_LABEL */ #define _DPRINTK_KEY_INIT @@ -117,7 +121,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) #endif -#endif +#endif /* CONFIG_JUMP_LABEL */ #define __dynamic_func_call(id, fmt, func, ...) do { \ DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt); \ @@ -172,10 +176,11 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor, KERN_DEBUG, prefix_str, prefix_type, \ rowsize, groupsize, buf, len, ascii) -#else +#else /* !CONFIG_DYNAMIC_DEBUG_CORE */ #include #include +#include static inline int ddebug_add_module(struct _ddebug *tab, unsigned int n, const char *modname) @@ -210,6 +215,13 @@ static inline int ddebug_dyndbg_module_param_cb(char *param, char *val, print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, \ rowsize, groupsize, buf, len, ascii); \ } while (0) -#endif + +static inline int dynamic_debug_exec_queries(const char *query, const char *modname) +{ + pr_warn("kernel not built with CONFIG_DYNAMIC_DEBUG_CORE\n"); + return 0; +} + +#endif /* !CONFIG_DYNAMIC_DEBUG_CORE */ #endif diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 01b7d0210412..a23b5d153153 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -525,7 +525,7 @@ static int ddebug_exec_query(char *query_string, const char *modname) last error or number of matching callsites. Module name is either in param (for boot arg) or perhaps in query string. */ -int ddebug_exec_queries(char *query, const char *modname) +static int ddebug_exec_queries(char *query, const char *modname) { char *split; int i, errs = 0, exitcode = 0, rc, nfound = 0; @@ -557,7 +557,29 @@ int ddebug_exec_queries(char *query, const char *modname) return exitcode; return nfound; } -EXPORT_SYMBOL_GPL(ddebug_exec_queries); + +/** + * dynamic_debug_exec_queries - select and change dynamic-debug prints + * @query: query-string described in admin-guide/dynamic-debug-howto + * @modname: string containing module name, usually &module.mod_name + * + * This uses the >/proc/dynamic_debug/control reader, allowing module + * authors to modify their dynamic-debug callsites. The modname is + * canonically struct module.mod_name, but can also be null or a + * module-wildcard, for example: "drm*". + */ +int dynamic_debug_exec_queries(const char *query, const char *modname) +{ + int rc; + char *qry = kstrndup(query, PAGE_SIZE, GFP_KERNEL); + if (!query) + return -ENOMEM; + + rc = ddebug_exec_queries(qry, modname); + kfree(qry); + return rc; +} +EXPORT_SYMBOL_GPL(dynamic_debug_exec_queries); #define PREFIX_SIZE 64 -- 2.26.2