Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2376028ybt; Tue, 16 Jun 2020 04:37:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnuU150QhCpL3lZ9VK78acEtbqe0rY6Jf28gOsDp2gaIoiGPEUs60twTqSXd8eqyjZGfHt X-Received: by 2002:a50:b0c3:: with SMTP id j61mr2164742edd.349.1592307455056; Tue, 16 Jun 2020 04:37:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592307455; cv=none; d=google.com; s=arc-20160816; b=WnUlfaFjQ2XhM/Fb7JNvcC1jLWD0ABLir8YIVLIUT/rry5pwEGi5ijEEN9LmHxj3fo YViovktmzHZ7tAKyqfPBgPzWulLPypavIXNX8z39ZXFAfiQFOGQEs4Y+So2vvRtkasOh LMVyLuG/u9012eSlc7uiJT2FKG2RogCnqLDX93HeGk8rnCvKlzl66GwlAXMPkfE7rHlv RdnblFuqyZUOYaGpwIpHzNwOna2YS+OncdFVnKYjsuILmrFMYLEprbhhRpGvit1eZ6aO LVK10y+CB6jCmMLauXijtCRpVq3AnugZPJRgMmv9ub7BsNdbtd+NWpUapPl0wU/bqL6B FYNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=JREtvHEBpwR2YpmCjxUrwjDE+hG2Ctp8qS/dOaJemhE=; b=G66D64IoQO6y6xVM0gy5NZqSMKQ/g2N3MMgrkC7THf/nbrar3+gbtSztMFwatT7IjZ 4O9SNXkwhKlSpKBSImLoGHulBOl177XagPxjaH2hg2ELAnkekqFVicCQZDo4Yk0nVWll qrFJaQxyGm7GE7VAdoAeQN6VeYVbf2+3C+2gym8fjIa45zTzt60zVpd/A1FnAq1AtkL2 rA91qj5ZGPxKJZxcN52hhB1eh37StqaG7Y6vIp8YDoVJkPj4/PbQdE8HIfEzVnoFCN/x tRAeE502BcNc7b8aXM9iu6PAI911WB/aztbdEfF4Y1Jl9fp6Oy4XS3o7ImJUH4fQbMta Ve1Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ha25si10974432ejb.180.2020.06.16.04.37.12; Tue, 16 Jun 2020 04:37:35 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728522AbgFPLer (ORCPT + 99 others); Tue, 16 Jun 2020 07:34:47 -0400 Received: from mx2.suse.de ([195.135.220.15]:54686 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726467AbgFPLer (ORCPT ); Tue, 16 Jun 2020 07:34:47 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id AE866AFE5; Tue, 16 Jun 2020 11:34:48 +0000 (UTC) Date: Tue, 16 Jun 2020 13:34:43 +0200 From: Petr Mladek To: jim.cromie@gmail.com Cc: Jason Baron , LKML , akpm@linuxfoundation.org, Greg KH , Rasmus Villemoes Subject: Re: [PATCH v2 13/24] dyndbg: combine flags & mask into a struct, use that Message-ID: <20200616113443.GB2238@alley> References: <20200613155738.2249399-1-jim.cromie@gmail.com> <20200613155738.2249399-14-jim.cromie@gmail.com> <20200615151414.GI31238@alley> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 2020-06-15 23:47:26, jim.cromie@gmail.com wrote: > On Mon, Jun 15, 2020 at 9:14 AM Petr Mladek wrote: > > > > On Sat 2020-06-13 09:57:27, Jim Cromie wrote: > > > 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. > > > --- > > > 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 93c627e9c094..8dc073a6e8a4 100644 > > > --- a/lib/dynamic_debug.c > > > +++ b/lib/dynamic_debug.c > > > +struct flagsettings { > > > + unsigned int flags; > > > + unsigned int mask; > > > +}; > > > > static int ddebug_change(const struct ddebug_query *query, > > > - unsigned int pflags, unsigned int mask) > > > + struct flagsettings *mods) > > > > > -static int ddebug_read_flags(const char *str, unsigned int *flags) > > > +static int ddebug_read_flags(const char *str, struct flagsettings *f) > > > > > -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) > > > > What "mods" stands for, please? > > > modifying_flags, or modifiers. > the original flags & mask bundled together > ie the pfmlt in > echo +pfmlt > control Honestly, storing flags and mask is a hack that makes the code tricky like hell. IMHO, it would be much easier to define something like: struct flags_operation { unsinged int flags; enum flags_operation_type op; } Where the opration would be: enum flags_operation_type { DD_FLAGS_SET, /* for '=' */ DD_FLAGS_ADD, /* for '+' */ DD_FLAGS_DEL, /* for '-' */ DD_FLAGS_FILTER_MATCH, DD_FLAGS_FILTER_NON_MATCH, }; Then you could define struct flags_operation fop_change; struct flags_operation fop_filter; Then you could do in ddebug_change(): if (fop_filter) { switch(fop_filter->op) { case DD_FLAGS_FILTER_MATCH: if ((dp->flags & fop_filter->flags) != fop_filter->flags) continue; break; case: DD_FLAGS_FILTER_NON_MATCH: if ((dp->flags & fop_filter->flags) continue; break; default: // warn error; } } switch (fop_change->op) { case DD_FLAGS_SET: dp->flags = fop_change->flags; break; case DD_FLAGS_ADD: dp->flags |= fop_change->flags; break; case DD_FLAGS_DEL: dp->flgas &= ^(fop_change->flgas); break; default: // error; } It might be more lines. But the bit operations will become straightforward. and the code self-explaining, > does the above help ? > I could go with modifying_flags > keep in mind the name has to suit all + - = operations > > I'll review all the new names. I recall you didnt like filterflags either, > so I wasnt sufficently clear there either. > Im mulling a better explanation. The above would make the code manageable. Another question is the user interface. I still wonder if it is worth it. What is the motivation for this fitlering? Is it requested by users? Or is it just a prerequisite for the user-specific filters? We need to be really careful. User interface is hard to change or remove later. Best Regards, Petr