[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <E6B85BE5-10E8-4532-B599-1ACB83097A62@gmail.com>
Date: Tue, 20 Jun 2023 15:43:02 -0700
From: Nadav Amit <nadav.amit@...il.com>
To: Andy Lutomirski <luto@...nel.org>
Cc: Dave Hansen <dave.hansen@...el.com>,
Kent Overstreet <kent.overstreet@...ux.dev>,
Mark Rutland <mark.rutland@....com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-fsdevel@...r.kernel.org,
"linux-bcachefs@...r.kernel.org" <linux-bcachefs@...r.kernel.org>,
Kent Overstreet <kent.overstreet@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Uladzislau Rezki <urezki@...il.com>,
"hch@...radead.org" <hch@...radead.org>,
linux-mm <linux-mm@...ck.org>, Kees Cook <keescook@...omium.org>,
the arch/x86 maintainers <x86@...nel.org>
Subject: Re: [PATCH 07/32] mm: Bring back vmalloc_exec
> On Jun 20, 2023, at 3:32 PM, Andy Lutomirski <luto@...nel.org> wrote:
>
>> // out needs to be zeroed first
>> void unpack(struct uncompressed *out, const u64 *in, const struct
>> bitblock *blocks, int nblocks)
>> {
>> u64 *out_as_words = (u64*)out;
>> for (int i = 0; i < nblocks; i++) {
>> const struct bitblock *b;
>> out_as_words[b->target] |= (in[b->source] & b->mask) <<
>> b->shift;
>> }
>> }
>>
>> void apply_offsets(struct uncompressed *out, const struct uncompressed *offsets)
>> {
>> out->a += offsets->a;
>> out->b += offsets->b;
>> out->c += offsets->c;
>> out->d += offsets->d;
>> out->e += offsets->e;
>> out->f += offsets->f;
>> }
>>
>> Which generates nice code: https://godbolt.org/z/3fEq37hf5
>
> Thinking about this a bit more, I think the only real performance issue with my code is that it does 12 read-xor-write operations in memory, which all depend on each other in horrible ways.
If you compare the generated code, just notice that you forgot to initialize b in unpack() in this version.
I presume you wanted it to say "b = &blocks[i]”.
Powered by blists - more mailing lists