From: Jarkko Sakkinen <jarkko@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
reinette.chatre@intel.com, tony.luck@intel.com,
nathaniel@profian.com, linux-kernel@vger.kernel.org,
linux-sgx@vger.kernel.org
Subject: Re: [PATCH v11 2/2] x86/sgx: Add an attribute for the amount of SGX memory in a NUMA node
Date: Sat, 06 Nov 2021 00:14:34 +0200 [thread overview]
Message-ID: <6655423a30c3ef695516b08fa409bf52d5db5fbc.camel@kernel.org> (raw)
In-Reply-To: <YYOK+7OREGsSDhEG@kroah.com>
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
prev parent reply other threads:[~2021-11-05 22:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-03 1:28 [PATCH v11 1/2] x86/sgx: Rename fallback labels in sgx_init() Jarkko Sakkinen
2021-11-03 1:28 ` [PATCH v11 2/2] x86/sgx: Add an attribute for the amount of SGX memory in a NUMA node Jarkko Sakkinen
2021-11-03 8:22 ` Greg Kroah-Hartman
2021-11-03 21:49 ` Jarkko Sakkinen
2021-11-03 21:54 ` Jarkko Sakkinen
2021-11-04 7:25 ` Greg Kroah-Hartman
2021-11-05 22:14 ` Jarkko Sakkinen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6655423a30c3ef695516b08fa409bf52d5db5fbc.camel@kernel.org \
--to=jarkko@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sgx@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nathaniel@profian.com \
--cc=rafael@kernel.org \
--cc=reinette.chatre@intel.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox