mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

Implement current with an inline assembly, which makes use of the ALTERNATIVE macro, to read current from lowcore. Provide an alternative instruction with a different offset in case lowcore is relocated. This replaces sequences of two instructions with one instruction. Before: 100076: a5 1e 00 00 llilh %r1,0 10007a: e3 40 13 40 00 04 lg %r4,832(%r1) After: 100076: e3 10 03 40 00 04 lg %r1,832 Kernel image size change: add/remove: 3/17 grow/shrink: 166/2204 up/down: 7122/-24594 (-17472) Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
35 lines
821 B
C
35 lines
821 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* S390 version
|
|
* Copyright IBM Corp. 1999
|
|
* Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
|
|
*
|
|
* Derived from "include/asm-i386/current.h"
|
|
*/
|
|
|
|
#ifndef _S390_CURRENT_H
|
|
#define _S390_CURRENT_H
|
|
|
|
#include <asm/lowcore.h>
|
|
#include <asm/machine.h>
|
|
|
|
struct task_struct;
|
|
|
|
static __always_inline struct task_struct *get_current(void)
|
|
{
|
|
unsigned long ptr, lc_current;
|
|
|
|
lc_current = offsetof(struct lowcore, current_task);
|
|
asm_inline(
|
|
ALTERNATIVE(" lg %[ptr],%[offzero](%%r0)\n",
|
|
" lg %[ptr],%[offalt](%%r0)\n",
|
|
ALT_FEATURE(MFEATURE_LOWCORE))
|
|
: [ptr] "=d" (ptr)
|
|
: [offzero] "i" (lc_current),
|
|
[offalt] "i" (lc_current + LOWCORE_ALT_ADDRESS));
|
|
return (struct task_struct *)ptr;
|
|
}
|
|
|
|
#define current get_current()
|
|
|
|
#endif /* !(_S390_CURRENT_H) */
|