From patchwork Mon May 16 22:56:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12851655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9FD2CC433F5 for ; Mon, 16 May 2022 23:04:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ij5wb7lUueKV9/YlaXkn4fMmppMYajmVO9IOSE3YqFc=; b=eoiGVRT8heSpxx 1hcr8Bba7j3cSD5VJOcR5+x+qMTsIWV32NipEeRVZc37GdkV82DhHG7XW90T6Aotfp3MdhPwXijcb TzV8PM2OEtNZ2Af70XrquZ9u/5RgphW9RmIw+tnsdY67WcTXryOoLUFz97u8v0A5ve1mSKxw5hH8/ YT2RycV3e6+rVlR/YztUloFbrJTb4exa5mqN65WW06/U3UvaEuz360vylVzjrZOBIwiFbhOJpm4f5 kCCguHps/O5lzw10V9H7OWY4Ng5Yslg6DGf13p39bK++2i9yboGOhyh8DQlaHfNWAVncBA+hQMyZf icyBbQnyltmvSUNxL2bQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjkb-00AcmS-Az; Mon, 16 May 2022 23:03:42 +0000 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqjeM-00AZML-J7 for linux-arm-kernel@lists.infradead.org; Mon, 16 May 2022 22:57:16 +0000 Received: by mail-il1-x136.google.com with SMTP id j7so2187998ila.1 for ; Mon, 16 May 2022 15:57:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pcTCD0gjQirPulppRUPJolVEvdGl8HWNF457l2/VCpM=; b=Q9CmR/OAi4f1fJoHiSq/A4+KKe+6D/bRcwzXAN4CXFUDU9W2e/2rDFlaPtn9DFL3UZ 0OP+IoKCCh6jybN/4qKugRJr9T7OMuUWB4WPcOmePoEDyIWmnOH/Ox90OJPiIk7Uj2Ay X08/tZRG4GW7glyZeaVHPS0481a3PaSmacbBlv0ZZESoKc5evx9H5So0ulM0I63j44yN SP5T0u614Gkgwz78lPA4m5oH9zHG8D7tq0xAtxEPiBhUov/810saX6SSHCROypTyuHX/ Hi1iw+N+BFIEL+BpwjFUjSZL5bIvVsgrCFPtwfR3vAntRQZrHwooDLmOROaOb3jpAut/ oK6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pcTCD0gjQirPulppRUPJolVEvdGl8HWNF457l2/VCpM=; b=nhke4109rcYYJvW8AZ8w1aBwb+tSKAjxCO+olz/VRZpvoCeDqTAyVU167GqUfeNpNn I9Go3YLYIVv9BmpF6sHz9EsnahUCzsGHyQm5hdWEhhDZXfAGTFRSYmA/VkqTy3W+WlmY mHj6IJXX7ulDRA2KIcVGMvMPf5zxeNZgBd7g9mx0Ozq3VGhYqic8B6rp4l1VEne4iYsg WflFF86dYTkiD0kSUZKD14QLReKbRZSa+xfMdW/2RBKETMm43OCZhqtOT/c40q8FWZd/ 5+XdV3udFmEh9KaTrshqTzkkC+vo06mnRk8dJHrEG1ltVA2RYcrYLwJFzeVut7i7DELc GAqg== X-Gm-Message-State: AOAM530EQy9zq/0W/O8P94rAy9PKv9q5h05lQAYYmJyWCtIo3XYlLHuL txTZF0385KnpjvWJGCDpkkc= X-Google-Smtp-Source: ABdhPJx/jSyAjp7ehDTr/MAgCBe4VOWPaEYbecT5v2lmg6AJpeafbX8FKEwrz5Q30LOOcV3+TCIIVg== X-Received: by 2002:a05:6e02:158c:b0:2cf:db51:f69b with SMTP id m12-20020a056e02158c00b002cfdb51f69bmr9710970ilu.263.1652741834203; Mon, 16 May 2022 15:57:14 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:2010::dd9f]) by smtp.googlemail.com with ESMTPSA id k26-20020a02661a000000b0032b74686763sm3133949jac.76.2022.05.16.15.57.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 15:57:13 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Cc: gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com, jim.cromie@gmail.com Subject: [PATCH v2 11/27] dyndbg: support symbolic class-names in bitmap Date: Mon, 16 May 2022 16:56:24 -0600 Message-Id: <20220516225640.3102269-12-jim.cromie@gmail.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220516225640.3102269-1-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220516_155714_691733_C26B2914 X-CRM114-Status: GOOD ( 17.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Extend the sysfs-node bitmap support to accept class-names registered by the module, allowing: #> echo DRM_UT_CORE,-DRM_UT_ATOMIC,+DRM_UT_KMS \ > /sys/module/drm/parameters/debug Do this in param_set_dyndbg_class_strings(), which is called from param_set_dyndbg_classes() when the input string isn't a integer. Signed-off-by: Jim Cromie --- . continue/skip on unknown class, so following symbols are processed. . better loadable module handling, no more KP_MOD_NAME . add do_callback_changes --- lib/dynamic_debug.c | 63 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 42dce2e76014..8e1b9159e881 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -618,6 +618,61 @@ static int do_callback_changes(const struct ddebug_classes_bitmap_param *dcp, return matches; } +/* support for [+-] symbolic-name boolean list */ +static int param_set_dyndbg_class_strings(const char *instr, const struct kernel_param *kp) +{ + const struct ddebug_classes_bitmap_param *dcp = kp->arg; + unsigned long inbits; + int idx_rc, totct = 0; + bool wanted; + char *cls, *p; + + if (!dcp || !dcp->map) { + pr_err("set_dyndbg_classes: no bits=>queries map\n"); + return -EINVAL; + } + + cls = kstrdup(instr, GFP_KERNEL); + p = strchr(cls, '\n'); + if (p) + *p = '\0'; + + inbits = *dcp->bits; + vpr_info("set_dyndbg_class_strings: %s on 0x%lx\n", cls, inbits); + + for (; cls; cls = p) { + p = strchr(cls, ','); + if (p) + *p++ = '\0'; + + if (*cls == '-') { + wanted = false; + cls++; + } else { + wanted = true; + if (*cls == '+') + cls++; + } + idx_rc = match_string(dcp->map->classes, dcp->map->length, cls); + if (idx_rc < 0) { + pr_err("%s not found for module: %s\n", cls, dcp->map->mod_name); + continue; + } + if (test_bit(idx_rc, &inbits) == wanted) { + v3pr_info("no change on %s\n", cls); + continue; + } + + vpr_info("set_dyndbg_classes: bit %d: %s\n", idx_rc, dcp->map->classes[idx_rc]); + inbits ^= BIT(idx_rc); + totct += do_callback_changes(dcp, idx_rc, &inbits); + } + kfree(cls); + *dcp->bits = inbits; + vpr_info("total matches: %d\n", totct); + return 0; +} + /** * param_set_dyndbg_classes - bits => categories >control setter * @instr: string echo>d to sysfs @@ -639,10 +694,9 @@ int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp) return -EINVAL; } rc = kstrtoul(instr, 0, &inbits); - if (rc) { - pr_err("set_dyndbg_classes: expecting bits/integer\n"); - return -EINVAL; - } + if (rc) + return param_set_dyndbg_class_strings(instr, kp); + vpr_info("set_dyndbg_classes: new 0x%lx current 0x%lx\n", inbits, *dcp->bits); for (i = 0; i < dcp->map->length; i++) { @@ -650,6 +704,7 @@ int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp) if (test_bit(i, &inbits) == test_bit(i, dcp->bits)) continue; + vpr_info("set_dyndbg_classes: bit %d: %s\n", i, dcp->map->classes[i]); totct += do_callback_changes(dcp, i, &inbits); } *dcp->bits = inbits;