[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YoPOcHvhWEqeEwzo@xhacker>
Date: Wed, 18 May 2022 00:33:52 +0800
From: Jisheng Zhang <jszhang@...nel.org>
To: Anup Patel <apatel@...tanamicro.com>
Cc: Anup Patel <anup@...infault.org>,
Atish Patra <atishp@...shpatra.org>,
Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>,
Andrey Ryabinin <ryabinin.a.a@...il.com>,
Alexander Potapenko <glider@...gle.com>,
Andrey Konovalov <andreyknvl@...il.com>,
Dmitry Vyukov <dvyukov@...gle.com>,
Vincenzo Frascino <vincenzo.frascino@....com>,
Alexandre Ghiti <alexandre.ghiti@...onical.com>,
linux-riscv <linux-riscv@...ts.infradead.org>,
"linux-kernel@...r.kernel.org List" <linux-kernel@...r.kernel.org>,
kasan-dev@...glegroups.com
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@...nel.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)
>
Powered by blists - more mailing lists