mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
parisc: Reduce kernel size by packing alternative tables
The values stored in the length and condition fields of the alternative tables fit into 16 bits, so we can save 4 bytes per alternative table entry. Since a typical 32-bit kernel has more than 3000 entries this saves > 12k of storage on disc. bloat-o-meter shows a reduction of -0.01% by this change: Total: Before=10196505, After=10195529, chg -0.01% $ ls -la vmlinux vmlinux.before -rwxr-xr-x 14437324 vmlinux -rwxr-xr-x 14449512 vmlinux.before Signed-off-by: Helge Deller <deller@gmx.de>
This commit is contained in:
@@ -22,10 +22,10 @@
|
|||||||
|
|
||||||
struct alt_instr {
|
struct alt_instr {
|
||||||
s32 orig_offset; /* offset to original instructions */
|
s32 orig_offset; /* offset to original instructions */
|
||||||
s32 len; /* end of original instructions */
|
s16 len; /* end of original instructions */
|
||||||
u32 cond; /* see ALT_COND_XXX */
|
u16 cond; /* see ALT_COND_XXX */
|
||||||
u32 replacement; /* replacement instruction or code */
|
u32 replacement; /* replacement instruction or code */
|
||||||
};
|
} __packed;
|
||||||
|
|
||||||
void set_kernel_text_rw(int enable_read_write);
|
void set_kernel_text_rw(int enable_read_write);
|
||||||
void apply_alternatives_all(void);
|
void apply_alternatives_all(void);
|
||||||
@@ -35,8 +35,9 @@ void apply_alternatives(struct alt_instr *start, struct alt_instr *end,
|
|||||||
/* Alternative SMP implementation. */
|
/* Alternative SMP implementation. */
|
||||||
#define ALTERNATIVE(cond, replacement) "!0:" \
|
#define ALTERNATIVE(cond, replacement) "!0:" \
|
||||||
".section .altinstructions, \"aw\" !" \
|
".section .altinstructions, \"aw\" !" \
|
||||||
".word (0b-4-.), 1, " __stringify(cond) "," \
|
".word (0b-4-.) !" \
|
||||||
__stringify(replacement) " !" \
|
".hword 1, " __stringify(cond) " !" \
|
||||||
|
".word " __stringify(replacement) " !" \
|
||||||
".previous"
|
".previous"
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@@ -44,15 +45,17 @@ void apply_alternatives(struct alt_instr *start, struct alt_instr *end,
|
|||||||
/* to replace one single instructions by a new instruction */
|
/* to replace one single instructions by a new instruction */
|
||||||
#define ALTERNATIVE(from, to, cond, replacement)\
|
#define ALTERNATIVE(from, to, cond, replacement)\
|
||||||
.section .altinstructions, "aw" ! \
|
.section .altinstructions, "aw" ! \
|
||||||
.word (from - .), (to - from)/4 ! \
|
.word (from - .) ! \
|
||||||
.word cond, replacement ! \
|
.hword (to - from)/4, cond ! \
|
||||||
|
.word replacement ! \
|
||||||
.previous
|
.previous
|
||||||
|
|
||||||
/* to replace multiple instructions by new code */
|
/* to replace multiple instructions by new code */
|
||||||
#define ALTERNATIVE_CODE(from, num_instructions, cond, new_instr_ptr)\
|
#define ALTERNATIVE_CODE(from, num_instructions, cond, new_instr_ptr)\
|
||||||
.section .altinstructions, "aw" ! \
|
.section .altinstructions, "aw" ! \
|
||||||
.word (from - .), -num_instructions ! \
|
.word (from - .) ! \
|
||||||
.word cond, (new_instr_ptr - .) ! \
|
.hword -num_instructions, cond ! \
|
||||||
|
.word (new_instr_ptr - .) ! \
|
||||||
.previous
|
.previous
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
#endif /* __ASSEMBLY__ */
|
||||||
|
@@ -26,7 +26,7 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
|
|||||||
struct alt_instr *entry;
|
struct alt_instr *entry;
|
||||||
int index = 0, applied = 0;
|
int index = 0, applied = 0;
|
||||||
int num_cpus = num_online_cpus();
|
int num_cpus = num_online_cpus();
|
||||||
u32 cond_check;
|
u16 cond_check;
|
||||||
|
|
||||||
cond_check = ALT_COND_ALWAYS |
|
cond_check = ALT_COND_ALWAYS |
|
||||||
((num_cpus == 1) ? ALT_COND_NO_SMP : 0) |
|
((num_cpus == 1) ? ALT_COND_NO_SMP : 0) |
|
||||||
@@ -45,8 +45,9 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
|
|||||||
|
|
||||||
for (entry = start; entry < end; entry++, index++) {
|
for (entry = start; entry < end; entry++, index++) {
|
||||||
|
|
||||||
u32 *from, cond, replacement;
|
u32 *from, replacement;
|
||||||
s32 len;
|
u16 cond;
|
||||||
|
s16 len;
|
||||||
|
|
||||||
from = (u32 *)((ulong)&entry->orig_offset + entry->orig_offset);
|
from = (u32 *)((ulong)&entry->orig_offset + entry->orig_offset);
|
||||||
len = entry->len;
|
len = entry->len;
|
||||||
|
Reference in New Issue
Block a user