Re: [PATCH v5 3/3] perf x86: Exposing an Uncore unit to PMON for Intel Xeon® server platform
From: Greg KH
Date: Tue Feb 11 2020 - 12:18:39 EST
On Tue, Feb 11, 2020 at 07:15:49PM +0300, roman.sudarikov@xxxxxxxxxxxxxxx wrote:
> +static struct attribute *uncore_empry_attr;
What is this for?
> +static struct attribute_group skx_iio_mapping_group = {
> + .attrs = &uncore_empry_attr,
Again, what for?
You just overwrite this value so why have it at all?
> + .is_visible = skx_iio_mapping_visible,
> +};
> +
> +const static struct attribute_group *skx_iio_attr_update[] = {
> + &skx_iio_mapping_group,
> + NULL,
> +};
> +
> +static int skx_iio_set_mapping(struct intel_uncore_type *type)
> +{
> + char buf[64];
> + int ret = 0;
> + long die;
> + struct attribute **attrs;
> + struct dev_ext_attribute *eas;
> +
> + ret = skx_iio_get_topology(type);
> + if (ret)
> + return ret;
> +
> + // One more for NULL.
> + attrs = kzalloc((uncore_max_dies() + 1) * sizeof(*attrs), GFP_KERNEL);
> + if (!attrs) {
> + kfree(type->topology);
> + return -ENOMEM;
> + }
> +
> + eas = kzalloc(sizeof(*eas) * uncore_max_dies(), GFP_KERNEL);
> + if (!eas) {
> + kfree(attrs);
> + kfree(type->topology);
> + return -ENOMEM;
> + }
> + for (die = 0; die < uncore_max_dies(); die++) {
> + sprintf(buf, "node%ld", die);
> + eas[die].attr.attr.name = kstrdup(buf, GFP_KERNEL);
> + if (!eas[die].attr.attr.name) {
> + ret = -ENOMEM;
> + goto err;
> + }
> + eas[die].attr.attr.mode = 0444;
> + eas[die].attr.show = skx_iio_mapping_show;
> + eas[die].attr.store = NULL;
> + eas[die].var = (void *)die;
> + attrs[die] = &eas[die].attr.attr;
You HAVE to call sysfs_attr_init() on any dynamically created
attributes. I am guessing you never ran this code with lockdep enabled?
{sigh}
greg k-h