Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp2265493ybg; Fri, 5 Jun 2020 09:31:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrE8LRM9sb1oyX6P8DX0bipN5fpqm/EVLZEr5LStS0DjF8/MrcRz7bdTaEKakTeQOFWKU1 X-Received: by 2002:a17:906:70e:: with SMTP id y14mr9200347ejb.221.1591374682683; Fri, 05 Jun 2020 09:31:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591374682; cv=none; d=google.com; s=arc-20160816; b=Ogsdy+u2Lq+Te1s+CZGrM0Jh9y9b2+cAuO/RtC5TsRIJcogiA+QXRHlgX8JD+AvOGV oem2qiNsGHidYtptstZwr/6/Vaw23XpuvB2+EL9raMunqhecr3ggSci7LxbssxSMeKw9 6jkTvdTLM3k1ENhwF+VCKped1oMYdXixlOkvjoy5dRQxeZlNxY2EK7c+ns9+bRv7lDej jETPbtkqA+0lclnFf3m1QuO/rM7fqWHLnUd3otj1i4cZrSerzG2jaixmbxIwX738Qste BUjk3U36n5JGUBoIgnIS7Ab74QaSwRwyO+Egrrm4Ac/rwIo4IpXFlrbxlIo6cTBk4Rkx ZuRw== 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=HVn2ZJqvpzUH29M3RomJkg8mujEdnSQL3JazyfpNjV4=; b=CpsiJT0WuUeKuY/BdeG5f9dubHUpnBhcE/FdSN1R6Nfw+ulM4h76ycGDZuUuwHdVVd gDBoP5vvqfATgvJjzGsLvMDQwoeJ7imvBGKBhQbtmmti6j3ZnzxFQSk0sAYYMjCg6fKl 9J/Qtagx4rY0jhS+8vVXL+GMOV63a391AAsy/7mOl/E6x8ANHkrf++xvDufbJFITLOqK W04DZ4H5NTaRXfhzCvM9y+Q5HwaCDkZY+0W3Zqu+GTrbvSo5fqTRvS82i205Q181zE4p 7wnYVzG1SgmB1O198hRK+mdlmr8JyMcOtjx8ozidOg7lrC21p/tMPmiAWUEHOez17nZz bUTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KFi3luT4; 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 dm27si4102161edb.308.2020.06.05.09.31.00; Fri, 05 Jun 2020 09:31:22 -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=KFi3luT4; 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 S1727098AbgFEQ20 (ORCPT + 99 others); Fri, 5 Jun 2020 12:28:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728561AbgFEQ14 (ORCPT ); Fri, 5 Jun 2020 12:27:56 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4DC9C08C5C2 for ; Fri, 5 Jun 2020 09:27:56 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id u23so8049680otq.10 for ; Fri, 05 Jun 2020 09:27:56 -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=HVn2ZJqvpzUH29M3RomJkg8mujEdnSQL3JazyfpNjV4=; b=KFi3luT4gKqZVo4io4NXZKfvbVrdDmtD/Rk9CTMxRvg8IVBYgB/sC81htsJE5WNhed 8leqy3In6at29qGCyfbBFsDDYU7c9skwCo7+i3s1cXrga44B4FnVxFdpFibv41iOmkob SQ4nliLo1/wy72PnOI4YBpTM2iHaiAIWX5q0JHh1XL5RWJrYb8O9vCR4xpMG8+F9xp2M pA8MU9ip8VGT1LGvjK7DV1ZNKC0TK9v2N0BGb20g7vz8UbuIb2tarM+QAOxbaSqEAU9i PQDtq8ghs6b5uzvn0tw442BO6CxkBd5H4lIUsV4wixjSJoruhwh4+7vm0A3yB6cvTrk5 +llg== 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=HVn2ZJqvpzUH29M3RomJkg8mujEdnSQL3JazyfpNjV4=; b=jdMSmwushTol/0LBbE0YhoD0E/CZAVwBU3OLzPi6Dts3zRL/yc2RUEcuBMNyefhfqB 8ypnljqQ9oa7gVilD+icQTvlfac+ebdYQSU3V2LLi2X3gKMf7zQfyyEj5a5P+3PV9Mhj u23QK4MBdK08q3z48wMCuKwQShHpVAS4T89Z/T2W+ZApELZ8mtppRrbI+QECLbz9kl/F 0E3wwa+BvLWM3dTx454pWbDa3WiejpyKgKQu0DpQz0CINCzhm34mYd89aapGdTr/sD16 nRTDyFn0qUD9amEmaJXlZrg932vqzfCsRqIjiEGA5YnVFuLi4z0Dpir9E9vP/7yQkHDO MlaA== X-Gm-Message-State: AOAM530pYfgAkIYieMCzvzaBgHoZYutzDB9C6DLpaWWwAPMvbn/YIfNq u+2OPjSZQN/AxR5WRAU9wEQ= X-Received: by 2002:a05:6830:13d3:: with SMTP id e19mr2311030otq.290.1591374476039; Fri, 05 Jun 2020 09:27:56 -0700 (PDT) Received: from frodo.hsd1.co.comcast.net ([2601:284:8204:6ba0::aaac]) by smtp.googlemail.com with ESMTPSA id z13sm813894ooa.28.2020.06.05.09.27.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 09:27:55 -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 11/16] dyndbg: combine flags & mask into a struct, use that Date: Fri, 5 Jun 2020 10:26:40 -0600 Message-Id: <20200605162645.289174-12-jim.cromie@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200605162645.289174-1-jim.cromie@gmail.com> References: <20200605162645.289174-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 combine flags & mask into a struct, and replace those 2 parameters in 3 functions: ddebug_change, ddebug_parse_flags, ddebug_read_flags, altering the derefs in them accordingly. This simplifies the 3 function sigs, preparing for more changes. We dont yet need mask from ddebug_read_flags, but will soon. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 46 +++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 005b8221a9d6..2ecabfd3f432 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -62,6 +62,11 @@ struct ddebug_iter { unsigned int idx; }; +struct flagsettings { + unsigned int flags; + unsigned int mask; +}; + static DEFINE_MUTEX(ddebug_lock); static LIST_HEAD(ddebug_tables); static int verbose; @@ -141,7 +146,7 @@ static void vpr_info_dq(const struct ddebug_query *query, const char *msg) * logs the changes. Takes ddebug_lock. */ static int ddebug_change(const struct ddebug_query *query, - unsigned int pflags, unsigned int mask) + struct flagsettings *mods) { int i; struct ddebug_table *dt; @@ -190,14 +195,14 @@ static int ddebug_change(const struct ddebug_query *query, nfound++; - newflags = (dp->flags & mask) | pflags; + newflags = (dp->flags & mods->mask) | mods->flags; if (newflags == dp->flags) continue; #ifdef CONFIG_JUMP_LABEL if (dp->flags & _DPRINTK_FLAGS_PRINT) { - if (!(pflags & _DPRINTK_FLAGS_PRINT)) + if (!(mods->flags & _DPRINTK_FLAGS_PRINT)) static_branch_disable(&dp->key.dd_key_true); - } else if (pflags & _DPRINTK_FLAGS_PRINT) + } else if (mods->flags & _DPRINTK_FLAGS_PRINT) static_branch_enable(&dp->key.dd_key_true); #endif dp->flags = newflags; @@ -413,14 +418,14 @@ static int ddebug_parse_query(char *words[], int nwords, return 0; } -static int ddebug_read_flags(const char *str, unsigned int *flags) +static int ddebug_read_flags(const char *str, struct flagsettings *f) { int i; for (; *str ; ++str) { for (i = ARRAY_SIZE(opt_array) - 1; i >= 0; i--) { if (*str == opt_array[i].opt_char) { - *flags |= opt_array[i].flag; + f->flags |= opt_array[i].flag; break; } } @@ -429,7 +434,7 @@ static int ddebug_read_flags(const char *str, unsigned int *flags) return -EINVAL; } } - vpr_info("flags=0x%x\n", *flags); + vpr_info("flags=0x%x mask=0x%x\n", f->flags, f->mask); return 0; } @@ -439,10 +444,8 @@ static int ddebug_read_flags(const char *str, unsigned int *flags) * flags fields of matched _ddebug's. Returns 0 on success * or <0 on error. */ -static int ddebug_parse_flags(const char *str, unsigned int *flagsp, - unsigned int *maskp) +static int ddebug_parse_flags(const char *str, struct flagsettings *mods) { - unsigned flags = 0; int op; switch (*str) { @@ -457,31 +460,30 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp, } vpr_info("op='%c'\n", op); - if (ddebug_read_flags(str, &flags)) + if (ddebug_read_flags(str, mods)) return -EINVAL; - /* calculate final *flagsp, *maskp according to mask and op */ + /* calculate final flags, mask based upon op */ switch (op) { case '=': - *maskp = 0; - *flagsp = flags; + mods->mask = 0; break; case '+': - *maskp = ~0U; - *flagsp = flags; + mods->mask = ~0U; break; case '-': - *maskp = ~flags; - *flagsp = 0; + mods->mask = ~mods->flags; + mods->flags = 0; break; } - vpr_info("*flagsp=0x%x *maskp=0x%x\n", *flagsp, *maskp); + vpr_info("*flagsp=0x%x *maskp=0x%x\n", mods->flags, mods->mask); + return 0; } static int ddebug_exec_query(char *query_string, const char *modname) { - unsigned int flags = 0, mask = 0; + struct flagsettings mods = {}; struct ddebug_query query; #define MAXWORDS 9 int nwords, nfound; @@ -493,7 +495,7 @@ static int ddebug_exec_query(char *query_string, const char *modname) return -EINVAL; } /* check flags 1st (last arg) so query is pairs of spec,val */ - if (ddebug_parse_flags(words[nwords-1], &flags, &mask)) { + if (ddebug_parse_flags(words[nwords-1], &mods)) { pr_err("flags parse failed\n"); return -EINVAL; } @@ -502,7 +504,7 @@ static int ddebug_exec_query(char *query_string, const char *modname) return -EINVAL; } /* actually go and implement the change */ - nfound = ddebug_change(&query, flags, mask); + nfound = ddebug_change(&query, &mods); vpr_info_dq(&query, nfound ? "applied" : "no-match"); return nfound; -- 2.26.2