Subject: Re: [PATCH 2/3] powerpc: Instrument Hypervisor Calls: add wrappers

From: Arnd Bergmann <[email-masked]>
Date: Thu, 15 Jun 2006 13:09:39 +0200

On Thursday 15 June 2006 01:52, Mike Kravetz wrote:
> I'm really wondering what would be the best way to make these stats
> available to userspace. =A0As mentioned, putting them into sysfs would
> violate the one value/one file rule. =A0The use of /proc is discouraged.
> debugfs was mentioned, but I have never used it. =A0Noticed that debugfs
> was enabled in the default config (at least for pseries). =A0Looks like
> that would be the best alternative. =A0Agree?

Debugfs sounds good. If you use one file per hcall, it's probably as
easy as

static u64 hcall_stats_get(void *data)
{
	unsigned long index =3D (unsigned long)data;
	return read_hcall_count(index);
}
DEFINE_SIMPLE_ATTRIBUTE(hcall_fops, hcall_stats_get, NULL, "%llu\n");

void hcall_stats_create(void)
{
	unsigned long i;
	struct dentry *dir;

	dir =3D debugfs_create_dir("hcall_stats", NULL);
	for (i=3D0; i <=3D MAX_HCALL_OPCODES; i++) {
		char name[16];
		sprintf(name, "%d", i << 2);
		debugfs_create_file(name, 0444, dir, (void *)i, &hcall_fops);
	}
}

	Arnd <><