Commit a961ec4
printk: Improve memory usage logging during boot
When the initial printk ring buffer size is updated, setup_log_buf()
allocates a new ring buffer, as well as a set of meta-data structures
for the new ring buffer. The function also emits the new size of the
ring buffer, but not the size of the meta-data structures.
This makes it difficult to assess how changing the log buffer size
impacts memory usage during boot.
For instance, increasing the ring buffer size from 512 KB to 1 MB
through the command line yields an increase of 2304 KB in reserved
memory at boot, while the only obvious change is the 512 KB
difference in the ring buffer sizes:
log_buf_len=512K:
printk: log_buf_len: 524288 bytes
Memory: ... (... 733252K reserved ...)
log_buf_len=1M:
printk: log_buf_len: 1048576 bytes
Memory: ... (... 735556K reserved ...)
This is because of how the size of the meta-data structures scale with
the size of the ring buffer.
Even when there aren't changes to the printk ring buffer size (i.e. the
initial size == 1 << CONFIG_LOG_BUF_SHIFT), it is impossible to tell
how much memory is consumed by the printk ring buffer during boot.
Therefore, unconditionally log the sizes of the printk ring buffer
and its meta-data structures, so that it's easier to understand
how changing the log buffer size (either through the command line or
by changing CONFIG_LOG_BUF_SHIFT) affects boot time memory usage.
With the new logs, it is much easier to see exactly why the memory
increased by 2304 KB:
log_buf_len=512K:
printk: log buffer data + meta data: 524288 + 1835008 = 2359296 bytes
Memory: ... (... 733252K reserved ...)
log_buf_len=1M:
printk: log buffer data + meta data: 1048576 + 3670016 = 4718592 bytes
Memory: ... (... 735556K reserved ...)
Signed-off-by: Isaac J. Manjarres <[email protected]>
Reviewed-by: Petr Mladek <[email protected]>
Tested-by: Petr Mladek <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[[email protected]: Updated the examples in the commit message, simplified comment for default buffer.]
Signed-off-by: Petr Mladek <[email protected]>1 parent 17b6557 commit a961ec4
1 file changed
+22
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1156 | 1156 | | |
1157 | 1157 | | |
1158 | 1158 | | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
1159 | 1170 | | |
1160 | 1171 | | |
1161 | 1172 | | |
| |||
1185 | 1196 | | |
1186 | 1197 | | |
1187 | 1198 | | |
1188 | | - | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
1189 | 1204 | | |
| 1205 | + | |
1190 | 1206 | | |
1191 | 1207 | | |
1192 | 1208 | | |
1193 | 1209 | | |
1194 | | - | |
| 1210 | + | |
1195 | 1211 | | |
1196 | 1212 | | |
1197 | 1213 | | |
1198 | 1214 | | |
1199 | 1215 | | |
1200 | 1216 | | |
1201 | | - | |
| 1217 | + | |
1202 | 1218 | | |
1203 | 1219 | | |
1204 | 1220 | | |
| |||
1261 | 1277 | | |
1262 | 1278 | | |
1263 | 1279 | | |
1264 | | - | |
| 1280 | + | |
1265 | 1281 | | |
1266 | 1282 | | |
1267 | 1283 | | |
| |||
1270 | 1286 | | |
1271 | 1287 | | |
1272 | 1288 | | |
| 1289 | + | |
| 1290 | + | |
1273 | 1291 | | |
1274 | 1292 | | |
1275 | 1293 | | |
| |||
0 commit comments