Project

General

Profile

IPC Logging » History » Version 1

laforge, 12/18/2016 12:10 PM

1 1 laforge
{{>toc}}
2
3
h1. IPC Logging
4
5
This is a non-standard/non-mainline high-speed in-memory logging sub-system that is present in the Qualcomm Linux kernel variants to perform logging of the IPC (inter processor communication) related drivers.
6
7
h2. User Interface
8
9
The user interface to obtain the logs is implemented via debugfs below @/sys/kernel/debug/ipc_logging@
10
11
For each ipc log context (see below) there is one sub-directory.  On the [[EC25]] this looks like:
12
<pre>
13
root@mdm9607-perf:# ls /sys/kernel/debug/ipc_logging
14
78b1000.uart          sps_bam_0x04044000_0  sps_bam_0x078c4000_0
15
bam_dmux              sps_bam_0x04044000_1  sps_bam_0x078c4000_1
16
diag                  sps_bam_0x04044000_2  sps_bam_0x078c4000_2
17
glink                 sps_bam_0x04044000_3  sps_bam_0x078c4000_3
18
glink_ssr             sps_bam_0x04044000_4  sps_bam_0x078c4000_4
19
kqmi_ind              sps_bam_0x06084000_0  sps_bam_0x07984000_0
20
kqmi_req_resp         sps_bam_0x06084000_1  sps_bam_0x07984000_1
21
local_IPCRTR          sps_bam_0x06084000_2  sps_bam_0x07984000_2
22
modem_IPCRTR          sps_bam_0x06084000_3  sps_bam_0x07984000_3
23
smd                   sps_bam_0x06084000_4  sps_bam_0x07984000_4
24
smd_pkt               sps_bam_0x07884000_0  sps_ipc_log0
25
smd_tty               sps_bam_0x07884000_1  sps_ipc_log1
26
smem                  sps_bam_0x07884000_2  sps_ipc_log2
27
smp2p                 sps_bam_0x07884000_3  sps_ipc_log3
28
smsm                  sps_bam_0x07884000_4  sps_ipc_log4
29
</pre>
30
31
Within each of those directories are two files: @log@ and @log_cont@.  Log shows you the log so far and then exits, while @log_cont@ performs a blocking read semantic at the end, similar from what you would normally have when using @tail -f@ on a classic log file.
32
33
The format of the log lines is like this:
34
<pre>
35
[  4191.362072425/      0x12bec5ff43] [diag_state_open_smd] MODEM_DATA setting diag state to 1
36
</pre>
37
where
38
* @4191.362072425@ is the number of seconds and nanoseconds since system boot
39
* @0x12bec5ff43@ is a _QTimer Timestamp_ (presumably some hardware timer?)
40
* @diag_state_open_smd@ is the function name of the function issuing the ipc log statement
41
* @MODEM_DATA setting diag state to 1@ is the format string that was printed, in this example @"%s setting diag state to 1", smd_info->name@ from @drivers/char/diag/diagfwd_smd.c@
42
43
44
h2. Official documentation
45
46
Below are excerpts from @Documentation/arm/msm/msm_ipc_logging.txt@:
47
48
h3. Introduction
49
50
This module will be used to log the events by any module/driver which enables Inter Processor Communication (IPC). Some of the IPC drivers such as Message Routers, Multiplexers etc. which act as a passive pipe need some mechanism to log their events. Since all such IPC drivers handle a
51
large amount of traffic/events, using kernel logs renders kernel logs unusable by other drivers and also degrades the performance of IPC drivers. This new module will help in logging such high frequency IPC
52
driver events while keeping the standard kernel logging mechanism intact.
53
54
h3. Hardware Description
55
56
This module does not drive any hardware resource and will only use the kernel memory-space to log the events.
57
58
h3. Design Goals
59
60
This module is designed to
61
* support logging for drivers handling large amount of traffic/events
62
* define & differentiate events/logs from different drivers
63
* support both id-based and stream-based logging
64
* support extracting the logs from both live target & memory dump
65
66
h3. IPC Log Context
67
68
This module will support logging by multiple drivers. To differentiate between the multiple drivers that are using this logging mechanism, each driver will be assigned a unique context by this module. Associated with each context is the logging space, dynamically allocated from the kernel memory-space, specific to that context so that the events logged using that context will not interfere with other contexts.
69
70
h3. Event Logging
71
72
Every event will be logged as a <Type: Size: Value> combination. Type field identifies the type of the event that is logged. Size field represents the size of the log information. Value field represents the actual information being logged. This approach will support both id-based logging and stream-based logging. This approach will also support logging sub-events of an event. This module will provide helper routines to encode/decode the logs to/from this format.
73
74
h3. Encode Context
75
76
Encode context is a temporary storage space that will be used by the client drivers to log the events in <Type: Size: Value> format. The client drivers will perform an encode start operation to initialize the encode context data structure. Then the client drivers will log their events into the encode context. Upon completion of event logging, the client drivers will perform an encode end operation to finalize the encode context data structure to be logged. Then this updated encode context data structure will be written into the client driver's IPC Log Context. The maximum event log size will be defined as 256 bytes.
77
78
h3. Log Space
79
80
Each context (Figure 1) has an associated log space, which is dynamically allocated from the kernel memory-space. The log space is organized as a list of 1 or more kernel memory pages. Each page (Figure 2) contains header information which is used to differentiate the log kernel page from the other kernel pages.
81
82
<pre>
83
      0 ---------------------------------
84
        |     magic_no = 0x25874452     |
85
        ---------------------------------
86
        |    nmagic_no = 0x52784425     |
87
        ---------------------------------
88
        |            version            |
89
        ---------------------------------
90
        |          user_version         |
91
        ---------------------------------
92
        |            log_id             |
93
        ---------------------------------
94
        |          header_size          |
95
        ---------------------------------
96
        |                               |
97
        |                               |
98
        |       name [20 chars]         |
99
        |                               |
100
        |                               |
101
        ---------------------------------
102
        |    run-time data structures   |
103
        ---------------------------------
104
         Figure 1 - Log Context Structure
105
106
107
        31                             0
108
      0 ---------------------------------
109
        |     magic_no = 0x52784425     |
110
        ---------------------------------
111
        |    nmagic_no = 0xAD87BBDA     |
112
        ---------------------------------
113
        |1|         page_num            |
114
        ---------------------------------
115
        |  read_offset  | write_offset  |
116
        ---------------------------------
117
        |            log_id             |
118
        ---------------------------------
119
        |     start_time low word       |
120
        |     start_time high word      |
121
        ---------------------------------
122
        |       end_time low word       |
123
        |       end_time high word      |
124
        ---------------------------------
125
        |         context offset        |
126
        ---------------------------------
127
        |    run-time data structures   |
128
        .            . . .              .
129
        ---------------------------------
130
        |                               |
131
        |           Log Data            |
132
        .              .                .
133
        .              .                .
134
        |                               |
135
        --------------------------------- PAGE_SIZE - 1
136
            Figure 2 - Log Page Structure
137
</pre>
138
139
In addition to extracting logs at runtime through DebugFS, IPC Logging has been designed to allow extraction of logs from a memory dump.  The magic numbers, timestamps, and context offset are all added to support the memory-dump extraction use case.
140
141
h3. Design
142
143
Alternate solutions discussed include using kernel & SMEM logs which are limited in size and hence using them render them unusable by other drivers. Also kernel logging into serial console is slowing down the performance of the drivers by multiple times and sometimes lead to APPs watchdog bite.
144
145
h3. SMP/multi-core
146
147
This module uses spinlocks & mutexes to handle multi-core safety.
148
149
h3. Performance
150
151
This logging mechanism, based on experimental data, is not expected to cause a significant performance degradation. Under worst case, it can cause 1 - 2 percent degradation in the throughput of the IPC Drivers.
152
153
h3. Dependencies
154
155
This module will partially depend on CONFIG_DEBUGFS, in order to dump the logs through debugfs. If CONFIG_DEBUGFS is disabled, the above mentioned helper functions will perform no operation and return appropriate error code if the return value is non void. Under such circumstances the logs can
156
only be extracted through the memory dump.
157
158
h3. User space utilities
159
160
DEBUGFS
161
162
h2. Kernel implementation
163
164
You can find related code in
165
<pre>
166
./include/linux/ipc_logging.h
167
./drivers/char/diag/diag_ipc_logging.h
168
./kernel/trace/ipc_logging.c
169
./kernel/trace/ipc_logging_debug.c
170
./kernel/trace/ipc_logging_private.h
171
</pre>
Add picture from clipboard (Maximum size: 48.8 MB)