Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cd3b70f5 authored by Carsten Otte's avatar Carsten Otte Committed by Martin Schwidefsky
Browse files

[S390] virtualization aware cpu measurement



Use the SPP instruction to set a tag on entry to / exit of the virtual
machine context. This allows the cpu measurement facility to distinguish
the samples from the host and the different guests.

Signed-off-by: default avatarCarsten Otte <cotte@de.ibm.com>
parent 6377981f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -267,7 +267,8 @@ struct _lowcore {
	__u64	vdso_per_cpu_data;		/* 0x0358 */
	__u64	machine_flags;			/* 0x0360 */
	__u64	ftrace_func;			/* 0x0368 */
	__u8	pad_0x0370[0x0380-0x0370];	/* 0x0370 */
	__u64	sie_hook;			/* 0x0370 */
	__u64	cmf_hpp;			/* 0x0378 */

	/* Interrupt response block. */
	__u8	irb[64];			/* 0x0380 */
+4 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
 *  include/asm-s390/setup.h
 *
 *  S390 version
 *    Copyright IBM Corp. 1999,2006
 *    Copyright IBM Corp. 1999,2010
 */

#ifndef _ASM_S390_SETUP_H
@@ -72,6 +72,7 @@ extern unsigned int user_mode;
#define MACHINE_FLAG_HPAGE	(1UL << 10)
#define MACHINE_FLAG_PFMF	(1UL << 11)
#define MACHINE_FLAG_LPAR	(1UL << 12)
#define MACHINE_FLAG_SPP	(1UL << 13)

#define MACHINE_IS_VM		(S390_lowcore.machine_flags & MACHINE_FLAG_VM)
#define MACHINE_IS_KVM		(S390_lowcore.machine_flags & MACHINE_FLAG_KVM)
@@ -88,6 +89,7 @@ extern unsigned int user_mode;
#define MACHINE_HAS_MVCOS	(0)
#define MACHINE_HAS_HPAGE	(0)
#define MACHINE_HAS_PFMF	(0)
#define MACHINE_HAS_SPP		(0)
#else /* __s390x__ */
#define MACHINE_HAS_IEEE	(1)
#define MACHINE_HAS_CSP		(1)
@@ -97,6 +99,7 @@ extern unsigned int user_mode;
#define MACHINE_HAS_MVCOS	(S390_lowcore.machine_flags & MACHINE_FLAG_MVCOS)
#define MACHINE_HAS_HPAGE	(S390_lowcore.machine_flags & MACHINE_FLAG_HPAGE)
#define MACHINE_HAS_PFMF	(S390_lowcore.machine_flags & MACHINE_FLAG_PFMF)
#define MACHINE_HAS_SPP		(S390_lowcore.machine_flags & MACHINE_FLAG_SPP)
#endif /* __s390x__ */

#define ZFCPDUMP_HSA_SIZE	(32UL<<20)
+2 −0
Original line number Diff line number Diff line
@@ -131,6 +131,8 @@ int main(void)
	DEFINE(__LC_MCCK_CLOCK, offsetof(struct _lowcore, mcck_clock));
	DEFINE(__LC_MACHINE_FLAGS, offsetof(struct _lowcore, machine_flags));
	DEFINE(__LC_FTRACE_FUNC, offsetof(struct _lowcore, ftrace_func));
	DEFINE(__LC_SIE_HOOK, offsetof(struct _lowcore, sie_hook));
	DEFINE(__LC_CMF_HPP, offsetof(struct _lowcore, cmf_hpp));
	DEFINE(__LC_IRB, offsetof(struct _lowcore, irb));
	DEFINE(__LC_CPU_TIMER_SAVE_AREA, offsetof(struct _lowcore, cpu_timer_save_area));
	DEFINE(__LC_CLOCK_COMP_SAVE_AREA, offsetof(struct _lowcore, clock_comp_save_area));
+4 −0
Original line number Diff line number Diff line
@@ -356,6 +356,7 @@ static __init void detect_machine_facilities(void)
{
#ifdef CONFIG_64BIT
	unsigned int facilities;
	unsigned long long facility_bits;

	facilities = stfl();
	if (facilities & (1 << 28))
@@ -364,6 +365,9 @@ static __init void detect_machine_facilities(void)
		S390_lowcore.machine_flags |= MACHINE_FLAG_PFMF;
	if (facilities & (1 << 4))
		S390_lowcore.machine_flags |= MACHINE_FLAG_MVCOS;
	if ((stfle(&facility_bits, 1) > 0) &&
	    (facility_bits & (1ULL << (63 - 40))))
		S390_lowcore.machine_flags |= MACHINE_FLAG_SPP;
#endif
}

+16 −10
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
 *  arch/s390/kernel/entry64.S
 *    S390 low-level entry points.
 *
 *    Copyright (C) IBM Corp. 1999,2006
 *    Copyright (C) IBM Corp. 1999,2010
 *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
 *		 Hartmut Penner (hp@de.ibm.com),
 *		 Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
@@ -59,6 +59,16 @@ _TIF_SYSCALL = (_TIF_SYSCALL_TRACE>>8 | _TIF_SYSCALL_AUDIT>>8 | \

#define BASED(name) name-system_call(%r13)

	.macro	HANDLE_SIE_INTERCEPT
#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
	lg	%r3,__LC_SIE_HOOK
	ltgr	%r3,%r3
	jz	0f
	basr	%r14,%r3
	0:
#endif
	.endm

#ifdef CONFIG_TRACE_IRQFLAGS
	.macro	TRACE_IRQS_ON
	basr	%r2,%r0
@@ -466,6 +476,7 @@ pgm_check_handler:
	UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
	mvc	__LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
pgm_no_vtime:
	HANDLE_SIE_INTERCEPT
	TRACE_IRQS_CHECK_OFF
	lg	%r9,__LC_THREAD_INFO	# load pointer to thread_info struct
	mvc	SP_ARGS(8,%r15),__LC_LAST_BREAK
@@ -507,6 +518,7 @@ pgm_per_std:
	UPDATE_VTIME __LC_LAST_UPDATE_TIMER,__LC_EXIT_TIMER,__LC_SYSTEM_TIMER
	mvc	__LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER
pgm_no_vtime2:
	HANDLE_SIE_INTERCEPT
	TRACE_IRQS_CHECK_OFF
	lg	%r9,__LC_THREAD_INFO	# load pointer to thread_info struct
	lg	%r1,__TI_task(%r9)
@@ -570,6 +582,7 @@ io_int_handler:
	mvc	__LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
io_no_vtime:
	lg	%r9,__LC_THREAD_INFO	# load pointer to thread_info struct
	HANDLE_SIE_INTERCEPT
	TRACE_IRQS_OFF
	la	%r2,SP_PTREGS(%r15)	# address of register-save area
	brasl	%r14,do_IRQ		# call standard irq handler
@@ -595,15 +608,6 @@ io_done:
io_work:
	tm	SP_PSW+1(%r15),0x01	# returning to user ?
	jo	io_work_user		# yes -> do resched & signal
#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
	lg	%r2,SP_PSW+8(%r15)	# check if current instruction is SIE
	lh	%r1,0(%r2)
	chi	%r1,-19948		# signed 16 bit compare with 0xb214
	jne	0f			# no -> leave PSW alone
	aghi	%r2,4			# yes-> add 4 bytes to leave SIE
	stg	%r2,SP_PSW+8(%r15)
0:
#endif
#ifdef CONFIG_PREEMPT
	# check for preemptive scheduling
	icm	%r0,15,__TI_precount(%r9)
@@ -712,6 +716,7 @@ ext_int_handler:
	mvc	__LC_LAST_UPDATE_TIMER(8),__LC_ASYNC_ENTER_TIMER
ext_no_vtime:
	lg	%r9,__LC_THREAD_INFO	# load pointer to thread_info struct
	HANDLE_SIE_INTERCEPT
	TRACE_IRQS_OFF
	la	%r2,SP_PTREGS(%r15)	# address of register-save area
	llgh	%r3,__LC_EXT_INT_CODE	# get interruption code
@@ -786,6 +791,7 @@ mcck_no_vtime:
	stosm	__SF_EMPTY(%r15),0x04	# turn dat on
	tm	__TI_flags+7(%r9),_TIF_MCCK_PENDING
	jno	mcck_return
	HANDLE_SIE_INTERCEPT
	TRACE_IRQS_OFF
	brasl	%r14,s390_handle_mcck
	TRACE_IRQS_ON
Loading