When sysfs is not available (say containers)

Dixit, Ashutosh ashutosh.dixit at intel.com
Fri Jul 19 16:50:04 UTC 2024


On Mon, 17 Jun 2024 18:45:57 -0700, Ashutosh Dixit wrote:
>

Folks,

The below is just an example from one of the earlier OA patches (already
merged):

> [PATCH 05/17] drm/xe/oa/uapi: Add/remove OA config perf ops
>
> +static ssize_t show_dynamic_id(struct kobject *kobj,
> +			       struct kobj_attribute *attr,
> +			       char *buf)
> +{
> +	struct xe_oa_config *oa_config =
> +		container_of(attr, typeof(*oa_config), sysfs_metric_id);
> +
> +	return sysfs_emit(buf, "%d\n", oa_config->id);
> +}
> +
> +static int create_dynamic_oa_sysfs_entry(struct xe_oa *oa,
> +					 struct xe_oa_config *oa_config)
> +{
> +	sysfs_attr_init(&oa_config->sysfs_metric_id.attr);
> +	oa_config->sysfs_metric_id.attr.name = "id";
> +	oa_config->sysfs_metric_id.attr.mode = 0444;
> +	oa_config->sysfs_metric_id.show = show_dynamic_id;
> +	oa_config->sysfs_metric_id.store = NULL;
> +
> +	oa_config->attrs[0] = &oa_config->sysfs_metric_id.attr;
> +	oa_config->attrs[1] = NULL;
> +
> +	oa_config->sysfs_metric.name = oa_config->uuid;
> +	oa_config->sysfs_metric.attrs = oa_config->attrs;
> +
> +	return sysfs_create_group(oa->metrics_kobj, &oa_config->sysfs_metric);
> +}

So we often expose things in sysfs. The question is: are there general
guidelines for what to do for environments (such as containers) where
userspace cannot access sysfs? E.g. in such cases, do we expose the
information exposed in sysfs via queries (i.e. an ioctl)? Or another way?
What have we done in the past in drm and what should we do in these cases
for Xe?

Thanks.
--
Ashutosh


More information about the Intel-xe mailing list