File tree Expand file tree Collapse file tree 5 files changed +39
-1
lines changed Expand file tree Collapse file tree 5 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,13 @@ config SYSTEM_NXINIT_ACTION_CMD_ARGS_MAX
5959 ...
6060 ```
6161
62+ config SYSTEM_NXINIT_ACTION_WARN_SLOW
63+ int "Warn if command takes too long"
64+ default 50
65+ depends on SYSTEM_NXINIT_WARN
66+ ---help---
67+ Warning if command took more than `SYSTEM_NXINIT_ACTION_WARN_SLOW` ms.
68+
6269config SYSTEM_NXINIT_ACTION_MANAGER_EVENT_MAX
6370 int "Max number of action manager events"
6471 default 32
Original file line number Diff line number Diff line change @@ -210,6 +210,10 @@ int init_action_run_command(FAR struct action_manager_s *am)
210210 struct action_cmd_s , node );
211211 }
212212
213+ #if defined(CONFIG_SYSTEM_NXINIT_ACTION_WARN_SLOW ) && \
214+ CONFIG_SYSTEM_NXINIT_ACTION_WARN_SLOW > 0
215+ clock_gettime (CLOCK_MONOTONIC , & am -> time_run );
216+ #endif
213217 ret = init_builtin_run (am , am -> running -> argc , am -> running -> argv );
214218 if (ret > 0 )
215219 {
@@ -229,6 +233,28 @@ void init_action_reap_command(FAR struct action_manager_s *am)
229233 struct action_s ,
230234 ready_node );
231235
236+ #if defined(CONFIG_SYSTEM_NXINIT_ACTION_WARN_SLOW ) && \
237+ CONFIG_SYSTEM_NXINIT_ACTION_WARN_SLOW > 0
238+ struct timespec time ;
239+ int ms ;
240+
241+ clock_gettime (CLOCK_MONOTONIC , & time );
242+ clock_timespec_subtract (& time , & am -> time_run , & time );
243+ ms = TIMESPEC2MS (time );
244+ if (ms > CONFIG_SYSTEM_NXINIT_ACTION_WARN_SLOW )
245+ {
246+ if (am -> pid_running <= 0 )
247+ {
248+ init_warn ("Command '%s' took %d ms" , am -> running -> argv [0 ], ms );
249+ }
250+ else
251+ {
252+ init_warn ("Command '%s' pid %d took %d ms" , am -> running -> argv [0 ],
253+ am -> pid_running , ms );
254+ }
255+ }
256+ #endif
257+
232258 am -> pid_running = -1 ;
233259 if (list_is_tail (& ready -> cmds , & am -> running -> node ))
234260 {
Original file line number Diff line number Diff line change @@ -64,6 +64,10 @@ struct action_manager_s
6464
6565 FAR struct action_cmd_s * running ;
6666 int pid_running ;
67+ #if defined(CONFIG_SYSTEM_NXINIT_ACTION_WARN_SLOW ) && \
68+ CONFIG_SYSTEM_NXINIT_ACTION_WARN_SLOW > 0
69+ struct timespec time_run ;
70+ #endif
6771 FAR struct service_manager_s * sm ;
6872};
6973
Original file line number Diff line number Diff line change 3333 * Pre-processor Definitions
3434 ****************************************************************************/
3535
36+ #define TIMESPEC2MS (t ) (((t).tv_sec * 1000) + (t).tv_nsec / 1000000)
37+
3638#ifdef CONFIG_SYSTEM_NXINIT_DEBUG
3739#define init_debug (...) syslog(LOG_DEBUG, ##__VA_ARGS__)
3840#define init_dump_args (argc , argv ) \
Original file line number Diff line number Diff line change 4444 ****************************************************************************/
4545
4646#define SYSTEM_NXINIT_SERVICE_GENTLE_KILL_TIMEOUT 200
47- #define TIMESPEC2MS (t ) (((t).tv_sec * 1000) + (t).tv_nsec / 1000000)
4847
4948#define check_flags (s , f ) ((s)->flags & (f))
5049
You can’t perform that action at this time.
0 commit comments