From: Michael Ellerman <mpe@ellerman.id.au>
To: Andrey Abramov <st5pub@yandex.ru>,
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] powerpc: module_[32|64].c: replace swap function with built-in one
Date: Mon, 01 Apr 2019 21:11:19 +1100 [thread overview]
Message-ID: <87zhpaox14.fsf@concordia.ellerman.id.au> (raw)
In-Reply-To: <21287961553964090@iva7-8a22bc446c12.qloud-c.yandex.net>
Andrey Abramov <st5pub@yandex.ru> writes:
> Replace relaswap with built-in one, because of relaswap
> does a simple byte to byte swap.
>
> Signed-off-by: Andrey Abramov <st5pub@yandex.ru>
> ---
> arch/powerpc/kernel/module_32.c | 17 +----------------
> arch/powerpc/kernel/module_64.c | 17 +----------------
> 2 files changed, 2 insertions(+), 32 deletions(-)
This looks OK. It's a bit of a pity to replace the 8-byte-at-a-time copy
with a byte-at-a-time copy, but I suspect it's insignificant compared to
the overhead of calling the comparison and swap functions.
And we could always add a generic 8-byte-at-a-time swap function if it's
a bottleneck.
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
cheers
> diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
> index 88d83771f462..c311e8575d10 100644
> --- a/arch/powerpc/kernel/module_32.c
> +++ b/arch/powerpc/kernel/module_32.c
> @@ -79,21 +79,6 @@ static int relacmp(const void *_x, const void *_y)
> return 0;
> }
>
> -static void relaswap(void *_x, void *_y, int size)
> -{
> - uint32_t *x, *y, tmp;
> - int i;
> -
> - y = (uint32_t *)_x;
> - x = (uint32_t *)_y;
> -
> - for (i = 0; i < sizeof(Elf32_Rela) / sizeof(uint32_t); i++) {
> - tmp = x[i];
> - x[i] = y[i];
> - y[i] = tmp;
> - }
> -}
> -
> /* Get the potential trampolines size required of the init and
> non-init sections */
> static unsigned long get_plt_size(const Elf32_Ehdr *hdr,
> @@ -130,7 +115,7 @@ static unsigned long get_plt_size(const Elf32_Ehdr *hdr,
> */
> sort((void *)hdr + sechdrs[i].sh_offset,
> sechdrs[i].sh_size / sizeof(Elf32_Rela),
> - sizeof(Elf32_Rela), relacmp, relaswap);
> + sizeof(Elf32_Rela), relacmp, NULL);
>
> ret += count_relocs((void *)hdr
> + sechdrs[i].sh_offset,
> diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
> index 8661eea78503..0c833d7f36f1 100644
> --- a/arch/powerpc/kernel/module_64.c
> +++ b/arch/powerpc/kernel/module_64.c
> @@ -231,21 +231,6 @@ static int relacmp(const void *_x, const void *_y)
> return 0;
> }
>
> -static void relaswap(void *_x, void *_y, int size)
> -{
> - uint64_t *x, *y, tmp;
> - int i;
> -
> - y = (uint64_t *)_x;
> - x = (uint64_t *)_y;
> -
> - for (i = 0; i < sizeof(Elf64_Rela) / sizeof(uint64_t); i++) {
> - tmp = x[i];
> - x[i] = y[i];
> - y[i] = tmp;
> - }
> -}
> -
> /* Get size of potential trampolines required. */
> static unsigned long get_stubs_size(const Elf64_Ehdr *hdr,
> const Elf64_Shdr *sechdrs)
> @@ -269,7 +254,7 @@ static unsigned long get_stubs_size(const Elf64_Ehdr *hdr,
> */
> sort((void *)sechdrs[i].sh_addr,
> sechdrs[i].sh_size / sizeof(Elf64_Rela),
> - sizeof(Elf64_Rela), relacmp, relaswap);
> + sizeof(Elf64_Rela), relacmp, NULL);
>
> relocs += count_relocs((void *)sechdrs[i].sh_addr,
> sechdrs[i].sh_size
> --
> 2.21.0
next prev parent reply other threads:[~2019-04-01 10:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-30 16:37 [PATCH 0/5] simple sort swap function usage improvements Andrey Abramov
2019-03-30 16:40 ` [PATCH 1/5] arch/arc: unwind.c: replace swap function with built-in one Andrey Abramov
2019-03-30 16:41 ` [PATCH 2/5] powerpc: module_[32|64].c: " Andrey Abramov
2019-04-01 10:11 ` Michael Ellerman [this message]
2019-04-02 19:11 ` Andrey Abramov
2019-03-30 16:42 ` [PATCH 3/5] ocfs2: dir, refcounttree, xattr: replace swap functions " Andrey Abramov
2019-03-30 16:43 ` [PATCH 4/5] ubifs: find.c: replace swap function " Andrey Abramov
2019-03-30 16:43 ` [PATCH 5/5] Lib: sort.h: replace int size with size_t size in the swap function Andrey Abramov
2019-03-30 18:38 ` gregkh
2019-03-30 17:16 ` [PATCH 0/5] simple sort swap function usage improvements George Spelvin
2019-03-30 18:32 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zhpaox14.fsf@concordia.ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=st5pub@yandex.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox