From: Anthony Yznaga <anthony.yznaga@oracle.com>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: Vijay Kumar <vijay.ac.kumar@oracle.com>,
davem@davemloft.net, linux-kernel@vger.kernel.org,
sparclinux@vger.kernel.org, babu.moger@oracle.com,
rob.gardner@oracle.com
Subject: Re: [PATCH v2 2/2] sparc64: Use lzcnt instruction for fls and __fls
Date: Wed, 27 Sep 2017 14:45:34 -0700 [thread overview]
Message-ID: <9DB110D2-67D6-4CAA-8C14-C3AF995D9711@oracle.com> (raw)
In-Reply-To: <20170927195637.GB15193@ravnborg.org>
> On Sep 27, 2017, at 12:56 PM, Sam Ravnborg <sam@ravnborg.org> wrote:
>
> Hi Vijay.
>
> On Wed, Sep 27, 2017 at 01:25:26PM -0600, Vijay Kumar wrote:
>> For T4 and above, patch fls and __fls functions
>> at the boot time to use lzcnt instruction.
>>
>> Signed-off-by: Vijay Kumar <vijay.ac.kumar@oracle.com>
>> Reviewed-by: Babu Moger <babu.moger@oracle.com>
>> ---
>> arch/sparc/Makefile | 1 +
>> arch/sparc/kernel/head_64.S | 2 ++
>> arch/sparc/lib/Makefile | 3 +++
>> arch/sparc/lib/NG4fls.S | 30 ++++++++++++++++++++++++++++++
>> arch/sparc/lib/NG4patch.S | 9 +++++++++
>> 5 files changed, 45 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile
>> index 8496a07..0763cd8 100644
>> --- a/arch/sparc/Makefile
>> +++ b/arch/sparc/Makefile
>> @@ -48,6 +48,7 @@ KBUILD_CFLAGS += -ffixed-g4 -ffixed-g5 -fcall-used-g7 -Wno-sign-compare
>> KBUILD_CFLAGS += -Wa,--undeclared-regs
>> KBUILD_CFLAGS += $(call cc-option,-mtune=ultrasparc3)
>> KBUILD_AFLAGS += -m64 -mcpu=ultrasparc -Wa,--undeclared-regs
>> +KBUILD_AFLAGS += -Wa,-Asparc4
> This change is not justified anywhere??
It looks like this is to get the assembler to recognize the lzcnt instruction.
Vijay,
Older assemblers may not support this flag so you’ll need to hardcode the lzcnt instructions using .word directives.
Anthony
>
>>
>> ifeq ($(CONFIG_MCOUNT),y)
>> KBUILD_CFLAGS += -pg
>> diff --git a/arch/sparc/kernel/head_64.S b/arch/sparc/kernel/head_64.S
>> index 78e0211..1165254 100644
>> --- a/arch/sparc/kernel/head_64.S
>> +++ b/arch/sparc/kernel/head_64.S
>> @@ -628,6 +628,8 @@ niagara4_patch:
>> nop
>> call niagara4_patch_pageops
>> nop
>> + call niagara4_patch_fls
>> + nop
>>
>> ba,a,pt %xcc, 80f
>> nop
>> diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
>> index eefbb9c..72d2d8c 100644
>> --- a/arch/sparc/lib/Makefile
>> +++ b/arch/sparc/lib/Makefile
>> @@ -46,3 +46,6 @@ lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o
>> obj-$(CONFIG_SPARC64) += iomap.o
>> obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o
>> obj-$(CONFIG_SPARC64) += PeeCeeI.o
>> +
>> +obj-$(CONFIG_SPARC64) += fls.o
>> +obj-$(CONFIG_SPARC64) += NG4fls.o
>> diff --git a/arch/sparc/lib/NG4fls.S b/arch/sparc/lib/NG4fls.S
>> new file mode 100644
>> index 0000000..eb239aa
>> --- /dev/null
>> +++ b/arch/sparc/lib/NG4fls.S
>> @@ -0,0 +1,30 @@
>> +/* NG4fls.S: SPARC optimized fls and __fls for T4 and above.
>> + *
>> + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
>> + */
>> +
>> + .text
>> + .align 32
>> +
>> + .globl NG4fls
>> + .globl __NG4fls
>> + .type NG4fls, #function
>> + .type __NG4fls, #function
>
> Use ENTRY(), ENDPROC() as already mentioned.
>> +NG4fls:
>> + lzcnt %o0, %o1
>> + mov 64, %o2
>> + retl
>> + sub %o2, %o1, %o0
>> + .size NG4fls, .-NG4fls
>> +
>> +__NG4fls:
>> + brz,pn %o0, 1f
>> + mov %o0, %o1
> Use tabs for indent, not spaces. In this case one tab + one space.
>
>> + lzcnt %o1, %o0
>> + mov 63, %o2
>> + sub %o2, %o0, %o0
>> +1:
>> + retl
>> + nop
>> + .size __NG4fls, .-__NG4fls
>> diff --git a/arch/sparc/lib/NG4patch.S b/arch/sparc/lib/NG4patch.S
>> index 3cc0f8c..1010d53 100644
>> --- a/arch/sparc/lib/NG4patch.S
>> +++ b/arch/sparc/lib/NG4patch.S
>> @@ -52,3 +52,12 @@ niagara4_patch_pageops:
>> retl
>> nop
>> .size niagara4_patch_pageops,.-niagara4_patch_pageops
>> +
>> + .globl niagara4_patch_fls
>> + .type niagara4_patch_fls,#function
>> +niagara4_patch_fls:
>> + NG_DO_PATCH(fls, NG4fls)
>> + NG_DO_PATCH(__fls, __NG4fls)
>> + retl
>> + nop
>> + .size niagara4_patch_fls,.-niagara4_patch_fls
>
> Please path the remaining functions in this file with ENTRY(), ENDPROC() - in a separate patch.
>
> Sam
> --
> To unsubscribe from this list: send the line "unsubscribe sparclinux" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-09-27 21:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-27 19:25 [PATCH v2 0/2] sparc64: Optimize fls, fls64 " Vijay Kumar
2017-09-27 19:25 ` [PATCH v2 1/2] sparc64: Define SPARC default fls " Vijay Kumar
2017-09-27 19:50 ` Sam Ravnborg
2017-09-27 19:59 ` Sam Ravnborg
2017-09-27 19:25 ` [PATCH v2 2/2] sparc64: Use lzcnt instruction for " Vijay Kumar
2017-09-27 19:56 ` Sam Ravnborg
2017-09-27 20:29 ` Vijay Kumar
2017-09-27 21:02 ` David Miller
2017-09-27 21:45 ` Anthony Yznaga [this message]
2017-09-27 22:10 ` David Miller
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=9DB110D2-67D6-4CAA-8C14-C3AF995D9711@oracle.com \
--to=anthony.yznaga@oracle.com \
--cc=babu.moger@oracle.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=rob.gardner@oracle.com \
--cc=sam@ravnborg.org \
--cc=sparclinux@vger.kernel.org \
--cc=vijay.ac.kumar@oracle.com \
/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
all inboxes | Powered by JetHome®