Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need a minimal log implementation that maps to printk() #19317

Closed
andrewboie opened this issue Sep 22, 2019 · 0 comments · Fixed by #19322
Closed

need a minimal log implementation that maps to printk() #19317

andrewboie opened this issue Sep 22, 2019 · 0 comments · Fixed by #19322
Labels
area: Logging Enhancement Changes/Updates/Additions to existing features

Comments

@andrewboie
Copy link
Contributor

We are trending towards having our logging APIs be the de factor standard for logging in the kernel codebase, for example we recently merged a patch which causes all fatal errors to get sent to the logging mechanism, and tests now all enable CONFIG_LOG and CONFIG_LOG_IMMEDIATE.

The APIs are good, and we should continue to convert kernel code to use them. But we need to keep supporting very tiny devices with limited RAM and ROM storage. Unfortunately, even in this configuration the logging code takes up about 1800B of ROM, for example here is a build of the thread_init test on 96b_meerkat96 (run "make rom_report"):

  logging                                                                               1770     7.86%
    log_backend_uart.c                                                                   276     1.23%
      char_out                                                                            48     0.21%
      log_backend_uart                                                                    16     0.07%
      log_backend_uart_api                                                                24     0.11%
      log_backend_uart_init                                                               60     0.27%
      log_output                                                                          16     0.07%
      panic                                                                               12     0.05%
      sync_hexdump                                                                        52     0.23%
      sync_string                                                                         48     0.21%
    log_core.c                                                                           482     2.14%
      __config_sys_init_enable_logger2                                                    12     0.05%
      __device_sys_init_enable_logger2                                                    12     0.05%
      enable_logger                                                                       10     0.04%
      log_backend_enable                                                                  76     0.34%
      log_const_log                                                                        8     0.04%
      log_core_init                                                                       24     0.11%
      log_generic                                                                         92     0.41%
      log_init                                                                           124     0.55%
      log_source_name_get                                                                 28     0.12%
      log_strdup                                                                           2     0.01%
      log_string_sync                                                                     26     0.12%
      timestamp_func                                                                       4     0.02%
      z_impl_log_panic                                                                    64     0.28%
    log_output.c                                                                        1012     4.49%
      buffer_write                                                                        26     0.12%
      colors                                                                              20     0.09%
      hexdump_line_print                                                                 184     0.82%
      log_output_flush                                                                    26     0.12%
      log_output_hexdump                                                                 116     0.52%
      log_output_string                                                                  112     0.50%
      log_output_timestamp_freq_set                                                       48     0.21%
      out_func                                                                            80     0.36%
      postfix_print                                                                       60     0.27%
      prefix_print                                                                       284     1.26%
      print_formatted                                                                     36     0.16%
      severity                                                                            20     0.09%

RAM usage is less of a concern, about 63B (run 'make ram_report'):

  logging                                                                                 63     0.87%
    log_backend_uart.c                                                                    21     0.29%
      backend_cb_log_backend_uart                                                          8     0.11%
      buf                                                                                  1     0.01%
      log_output_control_block                                                            12     0.17%
    log_core.c                                                                            34     0.47%
      __config_sys_init_enable_logger2                                                    12     0.17%
      __device_sys_init_enable_logger2                                                    12     0.17%
      backend_attached                                                                     1     0.01%
      initialized                                                                          4     0.06%
      panic_mode                                                                           1     0.01%
      timestamp_func                                                                       4     0.06%
    log_output.c                                                                           8     0.11%
      freq                                                                                 4     0.06%
      timestamp_div                                                                        4     0.06%

For the tiniest platforms, we need an alternative implementation. This new mechanism should implement all the APIs in include/logging/log.h, but with an alternate log_core.h where all messages are routed synchronously to printk() in the simplest way possible. Build-time filtering should be available, but ideally we do all of this with macro magic and there is no runtime RAM/ROM footprint for this at all, other than what is imposed by printk().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Logging Enhancement Changes/Updates/Additions to existing features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant