lkml.org 
[lkml]   [2021]   [Nov]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v11 2/2] x86/sgx: Add an attribute for the amount of SGX memory in a NUMA node
From
Date
On Thu, 2021-11-04 at 08:25 +0100, Greg Kroah-Hartman wrote:
> > static const struct attribute_group *node_dev_groups[] = {
> >         &node_dev_group,
> > #ifdef CONFIG_HAVE_ARCH_NODE_DEV_GROUP
> >         &arch_node_dev_group,
> > #endif
> >         NULL,
> > };
>
> Yes, that is true for the dev pointer passed to your callback, but what
> about the dev pointers in this random array you are looping over?

Right. I got what you are saying.

I think the most legit place to mark an entry in this array would be
just *before* device_register() in register_node(). It's different from
hugetlb_register_node() because hugetlb code adds its attribute group
with sysfs_create_group().

Similarly, the legit place to unmark an entry would be in
unregister_node(), right after device_unregister().

After writing this I realized something: the device ID is the same
as NUMA node ID. This means that I can rewrite my callback as

static ssize_t sgx_total_bytes_show(struct device *dev, struct device_attribute *attr, char *buf)
{
unsigned long size = 0;
int nid = dev->id;

return sysfs_emit(buf, "%lu\n", sgx_numa_nodes[dev->id].size);
}

I.e no need to maintain a device pointer.

/Jarkko

\
 
 \ /
  Last update: 2021-11-05 23:15    [W:0.210 / U:0.988 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site