From: "Michael S. Tsirkin" <mst@redhat.com>
To: Max Gurtovoy <mgurtovoy@nvidia.com>
Cc: axboe@kernel.dk, linux-block@vger.kernel.org,
kvm@vger.kernel.org, israelr@nvidia.com,
virtualization@lists.linux-foundation.org, hch@infradead.org,
nitzanc@nvidia.com, stefanha@redhat.com, oren@nvidia.com
Subject: Re: [PATCH 1/2] virtio: introduce virtio_dev_to_node helper
Date: Mon, 27 Sep 2021 05:31:59 -0400 [thread overview]
Message-ID: <20210927053121-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20210926145518.64164-1-mgurtovoy@nvidia.com>
On Sun, Sep 26, 2021 at 05:55:17PM +0300, Max Gurtovoy wrote:
> Also expose numa_node field as a sysfs attribute. Now virtio device
> drivers will be able to allocate memory that is node-local to the
> device. This significantly helps performance and it's oftenly used in
> other drivers such as NVMe, for example.
>
> Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
If you have to respin this, it is better to split this in
two patches, one with the helper one adding a sysfs attribute.
> ---
> drivers/virtio/virtio.c | 10 ++++++++++
> include/linux/virtio.h | 13 +++++++++++++
> 2 files changed, 23 insertions(+)
>
> diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
> index 588e02fb91d3..bdbd76c5c58c 100644
> --- a/drivers/virtio/virtio.c
> +++ b/drivers/virtio/virtio.c
> @@ -60,12 +60,22 @@ static ssize_t features_show(struct device *_d,
> }
> static DEVICE_ATTR_RO(features);
>
> +static ssize_t numa_node_show(struct device *_d,
> + struct device_attribute *attr, char *buf)
> +{
> + struct virtio_device *vdev = dev_to_virtio(_d);
> +
> + return sysfs_emit(buf, "%d\n", virtio_dev_to_node(vdev));
> +}
> +static DEVICE_ATTR_RO(numa_node);
> +
> static struct attribute *virtio_dev_attrs[] = {
> &dev_attr_device.attr,
> &dev_attr_vendor.attr,
> &dev_attr_status.attr,
> &dev_attr_modalias.attr,
> &dev_attr_features.attr,
> + &dev_attr_numa_node.attr,
> NULL,
> };
> ATTRIBUTE_GROUPS(virtio_dev);
> diff --git a/include/linux/virtio.h b/include/linux/virtio.h
> index 41edbc01ffa4..05b586ac71d1 100644
> --- a/include/linux/virtio.h
> +++ b/include/linux/virtio.h
> @@ -125,6 +125,19 @@ static inline struct virtio_device *dev_to_virtio(struct device *_dev)
> return container_of(_dev, struct virtio_device, dev);
> }
>
> +/**
> + * virtio_dev_to_node - return the NUMA node for a given virtio device
> + * @vdev: device to get the NUMA node for.
> + */
> +static inline int virtio_dev_to_node(struct virtio_device *vdev)
> +{
> + struct device *parent = vdev->dev.parent;
> +
> + if (!parent)
> + return NUMA_NO_NODE;
> + return dev_to_node(parent);
> +}
> +
> void virtio_add_status(struct virtio_device *dev, unsigned int status);
> int register_virtio_device(struct virtio_device *dev);
> void unregister_virtio_device(struct virtio_device *dev);
> --
> 2.18.1
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
prev parent reply other threads:[~2021-09-27 9:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210926145518.64164-1-mgurtovoy@nvidia.com>
2021-09-27 8:02 ` [PATCH 1/2] virtio: introduce virtio_dev_to_node helper Stefan Hajnoczi
[not found] ` <20210926145518.64164-2-mgurtovoy@nvidia.com>
2021-09-27 8:09 ` [PATCH 2/2] virtio-blk: set NUMA affinity for a tagset Stefan Hajnoczi
[not found] ` <21295187-41c4-5fb6-21c3-28004eb7c5d8@nvidia.com>
2021-09-28 6:47 ` Stefan Hajnoczi
[not found] ` <f15e1115-25c1-5b9a-223c-db122251d4c1@nvidia.com>
2021-09-30 13:16 ` Stefan Hajnoczi
2021-09-27 11:34 ` Leon Romanovsky
[not found] ` <0c155679-e1db-3d1e-2b4e-a0f12ce5950c@nvidia.com>
2021-09-27 18:23 ` Leon Romanovsky
[not found] ` <f8de7c19-9f04-a458-6c1d-8133a83aa93f@nvidia.com>
2021-09-28 16:27 ` Leon Romanovsky
[not found] ` <f0cc8cb4-92dc-f5f9-ea50-aa312ac6a056@nvidia.com>
2021-09-29 6:50 ` Leon Romanovsky
2021-09-27 9:31 ` Michael S. Tsirkin [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=20210927053121-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=axboe@kernel.dk \
--cc=hch@infradead.org \
--cc=israelr@nvidia.com \
--cc=kvm@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=mgurtovoy@nvidia.com \
--cc=nitzanc@nvidia.com \
--cc=oren@nvidia.com \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux-foundation.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;
as well as URLs for NNTP newsgroup(s).