Skip to content

Commit 0f8ce39

Browse files
committed
rimage: print cold data and text percentage
Calculate and print percentage of cold text and data when building loadable modules. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 2bd7e9d commit 0f8ce39

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

tools/rimage/src/module.c

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ void module_parse_sections(struct module *module, const struct memory_config *me
316316
uint16_t i;
317317

318318
struct module_section *out_section = module->sections;
319+
size_t cold_text_size = 0, cold_data_size = 0;
319320

320321
fprintf(stdout, " Found %d sections, listing valid sections...\n",
321322
module->elf.sections_count);
@@ -361,15 +362,18 @@ void module_parse_sections(struct module *module, const struct memory_config *me
361362
out_section->load_address, out_section->address,
362363
out_section->address + out_section->size, out_section->size);
363364

364-
365365
switch (out_section->type) {
366366
case MST_DATA:
367367
info = &module->data;
368+
if (out_section->detached)
369+
cold_data_size += out_section->size;
368370
fprintf(stdout, "\tDATA");
369371
break;
370372

371373
case MST_TEXT:
372374
info = &module->text;
375+
if (out_section->detached)
376+
cold_text_size += out_section->size;
373377
fprintf(stdout, "\tTEXT");
374378
break;
375379

@@ -415,14 +419,33 @@ void module_parse_sections(struct module *module, const struct memory_config *me
415419
sections_info_finalize(&module->bss);
416420

417421
size_t fw_size = module->data.size + module->text.size;
422+
size_t rounded, start, end, size;
418423

419424
fprintf(stdout, " module: input size %zd (0x%zx) bytes %d sections\n",
420425
fw_size, fw_size, module->num_sections);
421-
fprintf(stdout, " module: text %zu (0x%zx) bytes\n"
422-
"\tdata %zu (0x%zx) bytes\n"
423-
"\tbss %zu (0x%zx) bytes\n\n",
424-
module->text.size, module->text.size,
425-
module->data.size, module->data.size,
426+
427+
/* MST_TEXT */
428+
start = module->text.start;
429+
end = module->text.end + cold_text_size;
430+
size = module->text.size + cold_text_size;
431+
rounded = ALIGN_UP(end, MAN_PAGE_SIZE) - start;
432+
fprintf(stdout,
433+
" module: text %zu (0x%zx) bytes, including %zu (0x%zx) %zu%% efficiency bytes\n",
434+
size, size, cold_text_size, cold_text_size,
435+
rounded ? (cold_text_size * 100 + rounded / 2) / rounded : 0);
436+
437+
/* MST_DATA */
438+
start = module->data.start;
439+
end = module->data.end + cold_data_size;
440+
size = module->data.size + cold_data_size;
441+
rounded = ALIGN_UP(end, MAN_PAGE_SIZE) - start;
442+
fprintf(stdout,
443+
"\tdata %zu (0x%zx) bytes, including %zu (0x%zx) %zu%% efficiency bytes\n",
444+
size, size, cold_data_size, cold_data_size,
445+
rounded ? (cold_data_size * 100 + rounded / 2) / rounded : 0);
446+
447+
/* MST_BSS */
448+
fprintf(stdout, "\tbss %zu (0x%zx) bytes\n",
426449
module->bss.size, module->bss.size);
427450
}
428451

0 commit comments

Comments
 (0)