Re: WIP generic module->debug_flags and dynamic_debug

2020-06-11 Thread jim . cromie
> > can anyone diagnose my problem ?
>
> Sorry, I have not the faintest idea of what you're trying to achieve.
> Can you spell that out?
>
> Rasmus

hey, sorry for the lack of context.
Ive solved my problem, by adding (void*) to my container_of usage.
WIP code now "works", but still incomplete.
will reroll and resubmit


Re: WIP generic module->debug_flags and dynamic_debug

2020-06-11 Thread Rasmus Villemoes
On 10/06/2020 20.32, jim.cro...@gmail.com wrote:
> so Ive got a WIP / broken / partial approach to giving all modules a
> u32 flagset,
> and enabling pr_debug based upon it.  I leave out the "pr_debug_typed(
> bitpos )" for now.  For Stanimir, bits 1,2,3 could be high, middle,
> low.
> 
> ATM its broken on my lack of container_of() skills.
> 
> Im trying to use it to get a struct module* using its name value thats
> been copied
> into a ddebug_table member.
> 
> Im relying on
> cdf6d006968  dynamic_debug: don't duplicate modname in ddebug_add_module
> to have the same value in both structs
> 
> but Im clearly missing a few things
> besides the likely future trouble with .rodata builtin modules
> (after compile prob solved)
> 
> It seems container_of wants me to use struct ddebug_table instead,
> but I dont want a *ddebug_table.
> Ive blindly guessed at adding & and * to 1st param, w/o understanding.
> 
> can anyone diagnose my problem ?

Sorry, I have not the faintest idea of what you're trying to achieve.
Can you spell that out?

Rasmus


Re: WIP generic module->debug_flags and dynamic_debug

2020-06-10 Thread Joe Perches
On Wed, 2020-06-10 at 12:32 -0600, jim.cro...@gmail.com wrote:
> so Ive got a WIP / broken / partial approach to giving all modules a
> u32 flagset,
> and enabling pr_debug based upon it.  I leave out the "pr_debug_typed(
> bitpos )" for now.  For Stanimir, bits 1,2,3 could be high, middle,
> low.

Can you change this please to be a pointer to an unsigned long/int?

That way, existing non-dynamic debug uses like

MODULE_PARM_DESC(debug, "module specific debug control");

maybe could use the same mechanism to enable/disable by class.




WIP generic module->debug_flags and dynamic_debug

2020-06-10 Thread jim . cromie
so Ive got a WIP / broken / partial approach to giving all modules a
u32 flagset,
and enabling pr_debug based upon it.  I leave out the "pr_debug_typed(
bitpos )" for now.  For Stanimir, bits 1,2,3 could be high, middle,
low.

ATM its broken on my lack of container_of() skills.

Im trying to use it to get a struct module* using its name value thats
been copied
into a ddebug_table member.

Im relying on
cdf6d006968  dynamic_debug: don't duplicate modname in ddebug_add_module
to have the same value in both structs

but Im clearly missing a few things
besides the likely future trouble with .rodata builtin modules
(after compile prob solved)

It seems container_of wants me to use struct ddebug_table instead,
but I dont want a *ddebug_table.
Ive blindly guessed at adding & and * to 1st param, w/o understanding.

can anyone diagnose my problem ?


[jimc@frodo build-virtme]$ git diff
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index a5d76f8f6b40..2bfd1aa083b3 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -20,6 +20,7 @@ struct _ddebug {
const char *function;
const char *filename;
const char *format;
+   u32 reqd_flags; /*misleading name todo, probly should hold
just a single type-bit */
unsigned int lineno:18;
/*
 * The flags field controls the behaviour at the callsite.
diff --git a/include/linux/module.h b/include/linux/module.h
index 1ad393e62bef..06eeef438fd3 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -429,6 +429,7 @@ struct module {
struct mod_arch_specific arch;

unsigned long taints;   /* same bits as kernel:taint_flags */
+   u32 debugflags;

 #ifdef CONFIG_GENERIC_BUG
/* Support for BUG */
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 63ae6f77a0e4..965ee96630b5 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -202,6 +202,20 @@ static int ddebug_change(const struct ddebug_query *query,
if ((~dp->flags & filter->mask) != filter->mask)
continue;

+   /* screen on module->debugflags */
+   if (query->module) {
+   /* dt->modname is known == module->name */
+   struct module *m =
+   container_of((&(dt->mod_name)),
+struct module, name);
+   if (m->debugflags &&
+   ((m->debugflags & dp->reqd_flags)
+!= dp->reqd_flags))
+   continue;
+   vpr_info("%s module-debugflags: 0x%x\n",
+dt->mod_name, dp->reqd_flags);
+   }
+
nfound++;

newflags = (dp->flags & mods->mask) | mods->flags;
(END)