《Aastha_Grover_Logging_Subsystem_ZDS_2023.pdf》由會員分享,可在線閱讀,更多相關《Aastha_Grover_Logging_Subsystem_ZDS_2023.pdf(24頁珍藏版)》請在三個皮匠報告上搜索。
1、Overview of Logging-Aastha Grover,Intel Corporation20232Agenda Overview Log APIs Architecture of Logging Subsystem Log Message and Memory Log Filtering Modes of Logging Multi Domain Logging Types of Logging formats:pros,cons Switch Formats at Runtime3 Logging outputs Human readable strings.printf li
2、ke results+more.String formatting cbprintf package Supports all format specifiers.Identify source of Logging Source module,severity level,time of generation(Timestamp)Timestamping Can log from any context Interrupt context Functionality to dump data LOG_HEXDUMP Log API for every Severity levels.Info
3、rmation,Debugging,Warning&Error Supports Multiple output channels.Example:UART Filesystem,Remote(Bluetooth,Net)Multiple backendsOverview4Source Code:Source Code:#include LOG_MODULE_REGISTER(MODULE,Level);LOG_INF(”String);KconfigKconfig:CONFIG_LOG=yHow to Log using Zephyr?Example:Example:Hello World
4、Application zephyr/samples/hello_worldTimestamp 5Logger APIsX=ERR,WRN,DBG,INFOX=ERR,WRN,DBG,INFOLOG_X :LOG_X :Standard printf-like messages.Eg:LOG_ERRLOG_INST_X LOG_INST_X:Associated with the particular instance.Eg:LOG_INST_INFOLOG_HEXDUMP_X:LOG_HEXDUMP_X:Dump hex data.LOG_INST_HEXDUMP_X:LOG_INST_HE
5、XDUMP_X:Dump hex data associated with a particular instance.LOG_PRINTK/LOG_RAW:LOG_PRINTK/LOG_RAW:Unconditionally print raw log message.LOG_MODULE_REGISTER:LOG_MODULE_REGISTER:Creates module-specific state and register the module with Logger.LOG_MODULE_DECLARE:LOG_MODULE_DECLARE:Declares a log modul
6、e(not register it).6FrontendFrontend Engaged by default when LOG API is called.Responsible for log filtering(Compile&Run-Time),buffer allocation,creating&committing the message.Optimized to log messages faster interrupt context.CoreCore Macros and functions needed for creating logging messages Enabl
7、es/disables logging formats.BackendsBackends Outputs the log messages Cannot be selected by user.Messages are passed through a frontend and are then processed by active backends.ArchitectureCoreCoreFrontendFrontendBackendBackendCONFIG_LOG_FRONTENDCONFIG_LOG_BACKEND7 Filtering a message Compile Time
8、Filtering Run Time Filtering Allocating buffer for the message Message Creation Commit the MessageFrontend:Logging Process8 Self-contained,continuous block of memory Log message contents:Message Descriptor(Source,Domain&Level)Timestamp Formatted String details Optional dataLog Message9 Message Heade
9、r MPSC packet buffer header:2 bits Trace/Log message flag:1 bit Domain ID:3 bits Level:3 bits Cbprintf Package Length:10 bits Data length:12 bits Reserved:1 bit Pointer:Pointer to the source descriptor Timestamp:32 or 64 bits Optional padding Cbprintf package(optional)Header,Arguments&Appended strin
10、gs Hexdump data(optional)Alignment padding(optional)Log Message Format10 Messages stored in Multi Producer Single Consumer Packet Buffer(MPSC_PBUF)circular buffer as continuous block of memory Messages must be sequentially freed suited for copying the messages for offline processing.Backend processi
11、ng is synchronous.Backend can make a copy for deferred processing.Log Message Memory11 Circular Buffer-First-in First Out Order,Continous block of memory.Allocation Policy,when requested space cannot be allocated:Overwrite-CONFIG_LOG_MODE_OVERFLOW(Degrades Performance)No-overwrite Producing the pack
12、et 2 steps Requested amount of data allocated,producer fills the data Commits it Consuming the packet-2 steps Consumer claims the packet(gets pointer to it and length)Packet is freed(Reduces memory copying)Multi Producer Single Consumer Packet Buffer12 Each packet contains MPSC_PBUF specific header.
13、Header 2 bits Valid Busy(Packet being consumed)Multi Producer Single Consumer Packet Buffer(Contd.)ValidValidBusyBusyDescriptionDescription00Space is Free10Valid Packet11Claimed valid Packet01Internal Skip Packet13 Need?To reduce Image size,to not overload the system Compile Time Filtering Module Se
14、verity Levels RunTime Filtering Source:Module or specific instance of module Independent for each backendLog Filtering14 Filter structure(Ten 3bit slots in RAM)for each source of logging:Run-Time FilteringSlot 0Slot 0INFSlot 1ERRSlot 2INFSlot 3OFFSlot 4Slot 5Slot 6Slot 7Slot 8Slot 9OFFEach slot stor
15、es current filter for one backend in the systemAggregate maximal filter for given source15DeferredDeferredImmediateImmediateMinimalMinimalLog messages are buffered and processed later.Log is processed in the context of the call.Immediate output.Redirected to printkTime consuming processing is deferr
16、ed to the known context.Least impact on the application.Impacts performance,time consuming operationsperformed in context of the logentry(e.g.high priority interrupt)No run time filtering,formatting,timestampingBuild-time,run-timefilteringFiltering and formattingLow FootprintRich formatting,timestam
17、ping.IntrusiveClose to non-intrusiveLimited backends supportedAny backendModes of Logging16 Domain:Independent Binary Build Restricted Memory access cross domains Approaches:1.Inside each domain independently.Not scalable2.Use a multi-domain logging system.Log messages inside each domain goes to one
18、 root domain.Passed using link between domains.One backend-Other backend.Log Link Interface:Receives log messages from another domain.Creates copy&put local log message copy into message queue.Matches complementary backend implementation.Multi-Domain Logging17 Types of Domains:End Domain:Logging cor
19、e implementation&a cross-domain backend.Relay Domain Links to other domains but does not have backends.Has a cross-domain backend either to another relay or to the root domain.Root Domain One or multiple links and a backend that outputs logs to the user.Runtime-filtering works identically in both mu
20、lti-domain and single-domain scenarios.Multi-Domain Logging(Contd.)18 MIPI-SyS-T:CONFIG_LOG_MIPI_SYST_ENABLE Universal data format for sharing software debug and trace information between test systems and devices such as systems-on-chip(SoC)or platforms.Simplify Integration of embedded software and
21、debug hardware Developing test products Dictionary:LOG_DICTIONARY_SUPPORT Outputs in binary format.Encodes arguments to formatted strings in native storage formats-compact long double-Not supported.Text:Default Requires less processing than dict.Custom Format:CONFIG_LOG_CUSTOM_FORMAT_SUPPORTTypes of
22、 Logging Formats19 User can pass the output format needed and use APIs like log_format_set(const struct log_backend*backend,uint32_t log_type)log_format_set_all_active_backends(size_t log_type)Limitations Deferred mode.Results in dropped messages large number of messages to be printed.Wont be able t
23、o see complete results.Recommendations:Use Immediate ModeDynamically Switch Logging formats20MIPI SyS-TTextMIPI SyS-T21 Logging Documentation Mailing Lists:User List:userslists.zephyrproject.org Developer List:devellists.zephyrproject.org Discord Channel:#logging#tracing Contributing to Zephyr:See theContribution GuideReferences22Questions?Comments?23Thank You-Aastha Grover