[PATCH 0/3] powerpc: Instrument Hypervisor Calls: add sysfs files

Dave C Boutcher boutcher at cs.umn.edu
Thu Jun 15 00:30:40 EST 2006


On Tue, 13 Jun 2006 20:54:20 -0700, Mike Kravetz <kravetz at us.ibm.com> said:
> 
> Make statistics available via files in sysfs.
> -- 
> Signed-off-by: Mike Kravetz <kravetz at us.ibm.com>
> 
> 
> diff -Naupr linux-2.6.17-rc6/arch/powerpc/kernel/sysfs.c linux-2.6.17-rc6.work/arch/powerpc/kernel/sysfs.c
> --- linux-2.6.17-rc6/arch/powerpc/kernel/sysfs.c	2006-06-06 00:57:02.000000000 +0000
> +++ linux-2.6.17-rc6.work/arch/powerpc/kernel/sysfs.c	2006-06-13 21:42:32.000000000 +0000
> @@ -356,6 +356,39 @@ static ssize_t show_physical_id(struct s
>  }
>  static SYSDEV_ATTR(physical_id, 0444, show_physical_id, NULL);
>  
> +#ifdef CONFIG_HCALL_STATS
> +DECLARE_PER_CPU(struct hcall_stats[MAX_HCALL_OPCODES+1], hcall_stats);
> +
> +static ssize_t show_hcall_stats(struct sys_device *dev, char *buf)
> +{
> +	struct cpu *cpu = container_of(dev, struct cpu, sysdev);
> +	struct hcall_stats *hs = per_cpu(hcall_stats, cpu->sysdev.id);
> +	size_t rc = 0;
> +	size_t b_written = 0;
> +	size_t b_remain = PAGE_SIZE;
> +	unsigned long i;
> +
> +	for (i=0; i<MAX_HCALL_OPCODES+1; i++){
> +		if (!hs[i].num_calls)
> +			continue;
> +
> +		b_written = snprintf(buf+rc, b_remain,
> +				"%lu %lu %lu\n",
> +				i<<2, hs[i].num_calls, hs[i].total_time);
> +
> +		if (b_written >= b_remain)
> +			break;	/* end of buffer */
> +
> +		rc += b_written;
> +		b_remain -= b_written;
> +	}
> +
> +	return rc;
> +}
> +

You're violating the "one value per file" rule for sysfs.  Ware the
wrath of Greg KH.

Dave B



More information about the Linuxppc-dev mailing list