Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1244507ybl; Sun, 1 Dec 2019 23:59:33 -0800 (PST) X-Google-Smtp-Source: APXvYqyTtjXNMgpQ9ODHofC6RAPyomJMyaywNcdHGtMCugi2AY0kDCrUmA86FN9T6ehoT6iozc87 X-Received: by 2002:aa7:cf81:: with SMTP id z1mr28478904edx.157.1575273573351; Sun, 01 Dec 2019 23:59:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575273573; cv=none; d=google.com; s=arc-20160816; b=paYoPXvfrS5pyVp820/Ay3jl3/CvBw+aSW2MeP8xKtRsUZRKQsfba0yWZzBF6VYKsU 4bv0k32LcmU+pbP97xfUqiozQX1oTdteuLJoFH4vwHTp6LdCCF6f2m3Yl36Cdl3drGEe +2OGhYA75VYuvt1B5NMxI0lL+cwIe260vc2tcyW+5r7dPdmFOCrYZ7GnFvA4J7Drxdan eN03FOIcfYCcQix1QSDfaeuNb3jKijTnroUjR5tU/+xHM82OB52N/zzcl/i9QwusKfbj mMq9zAzpHFPZROcpFaxDrUEgPopp3Ss0vYM741TWdLTpBV8DVBx3GQhQEv2+GeWgnemr MPJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id:dkim-signature; bh=34AgENn3LP2F0xBcKj3nh7FTCsEI1E8QD6VctPYAQOs=; b=ptbtrXEFB8tcFX3w2lcJI6vk7yWErv90XTu7VQEs5Gcu6c8XTaMtRB0rLIVmdMzIsQ eHXxaS96e2XgJBieV78weueu54vfs7vevYYv/T6TzLRXOp36bA4dSPnjTqJL2jIBnumW uNF6dg2VBERIqVmC1d5k5URy+Oz0Q0VsL9wl17KNPq5r4l8sjHxOWzILFfliuvLJjlH1 7Ec7y5bhcRk0dT7DZ4eg2R9zfBNW62pVEMHcMeFf1B+cm73VNr3G5rcbMQHTKYuX8va2 vISjKAHEHiyr4ZQXCRVgdVfW/HUSHuG2CSxaBBDkRdAkqwEnKjup6uFm5gF86YHB53Lw MxwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=bblCPYuN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dg3si3597926edb.61.2019.12.01.23.59.02; Sun, 01 Dec 2019 23:59:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=bblCPYuN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727364AbfLBH5e (ORCPT + 99 others); Mon, 2 Dec 2019 02:57:34 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:61109 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727221AbfLBH5c (ORCPT ); Mon, 2 Dec 2019 02:57:32 -0500 Received: from localhost (mailhub1-ext [192.168.12.233]) by localhost (Postfix) with ESMTP id 47RHX656Q5z9txt2; Mon, 2 Dec 2019 08:57:26 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=bblCPYuN; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id vP5LoNkWLm7o; Mon, 2 Dec 2019 08:57:26 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 47RHX645Ntz9txsp; Mon, 2 Dec 2019 08:57:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1575273446; bh=34AgENn3LP2F0xBcKj3nh7FTCsEI1E8QD6VctPYAQOs=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=bblCPYuNvB9bwt4bpd4gI/kJc+nomzfnr019BgljxWK7U0W55DD5htgf8k6ftpYi7 MaAT/AT9qN5mqJJs6dl+ZsrkWqcHyD7TGPQaI3GRWCThekcdJQYUBbrQEf8LYv7f0R fU2WJ+JIjPI8w5hI5IWL5X9EaQEPWnwYU+u6DQJk= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2AE1A8B79B; Mon, 2 Dec 2019 08:57:31 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id ta0_7kHH6YWV; Mon, 2 Dec 2019 08:57:31 +0100 (CET) Received: from po16098vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.230.103]) by messagerie.si.c-s.fr (Postfix) with ESMTP id ECA188B79A; Mon, 2 Dec 2019 08:57:30 +0100 (CET) Received: by po16098vm.idsi0.si.c-s.fr (Postfix, from userid 0) id E344C63600; Mon, 2 Dec 2019 07:57:30 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v4 4/8] powerpc/vdso32: inline __get_datapage() To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, arnd@arndb.de Date: Mon, 2 Dec 2019 07:57:30 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __get_datapage() is only a few instructions to retrieve the address of the page where the kernel stores data to the VDSO. By inlining this function into its users, a bl/blr pair and a mflr/mtlr pair is avoided, plus a few reg moves. The improvement is noticeable (about 55 nsec/call on an 8xx) vdsotest before the patch: gettimeofday: vdso: 731 nsec/call clock-gettime-realtime-coarse: vdso: 668 nsec/call clock-gettime-monotonic-coarse: vdso: 745 nsec/call vdsotest after the patch: gettimeofday: vdso: 677 nsec/call clock-gettime-realtime-coarse: vdso: 613 nsec/call clock-gettime-monotonic-coarse: vdso: 690 nsec/call Signed-off-by: Christophe Leroy --- v3: define get_datapage macro in asm/vdso_datapage.h v4: fixed build failure with old binutils --- arch/powerpc/include/asm/vdso_datapage.h | 10 ++++++++++ arch/powerpc/kernel/vdso32/cacheflush.S | 9 ++++----- arch/powerpc/kernel/vdso32/datapage.S | 28 +++------------------------- arch/powerpc/kernel/vdso32/gettimeofday.S | 12 +++++------- 4 files changed, 22 insertions(+), 37 deletions(-) diff --git a/arch/powerpc/include/asm/vdso_datapage.h b/arch/powerpc/include/asm/vdso_datapage.h index 40f13f3626d3..ee5319a6f4e3 100644 --- a/arch/powerpc/include/asm/vdso_datapage.h +++ b/arch/powerpc/include/asm/vdso_datapage.h @@ -118,6 +118,16 @@ struct vdso_data { extern struct vdso_data *vdso_data; +#else /* __ASSEMBLY__ */ + +.macro get_datapage ptr, tmp + bcl 20, 31, .+4 + mflr \ptr + addi \ptr, \ptr, (__kernel_datapage_offset - (.-4))@l + lwz \tmp, 0(\ptr) + add \ptr, \tmp, \ptr +.endm + #endif /* __ASSEMBLY__ */ #endif /* __KERNEL__ */ diff --git a/arch/powerpc/kernel/vdso32/cacheflush.S b/arch/powerpc/kernel/vdso32/cacheflush.S index 7f882e7b9f43..d178ec8c279d 100644 --- a/arch/powerpc/kernel/vdso32/cacheflush.S +++ b/arch/powerpc/kernel/vdso32/cacheflush.S @@ -8,6 +8,7 @@ #include #include #include +#include #include .text @@ -24,14 +25,12 @@ V_FUNCTION_BEGIN(__kernel_sync_dicache) .cfi_startproc mflr r12 .cfi_register lr,r12 - mr r11,r3 - bl __get_datapage@local + get_datapage r10, r0 mtlr r12 - mr r10,r3 lwz r7,CFG_DCACHE_BLOCKSZ(r10) addi r5,r7,-1 - andc r6,r11,r5 /* round low to line bdy */ + andc r6,r3,r5 /* round low to line bdy */ subf r8,r6,r4 /* compute length */ add r8,r8,r5 /* ensure we get enough */ lwz r9,CFG_DCACHE_LOGBLOCKSZ(r10) @@ -48,7 +47,7 @@ V_FUNCTION_BEGIN(__kernel_sync_dicache) lwz r7,CFG_ICACHE_BLOCKSZ(r10) addi r5,r7,-1 - andc r6,r11,r5 /* round low to line bdy */ + andc r6,r3,r5 /* round low to line bdy */ subf r8,r6,r4 /* compute length */ add r8,r8,r5 lwz r9,CFG_ICACHE_LOGBLOCKSZ(r10) diff --git a/arch/powerpc/kernel/vdso32/datapage.S b/arch/powerpc/kernel/vdso32/datapage.S index 6c7401bd284e..1095d818f94a 100644 --- a/arch/powerpc/kernel/vdso32/datapage.S +++ b/arch/powerpc/kernel/vdso32/datapage.S @@ -10,35 +10,13 @@ #include #include #include +#include .text .global __kernel_datapage_offset; __kernel_datapage_offset: .long 0 -V_FUNCTION_BEGIN(__get_datapage) - .cfi_startproc - /* We don't want that exposed or overridable as we want other objects - * to be able to bl directly to here - */ - .protected __get_datapage - .hidden __get_datapage - - mflr r0 - .cfi_register lr,r0 - - bcl 20,31,data_page_branch -data_page_branch: - mflr r3 - mtlr r0 - addi r3, r3, __kernel_datapage_offset-data_page_branch - lwz r0,0(r3) - .cfi_restore lr - add r3,r0,r3 - blr - .cfi_endproc -V_FUNCTION_END(__get_datapage) - /* * void *__kernel_get_syscall_map(unsigned int *syscall_count) ; * @@ -53,7 +31,7 @@ V_FUNCTION_BEGIN(__kernel_get_syscall_map) mflr r12 .cfi_register lr,r12 mr r4,r3 - bl __get_datapage@local + get_datapage r3, r0 mtlr r12 addi r3,r3,CFG_SYSCALL_MAP32 cmpli cr0,r4,0 @@ -75,7 +53,7 @@ V_FUNCTION_BEGIN(__kernel_get_tbfreq) .cfi_startproc mflr r12 .cfi_register lr,r12 - bl __get_datapage@local + get_datapage r3, r0 lwz r4,(CFG_TB_TICKS_PER_SEC + 4)(r3) lwz r3,CFG_TB_TICKS_PER_SEC(r3) mtlr r12 diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kernel/vdso32/gettimeofday.S index e9ce8ee56edb..74973548529a 100644 --- a/arch/powerpc/kernel/vdso32/gettimeofday.S +++ b/arch/powerpc/kernel/vdso32/gettimeofday.S @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -33,8 +34,7 @@ V_FUNCTION_BEGIN(__kernel_gettimeofday) mr r10,r3 /* r10 saves tv */ mr r11,r4 /* r11 saves tz */ - bl __get_datapage@local /* get data page */ - mr r9, r3 /* datapage ptr in r9 */ + get_datapage r9, r0 cmplwi r10,0 /* check if tv is NULL */ beq 3f lis r7,1000000@ha /* load up USEC_PER_SEC */ @@ -80,8 +80,7 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime) mflr r12 /* r12 saves lr */ .cfi_register lr,r12 mr r11,r4 /* r11 saves tp */ - bl __get_datapage@local /* get data page */ - mr r9,r3 /* datapage ptr in r9 */ + get_datapage r9, r0 lis r7,NSEC_PER_SEC@h /* want nanoseconds */ ori r7,r7,NSEC_PER_SEC@l beq cr5, .Lcoarse_clocks @@ -206,7 +205,7 @@ V_FUNCTION_BEGIN(__kernel_clock_getres) mflr r12 .cfi_register lr,r12 - bl __get_datapage@local /* get data page */ + get_datapage r3, r0 lwz r5, CLOCK_HRTIMER_RES(r3) mtlr r12 li r3,0 @@ -240,8 +239,7 @@ V_FUNCTION_BEGIN(__kernel_time) .cfi_register lr,r12 mr r11,r3 /* r11 holds t */ - bl __get_datapage@local - mr r9, r3 /* datapage ptr in r9 */ + get_datapage r9, r0 lwz r3,STAMP_XTIME_SEC+LOPART(r9) -- 2.13.3