Skip to content

Commit 857f451

Browse files
eleanorLYJvineetgarc
authored andcommitted
ARC: unwind: Use built-in sort swap to reduce code size and improve performance
The custom swap function used in sort() was identical to the default built-in sort swap. Remove the custom swap function and passes NULL to sort(), allowing it to use the default swap function. This change reduces code size and improves performance, particularly when CONFIG_MITIGATION_RETPOLINE is enabled. With RETPOLINE mitigation, indirect function calls incur significant overhead, and using the default swap function avoids this cost. $ ./scripts/bloat-o-meter ./unwind.o.old ./unwind.o.new add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-22 (-22) Function old new delta init_unwind_hdr.constprop 544 540 -4 swap_eh_frame_hdr_table_entries 18 - -18 Total: Before=4410, After=4388, chg -0.50% Signed-off-by: Yu-Chun Lin <[email protected]> Signed-off-by: Vineet Gupta <[email protected]>
1 parent ea7caff commit 857f451

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

arch/arc/kernel/unwind.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,6 @@ static int cmp_eh_frame_hdr_table_entries(const void *p1, const void *p2)
241241
return (e1->start > e2->start) - (e1->start < e2->start);
242242
}
243243

244-
static void swap_eh_frame_hdr_table_entries(void *p1, void *p2, int size)
245-
{
246-
struct eh_frame_hdr_table_entry *e1 = p1;
247-
struct eh_frame_hdr_table_entry *e2 = p2;
248-
249-
swap(e1->start, e2->start);
250-
swap(e1->fde, e2->fde);
251-
}
252-
253244
static void init_unwind_hdr(struct unwind_table *table,
254245
void *(*alloc) (unsigned long))
255246
{
@@ -345,7 +336,7 @@ static void init_unwind_hdr(struct unwind_table *table,
345336
sort(header->table,
346337
n,
347338
sizeof(*header->table),
348-
cmp_eh_frame_hdr_table_entries, swap_eh_frame_hdr_table_entries);
339+
cmp_eh_frame_hdr_table_entries, NULL);
349340

350341
table->hdrsz = hdrSize;
351342
smp_wmb();

0 commit comments

Comments
 (0)