Messages in this thread | | | Date | Wed, 18 May 2022 00:33:52 +0800 | From | Jisheng Zhang <> | Subject | Re: [PATCH v2 2/4] riscv: introduce unified static key mechanism for CPU features |
| |
On Tue, May 17, 2022 at 09:31:50AM +0530, Anup Patel wrote: > On Mon, May 16, 2022 at 11:02 PM Jisheng Zhang <jszhang@kernel.org> wrote: > > ... > > Currently, RISCV_ISA_EXT_MAX equals to 64 while the base ID is 26. > > In those 26 base IDs, only F/D and V need static key, it means > > we waste at least 24 static keys. > > If you want to save space of unused static keys then there are other > ways. > > For example, you can create a small static key array which has > many-to-one relation with the ISA extension numbers. For ISA extension
"any problem in computer science can be solved with another layer of indirection" ;) I see your points, thanks very much! But I think the array should be a static inline function to make use of compiler optimization to avoid the array references for performance. And the static key check maybe used in modules, I want to export less vars. I'm cooking the patches, will send out for review soon.
> which are always ON or always OFF, we can use fixed FALSE and > TRUE keys. Something like below. > > enum riscv_isa_ext_key { > RISCV_ISA_EXT_KEY_FALSE = 0, > RISCV_ISA_EXT_KEY_TRUE, > RISCV_ISA_EXT_KEY_FLOAD, /* For 'F' and 'D' */ > RISCV_ISA_EXT_KEY_VECTOR, /* For all vector extensions */ > RISCV_ISA_EXT_KEY_SVINVAL, > RISCV_ISA_EXT_KEY_SSCOFPMT, > RISCV_ISA_EXT_KEY_MAX, > }; > > extern unsigned char __riscv_isa_ext_id2key[RISCV_ISA_EXT_ID_MAX]; > extern struct static_key_false __riscv_isa_ext_keys[RISCV_ISA_EXT_KEY_MAX]; > > static __always_inline bool __riscv_isa_extension_keycheck(unsigned int ext) > { > if (RISCV_ISA_EXT_ID_MAX <= ext) > return false; > return static_branch_unlikely(&__riscv_isa_ext_keys[__riscv_isa_ext_id2key[ext]]); > } > #define riscv_isa_extension_keycheck(ext) \ > __riscv_isa_extension_keycheck(RISCV_ISA_EXT_##ext) >
| |