Re: [PATCH RFC/RFT v2 1/8] drivers: base: support cpu cache informationinterface to userspace via sysfs

From: Sudeep Holla
Date: Mon Feb 10 2014 - 13:09:51 EST


On 07/02/14 19:29, Greg Kroah-Hartman wrote:
> On Fri, Feb 07, 2014 at 04:49:16PM +0000, Sudeep Holla wrote:
>> From: Sudeep Holla <sudeep.holla@xxxxxxx>
>>
>> This patch adds initial support for providing processor cache information
>> to userspace through sysfs interface. This is based on already existing
>> implementations(x86, ia64, s390 and powerpc) and hence the interface is
>> intended to be fully compatible.
>>
>> The main purpose of this generic support is to avoid further code
>> duplication to support new architectures and also to unify all the existing
>> different implementations.
>>
>> This implementation maintains the hierarchy of cache objects which reflects
>> the system's cache topology. Cache objects are instantiated as needed as
>> CPUs come online. The cache objects are replicated per-cpu even if they are
>> shared. A per-cpu array of cache information maintained is used mainly for
>> sysfs-related book keeping.
>
> I thought I asked that you not use "raw" kobjects for this, instead
> using 'struct device' or just an attribute group?
>

Correct, sorry I should have mentioned here instead of cover letter that it's
not yet done. Since the changes involved other architectures, I posted v2 to get
early feedback and testing. More over it's one place to fix now instead of 4
unlike before.

Just adding cache as a device as you suggested won't suffice here. As we need to
track multiple cache indices for each cpu, devices are needed for each cache
index. I tried using device_create_with_groups which provides all we need in one
api for cache indices but since cpu devices are not associated with any class,
it fails if class is NULL. Any suggestions ?

--->8(something like this)
struct device *dev = get_cpu_device(cpu);
struct device *cache_dev =
device_create(dev->class, dev, 0, NULL, "cache");

/* then for each cache call index device_create_with_groups */

> Using a kobject means that userspace tools that use libudev have no
> chance to see these attributes at all, which is not good, right?
>

Yes I understand that, I am looking at fixing it. Looks like none of the current
implementations cares about uevent notifications :(

Regards,
Sudeep

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/