[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210519182739.GG21560@worktop.programming.kicks-ass.net>
Date: Wed, 19 May 2021 20:27:39 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Daniel Bristot de Oliveira <bristot@...hat.com>
Cc: linux-kernel@...r.kernel.org, Steven Rostedt <rostedt@...dmis.org>,
Tommaso Cucinotta <tommaso.cucinotta@...tannapisa.it>,
Kate Carcia <kcarcia@...hat.com>,
Jonathan Corbet <corbet@....net>,
Ingo Molnar <mingo@...hat.com>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Will Deacon <will@...nel.org>,
Catalin Marinas <catalin.marinas@....com>,
"Paul E. McKenney" <paulmck@...nel.org>,
Joel Fernandes <joel@...lfernandes.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Gabriele Paoloni <gabriele.paoloni@...el.com>,
Juri Lelli <juri.lelli@...hat.com>,
Clark Williams <williams@...hat.com>, linux-doc@...r.kernel.org
Subject: Re: [RFC PATCH 04/16] rv/include: Add deterministic automata monitor
definition via C macros
On Wed, May 19, 2021 at 01:36:25PM +0200, Daniel Bristot de Oliveira wrote:
> +struct da_monitor {
> + char curr_state;
> + bool monitoring;
> + void *model;
> +};
> +
> +#define MAX_PID 1024000
> +/*
> + * Functions to define, init and get a per-task monitor.
> + *
> + * XXX: Make it dynamic? make it part of the task structure?
Yes !
I'd start with maybe adding a list_head to da_monitor and embedding a
single copy into task_struct and link from there. Yes lists suck, but
how many monitors do you realistically expect to run concurrently?
> + */
> +#define DECLARE_DA_MON_INIT_PER_TASK(name, type) \
> + \
> +struct da_monitor da_mon_##name[MAX_PID]; \
That's ~16M of memory, which seems somewhat silly.
> + \
> +static inline struct da_monitor *da_get_monitor_##name(pid_t pid) \
> +{ \
> + return &da_mon_##name[pid]; \
> +} \
> + \
> +void da_monitor_reset_all_##name(void) \
> +{ \
> + struct da_monitor *mon = da_mon_##name; \
> + int i; \
> + for (i = 0; i < MAX_PID; i++) \
> + da_monitor_reset_##name(&mon[i]); \
> +} \
> + \
> +static void da_monitor_init_##name(void) \
> +{ \
> + struct da_monitor *mon = da_mon_##name; \
> + int i; \
> + \
> + for (i = 0; i < MAX_PID; i++) { \
> + mon[i].curr_state = model_get_init_state_##name(); \
> + mon[i].monitoring = 0; \
> + mon[i].model = model_get_model_##name(); \
> + } \
> +} \
Powered by blists - more mailing lists