aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2022-05-24 10:42:24 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2022-05-24 10:42:24 -0300
commitc3d6522e0499c5b0364aa6f16c47d6743776a602 (patch)
tree3578cbebcb9061ec2b6ba0710e65063ff3bb3e0f
parent384a16a011226163f097425e3770d2ab91108a1e (diff)
downloadpahole-c3d6522e0499c5b0364aa6f16c47d6743776a602.tar.gz
fprintf: Fix plural/singular when printing cacheline boundary
Mostly happens in explicitely packed structs, but there are other cases as well, one of which we can see below: Before/after: --- /tmp/b 2022-05-24 09:50:53.872105860 -0300 +++ /tmp/a 2022-05-24 09:51:39.891231335 -0300 @@ -8421,37 +8421,37 @@ struct new_utsname { char sysname[65]; /* 0 65 */ - /* --- cacheline 1 boundary (64 bytes) was 1 bytes ago --- */ + /* --- cacheline 1 boundary (64 bytes) was 1 byte ago --- */ char nodename[65]; /* 65 65 */ /* --- cacheline 2 boundary (128 bytes) was 2 bytes ago --- */ char release[65]; /* 130 65 */ /* --- cacheline 3 boundary (192 bytes) was 3 bytes ago --- */ char version[65]; /* 195 65 */ /* --- cacheline 4 boundary (256 bytes) was 4 bytes ago --- */ char machine[65]; /* 260 65 */ /* --- cacheline 5 boundary (320 bytes) was 5 bytes ago --- */ char domainname[65]; /* 325 65 */ /* size: 390, cachelines: 7, members: 6 */ /* last cacheline: 6 bytes */ }; @@ -27848,37 +27848,37 @@ struct old_utsname { char sysname[65]; /* 0 65 */ - /* --- cacheline 1 boundary (64 bytes) was 1 bytes ago --- */ + /* --- cacheline 1 boundary (64 bytes) was 1 byte ago --- */ char nodename[65]; /* 65 65 */ /* --- cacheline 2 boundary (128 bytes) was 2 bytes ago --- */ char release[65]; /* 130 65 */ /* --- cacheline 3 boundary (192 bytes) was 3 bytes ago --- */ char version[65]; /* 195 65 */ /* --- cacheline 4 boundary (256 bytes) was 4 bytes ago --- */ char machine[65]; /* 260 65 */ /* size: 325, cachelines: 6, members: 5 */ /* last cacheline: 5 bytes */ }; @@ -52698,37 +52698,37 @@ struct nfs41_impl_id { char domain[1025]; /* 0 1025 */ - /* --- cacheline 16 boundary (1024 bytes) was 1 bytes ago --- */ + /* --- cacheline 16 boundary (1024 bytes) was 1 byte ago --- */ char name[1025]; /* 1025 1025 */ /* XXX 6 bytes hole, try to pack */ /* --- cacheline 32 boundary (2048 bytes) was 8 bytes ago --- */ struct nfstime4 date; /* 2056 16 */ /* XXX last struct has 4 bytes of padding */ /* size: 2072, cachelines: 33, members: 3 */ /* sum members: 2066, holes: 1, sum holes: 6 */ /* paddings: 1, sum paddings: 4 */ /* last cacheline: 24 bytes */ }; @@ -100590,37 +100590,37 @@ struct cxl_mbox_identify { char fw_revision[16]; /* 0 16 */ __le64 total_capacity; /* 16 8 */ __le64 volatile_capacity; /* 24 8 */ __le64 persistent_capacity; /* 32 8 */ __le64 partition_align; /* 40 8 */ __le16 info_event_log_size; /* 48 2 */ __le16 warning_event_log_size; /* 50 2 */ __le16 failure_event_log_size; /* 52 2 */ __le16 fatal_event_log_size; /* 54 2 */ __le32 lsa_size; /* 56 4 */ u8 poison_list_max_mer[3]; /* 60 3 */ __le16 inject_poison_limit; /* 63 2 */ - /* --- cacheline 1 boundary (64 bytes) was 1 bytes ago --- */ + /* --- cacheline 1 boundary (64 bytes) was 1 byte ago --- */ u8 poison_caps; /* 65 1 */ u8 qos_telemetry_caps; /* 66 1 */ /* size: 67, cachelines: 2, members: 14 */ /* last cacheline: 3 bytes */ } __attribute__((__packed__)); @@ -137125,37 +137125,37 @@ struct saved_context { struct pt_regs regs; /* 0 168 */ /* --- cacheline 2 boundary (128 bytes) was 40 bytes ago --- */ u16 ds; /* 168 2 */ u16 es; /* 170 2 */ u16 fs; /* 172 2 */ u16 gs; /* 174 2 */ long unsigned int kernelmode_gs_base; /* 176 8 */ long unsigned int usermode_gs_base; /* 184 8 */ /* --- cacheline 3 boundary (192 bytes) --- */ long unsigned int fs_base; /* 192 8 */ long unsigned int cr0; /* 200 8 */ long unsigned int cr2; /* 208 8 */ long unsigned int cr3; /* 216 8 */ long unsigned int cr4; /* 224 8 */ u64 misc_enable; /* 232 8 */ bool misc_enable_saved; /* 240 1 */ struct saved_msrs saved_msrs; /* 241 16 */ - /* --- cacheline 4 boundary (256 bytes) was 1 bytes ago --- */ + /* --- cacheline 4 boundary (256 bytes) was 1 byte ago --- */ long unsigned int efer; /* 257 8 */ u16 gdt_pad; /* 265 2 */ struct desc_ptr gdt_desc; /* 267 10 */ u16 idt_pad; /* 277 2 */ struct desc_ptr idt; /* 279 10 */ u16 ldt; /* 289 2 */ u16 tss; /* 291 2 */ long unsigned int tr; /* 293 8 */ long unsigned int safety; /* 301 8 */ long unsigned int return_address; /* 309 8 */ /* size: 317, cachelines: 5, members: 25 */ /* last cacheline: 61 bytes */ } __attribute__((__packed__)); Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--dwarves_fprintf.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c
index d751e642..2cec5843 100644
--- a/dwarves_fprintf.c
+++ b/dwarves_fprintf.c
@@ -1359,9 +1359,10 @@ static size_t class__fprintf_cacheline_boundary(struct conf_fprintf *conf,
cacheline_in_bytes);
else
printed += fprintf(fp, "/* --- cacheline %u boundary "
- "(%u bytes) was %u bytes ago --- "
+ "(%u bytes) was %u byte%s ago --- "
"*/\n", cacheline,
- cacheline_in_bytes, cacheline_pos);
+ cacheline_in_bytes, cacheline_pos,
+ cacheline_pos > 1 ? "s" : "");
printed += fprintf(fp, "%.*s", indent, tabs);