[PATCH] ppc64: Fix oprofile when compiled as a module

Kumar Gala galak at kernel.crashing.org
Sat Dec 31 02:49:18 EST 2005


Anton,

Common on, if you are going to "fix" things dont break ppc32 :)

Anyways, can you extend your patch to cover the op_model_7450 &  
op_model_fsl_booke which are now in the powerpc.git tree.

- kumar

On Dec 29, 2005, at 4:51 AM, Anton Blanchard wrote:

>
> My recent changes to oprofile broke it when built as a module. Fix  
> it by
> using an enum instead of a function pointer. This way we still retain
> the oprofile configuration in the cputable.
>
> Signed-off-by: Anton Blanchard <anton at samba.org>
> ---
>
> Index: build/arch/powerpc/kernel/cputable.c
> ===================================================================
> --- build.orig/arch/powerpc/kernel/cputable.c	2005-12-29  
> 20:50:47.000000000 +1100
> +++ build/arch/powerpc/kernel/cputable.c	2005-12-29  
> 20:53:49.000000000 +1100
> @@ -78,10 +78,8 @@
>  		.dcache_bsize		= 128,
>  		.num_pmcs		= 8,
>  		.cpu_setup		= __setup_cpu_power3,
> -#ifdef CONFIG_OPROFILE
>  		.oprofile_cpu_type	= "ppc64/power3",
> -		.oprofile_model		= &op_model_rs64,
> -#endif
> +		.oprofile_type		= RS64,
>  	},
>  	{	/* Power3+ */
>  		.pvr_mask		= 0xffff0000,
> @@ -93,10 +91,8 @@
>  		.dcache_bsize		= 128,
>  		.num_pmcs		= 8,
>  		.cpu_setup		= __setup_cpu_power3,
> -#ifdef CONFIG_OPROFILE
>  		.oprofile_cpu_type	= "ppc64/power3",
> -		.oprofile_model		= &op_model_rs64,
> -#endif
> +		.oprofile_type		= RS64,
>  	},
>  	{	/* Northstar */
>  		.pvr_mask		= 0xffff0000,
> @@ -108,10 +104,8 @@
>  		.dcache_bsize		= 128,
>  		.num_pmcs		= 8,
>  		.cpu_setup		= __setup_cpu_power3,
> -#ifdef CONFIG_OPROFILE
>  		.oprofile_cpu_type	= "ppc64/rs64",
> -		.oprofile_model		= &op_model_rs64,
> -#endif
> +		.oprofile_type		= RS64,
>  	},
>  	{	/* Pulsar */
>  		.pvr_mask		= 0xffff0000,
> @@ -123,10 +117,8 @@
>  		.dcache_bsize		= 128,
>  		.num_pmcs		= 8,
>  		.cpu_setup		= __setup_cpu_power3,
> -#ifdef CONFIG_OPROFILE
>  		.oprofile_cpu_type	= "ppc64/rs64",
> -		.oprofile_model		= &op_model_rs64,
> -#endif
> +		.oprofile_type		= RS64,
>  	},
>  	{	/* I-star */
>  		.pvr_mask		= 0xffff0000,
> @@ -138,10 +130,8 @@
>  		.dcache_bsize		= 128,
>  		.num_pmcs		= 8,
>  		.cpu_setup		= __setup_cpu_power3,
> -#ifdef CONFIG_OPROFILE
>  		.oprofile_cpu_type	= "ppc64/rs64",
> -		.oprofile_model		= &op_model_rs64,
> -#endif
> +		.oprofile_type		= RS64,
>  	},
>  	{	/* S-star */
>  		.pvr_mask		= 0xffff0000,
> @@ -153,10 +143,8 @@
>  		.dcache_bsize		= 128,
>  		.num_pmcs		= 8,
>  		.cpu_setup		= __setup_cpu_power3,
> -#ifdef CONFIG_OPROFILE
>  		.oprofile_cpu_type	= "ppc64/rs64",
> -		.oprofile_model		= &op_model_rs64,
> -#endif
> +		.oprofile_type		= RS64,
>  	},
>  	{	/* Power4 */
>  		.pvr_mask		= 0xffff0000,
> @@ -168,10 +156,8 @@
>  		.dcache_bsize		= 128,
>  		.num_pmcs		= 8,
>  		.cpu_setup		= __setup_cpu_power4,
> -#ifdef CONFIG_OPROFILE
>  		.oprofile_cpu_type	= "ppc64/power4",
> -		.oprofile_model		= &op_model_rs64,
> -#endif
> +		.oprofile_type		= POWER4,
>  	},
>  	{	/* Power4+ */
>  		.pvr_mask		= 0xffff0000,
> @@ -183,10 +169,8 @@
>  		.dcache_bsize		= 128,
>  		.num_pmcs		= 8,
>  		.cpu_setup		= __setup_cpu_power4,
> -#ifdef CONFIG_OPROFILE
>  		.oprofile_cpu_type	= "ppc64/power4",
> -		.oprofile_model		= &op_model_power4,
> -#endif
> +		.oprofile_type		= POWER4,
>  	},
>  	{	/* PPC970 */
>  		.pvr_mask		= 0xffff0000,
> @@ -199,10 +183,8 @@
>  		.dcache_bsize		= 128,
>  		.num_pmcs		= 8,
>  		.cpu_setup		= __setup_cpu_ppc970,
> -#ifdef CONFIG_OPROFILE
>  		.oprofile_cpu_type	= "ppc64/970",
> -		.oprofile_model		= &op_model_power4,
> -#endif
> +		.oprofile_type		= POWER4,
>  	},
>  #endif /* CONFIG_PPC64 */
>  #if defined(CONFIG_PPC64) || defined(CONFIG_POWER4)
> @@ -221,10 +203,8 @@
>  		.dcache_bsize		= 128,
>  		.num_pmcs		= 8,
>  		.cpu_setup		= __setup_cpu_ppc970,
> -#ifdef CONFIG_OPROFILE
>  		.oprofile_cpu_type	= "ppc64/970",
> -		.oprofile_model		= &op_model_power4,
> -#endif
> +		.oprofile_type		= POWER4,
>  	},
>  #endif /* defined(CONFIG_PPC64) || defined(CONFIG_POWER4) */
>  #ifdef CONFIG_PPC64
> @@ -238,10 +218,8 @@
>  		.icache_bsize		= 128,
>  		.dcache_bsize		= 128,
>  		.cpu_setup		= __setup_cpu_ppc970,
> -#ifdef CONFIG_OPROFILE
>  		.oprofile_cpu_type	= "ppc64/970",
> -		.oprofile_model		= &op_model_power4,
> -#endif
> +		.oprofile_type		= POWER4,
>  	},
>  	{	/* Power5 GR */
>  		.pvr_mask		= 0xffff0000,
> @@ -253,10 +231,8 @@
>  		.dcache_bsize		= 128,
>  		.num_pmcs		= 6,
>  		.cpu_setup		= __setup_cpu_power4,
> -#ifdef CONFIG_OPROFILE
>  		.oprofile_cpu_type	= "ppc64/power5",
> -		.oprofile_model		= &op_model_power4,
> -#endif
> +		.oprofile_type		= POWER4,
>  	},
>  	{	/* Power5 GS */
>  		.pvr_mask		= 0xffff0000,
> @@ -268,10 +244,8 @@
>  		.dcache_bsize		= 128,
>  		.num_pmcs		= 6,
>  		.cpu_setup		= __setup_cpu_power4,
> -#ifdef CONFIG_OPROFILE
>  		.oprofile_cpu_type	= "ppc64/power5",
> -		.oprofile_model		= &op_model_power4,
> -#endif
> +		.oprofile_type		= POWER4,
>  	},
>  	{	/* BE DD1.x */
>  		.pvr_mask		= 0xffff0000,
> Index: build/arch/powerpc/oprofile/common.c
> ===================================================================
> --- build.orig/arch/powerpc/oprofile/common.c	2005-12-29  
> 20:50:47.000000000 +1100
> +++ build/arch/powerpc/oprofile/common.c	2005-12-29  
> 20:53:49.000000000 +1100
> @@ -167,9 +167,20 @@
>
>  	ops->cpu_type = cpu_type;
>  #else /* __powerpc64__ */
> -	if (!cur_cpu_spec->oprofile_model || !cur_cpu_spec- 
> >oprofile_cpu_type)
> +	if (!cur_cpu_spec->oprofile_cpu_type)
>  		return -ENODEV;
> -	model = cur_cpu_spec->oprofile_model;
> +
> +	switch (cur_cpu_spec->oprofile_type) {
> +		case RS64:
> +			model = &op_model_rs64;
> +			break;
> +		case POWER4:
> +			model = &op_model_power4;
> +			break;
> +		default:
> +			return -ENODEV;
> +	}
> +
>  	model->num_counters = cur_cpu_spec->num_pmcs;
>
>  	ops->cpu_type = cur_cpu_spec->oprofile_cpu_type;
> Index: build/include/asm-powerpc/cputable.h
> ===================================================================
> --- build.orig/include/asm-powerpc/cputable.h	2005-12-29  
> 20:50:47.000000000 +1100
> +++ build/include/asm-powerpc/cputable.h	2005-12-29  
> 21:33:01.000000000 +1100
> @@ -28,10 +28,15 @@
>   * via the mkdefs mechanism.
>   */
>  struct cpu_spec;
> -struct op_powerpc_model;
>
>  typedef	void (*cpu_setup_t)(unsigned long offset, struct cpu_spec*  
> spec);
>
> +enum powerpc_oprofile_type {
> +	INVALID = 0,
> +	RS64 = 1,
> +	POWER4 = 2,
> +};
> +
>  struct cpu_spec {
>  	/* CPU is matched via (PVR & pvr_mask) == pvr_value */
>  	unsigned int	pvr_mask;
> @@ -57,7 +62,7 @@
>  	char		*oprofile_cpu_type;
>
>  	/* Processor specific oprofile operations */
> -	struct op_powerpc_model *oprofile_model;
> +	enum powerpc_oprofile_type oprofile_type;
>  };
>
>  extern struct cpu_spec		*cur_cpu_spec;
> _______________________________________________
> Linuxppc64-dev mailing list
> Linuxppc64-dev at ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc64-dev




More information about the Linuxppc64-dev mailing list