[SRU,B,D,E,1/1] s390/cpumsf: Check for CPU Measurement sampling
diff mbox series

Message ID 1571166368-8078-2-git-send-email-frank.heimes@canonical.com
State New
Headers show
Series
  • Check for CPU Measurement sampling (LP: 1847590)
Related show

Commit Message

Frank Heimes Oct. 15, 2019, 7:06 p.m. UTC
From: Thomas Richter <tmricht@linux.ibm.com>

BugLink: https://bugs.launchpad.net/bugs/1847590

s390 IBM z15 introduces a check if the CPU Mesurement Facility
sampling is temporarily unavailable. If this is the case return -EBUSY
and abort the setup of CPU Measuement facility sampling.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
(cherry picked from commit 932bfc5aae08f3cb20c1c9f051542f5933710151)
Signed-off-by: Frank Heimes <frank.heimes@canonical.com>
---
 arch/s390/include/asm/cpu_mf.h  | 7 +++++--
 arch/s390/kernel/perf_cpum_sf.c | 6 ++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

Comments

Sultan Alsawaf Oct. 15, 2019, 10:16 p.m. UTC | #1
On Tue, Oct 15, 2019 at 09:06:08PM +0200, frank.heimes@canonical.com wrote:
> From: Thomas Richter <tmricht@linux.ibm.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1847590
> 
> s390 IBM z15 introduces a check if the CPU Mesurement Facility
> sampling is temporarily unavailable. If this is the case return -EBUSY
> and abort the setup of CPU Measuement facility sampling.
> 
> Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
> (cherry picked from commit 932bfc5aae08f3cb20c1c9f051542f5933710151)
> Signed-off-by: Frank Heimes <frank.heimes@canonical.com>
> ---
>  arch/s390/include/asm/cpu_mf.h  | 7 +++++--
>  arch/s390/kernel/perf_cpum_sf.c | 6 ++++++
>  2 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/s390/include/asm/cpu_mf.h b/arch/s390/include/asm/cpu_mf.h
> index 4082542..55f9e92 100644
> --- a/arch/s390/include/asm/cpu_mf.h
> +++ b/arch/s390/include/asm/cpu_mf.h
> @@ -26,6 +26,8 @@
>  				 CPU_MF_INT_SF_PRA|CPU_MF_INT_SF_SACA|	\
>  				 CPU_MF_INT_SF_LSDA)
>  
> +#define CPU_MF_SF_RIBM_NOTAV	0x1		/* Sampling unavailable */
> +
>  /* CPU measurement facility support */
>  static inline int cpum_cf_avail(void)
>  {
> @@ -67,8 +69,9 @@ struct hws_qsi_info_block {	    /* Bit(s) */
>  	unsigned long max_sampl_rate; /* 16-23: maximum sampling interval*/
>  	unsigned long tear;	    /* 24-31: TEAR contents		 */
>  	unsigned long dear;	    /* 32-39: DEAR contents		 */
> -	unsigned int rsvrd0;	    /* 40-43: reserved			 */
> -	unsigned int cpu_speed;     /* 44-47: CPU speed 		 */
> +	unsigned int rsvrd0:24;	    /* 40-42: reserved			 */
> +	unsigned int ribm:8;	    /* 43: Reserved by IBM		 */
> +	unsigned int cpu_speed;     /* 44-47: CPU speed			 */
>  	unsigned long long rsvrd1;  /* 48-55: reserved			 */
>  	unsigned long long rsvrd2;  /* 56-63: reserved			 */
>  } __packed;
> diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c
> index 2d55fc2..9cde67e 100644
> --- a/arch/s390/kernel/perf_cpum_sf.c
> +++ b/arch/s390/kernel/perf_cpum_sf.c
> @@ -728,6 +728,12 @@ static int __hw_perf_event_init(struct perf_event *event)
>  		goto out;
>  	}
>  
> +	if (si.ribm & CPU_MF_SF_RIBM_NOTAV) {
> +		pr_warn("CPU Measurement Facility sampling is temporarily not available\n");
> +		err = -EBUSY;
> +		goto out;
> +	}
> +
>  	/* Always enable basic sampling */
>  	SAMPL_FLAGS(hwc) = PERF_CPUM_SF_BASIC_MODE;
>  
> -- 
> 2.7.4
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team

Acked-by: Sultan Alsawaf <sultan.alsawaf@canonical.com>
Khaled Elmously Oct. 16, 2019, 5:29 p.m. UTC | #2
On 2019-10-15 21:06:08 , frank.heimes@canonical.com wrote:
> From: Thomas Richter <tmricht@linux.ibm.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1847590
> 
> s390 IBM z15 introduces a check if the CPU Mesurement Facility
> sampling is temporarily unavailable. If this is the case return -EBUSY
> and abort the setup of CPU Measuement facility sampling.
> 
> Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
> Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
> (cherry picked from commit 932bfc5aae08f3cb20c1c9f051542f5933710151)
> Signed-off-by: Frank Heimes <frank.heimes@canonical.com>
> ---
>  arch/s390/include/asm/cpu_mf.h  | 7 +++++--
>  arch/s390/kernel/perf_cpum_sf.c | 6 ++++++
>  2 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/s390/include/asm/cpu_mf.h b/arch/s390/include/asm/cpu_mf.h
> index 4082542..55f9e92 100644
> --- a/arch/s390/include/asm/cpu_mf.h
> +++ b/arch/s390/include/asm/cpu_mf.h
> @@ -26,6 +26,8 @@
>  				 CPU_MF_INT_SF_PRA|CPU_MF_INT_SF_SACA|	\
>  				 CPU_MF_INT_SF_LSDA)
>  
> +#define CPU_MF_SF_RIBM_NOTAV	0x1		/* Sampling unavailable */
> +
>  /* CPU measurement facility support */
>  static inline int cpum_cf_avail(void)
>  {
> @@ -67,8 +69,9 @@ struct hws_qsi_info_block {	    /* Bit(s) */
>  	unsigned long max_sampl_rate; /* 16-23: maximum sampling interval*/
>  	unsigned long tear;	    /* 24-31: TEAR contents		 */
>  	unsigned long dear;	    /* 32-39: DEAR contents		 */
> -	unsigned int rsvrd0;	    /* 40-43: reserved			 */
> -	unsigned int cpu_speed;     /* 44-47: CPU speed 		 */
> +	unsigned int rsvrd0:24;	    /* 40-42: reserved			 */
> +	unsigned int ribm:8;	    /* 43: Reserved by IBM		 */
> +	unsigned int cpu_speed;     /* 44-47: CPU speed			 */
>  	unsigned long long rsvrd1;  /* 48-55: reserved			 */
>  	unsigned long long rsvrd2;  /* 56-63: reserved			 */
>  } __packed;
> diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c
> index 2d55fc2..9cde67e 100644
> --- a/arch/s390/kernel/perf_cpum_sf.c
> +++ b/arch/s390/kernel/perf_cpum_sf.c
> @@ -728,6 +728,12 @@ static int __hw_perf_event_init(struct perf_event *event)
>  		goto out;
>  	}
>  
> +	if (si.ribm & CPU_MF_SF_RIBM_NOTAV) {
> +		pr_warn("CPU Measurement Facility sampling is temporarily not available\n");
> +		err = -EBUSY;
> +		goto out;
> +	}
> +
>  	/* Always enable basic sampling */
>  	SAMPL_FLAGS(hwc) = PERF_CPUM_SF_BASIC_MODE;
>  
> -- 
> 2.7.4
> 
> 

Acked-by: Khalid Elmously <khalid.elmously@canonical.com>

Patch
diff mbox series

diff --git a/arch/s390/include/asm/cpu_mf.h b/arch/s390/include/asm/cpu_mf.h
index 4082542..55f9e92 100644
--- a/arch/s390/include/asm/cpu_mf.h
+++ b/arch/s390/include/asm/cpu_mf.h
@@ -26,6 +26,8 @@ 
 				 CPU_MF_INT_SF_PRA|CPU_MF_INT_SF_SACA|	\
 				 CPU_MF_INT_SF_LSDA)
 
+#define CPU_MF_SF_RIBM_NOTAV	0x1		/* Sampling unavailable */
+
 /* CPU measurement facility support */
 static inline int cpum_cf_avail(void)
 {
@@ -67,8 +69,9 @@  struct hws_qsi_info_block {	    /* Bit(s) */
 	unsigned long max_sampl_rate; /* 16-23: maximum sampling interval*/
 	unsigned long tear;	    /* 24-31: TEAR contents		 */
 	unsigned long dear;	    /* 32-39: DEAR contents		 */
-	unsigned int rsvrd0;	    /* 40-43: reserved			 */
-	unsigned int cpu_speed;     /* 44-47: CPU speed 		 */
+	unsigned int rsvrd0:24;	    /* 40-42: reserved			 */
+	unsigned int ribm:8;	    /* 43: Reserved by IBM		 */
+	unsigned int cpu_speed;     /* 44-47: CPU speed			 */
 	unsigned long long rsvrd1;  /* 48-55: reserved			 */
 	unsigned long long rsvrd2;  /* 56-63: reserved			 */
 } __packed;
diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c
index 2d55fc2..9cde67e 100644
--- a/arch/s390/kernel/perf_cpum_sf.c
+++ b/arch/s390/kernel/perf_cpum_sf.c
@@ -728,6 +728,12 @@  static int __hw_perf_event_init(struct perf_event *event)
 		goto out;
 	}
 
+	if (si.ribm & CPU_MF_SF_RIBM_NOTAV) {
+		pr_warn("CPU Measurement Facility sampling is temporarily not available\n");
+		err = -EBUSY;
+		goto out;
+	}
+
 	/* Always enable basic sampling */
 	SAMPL_FLAGS(hwc) = PERF_CPUM_SF_BASIC_MODE;