From: "Michael S. Tsirkin" <mst@redhat.com>
To: Max Gurtovoy <mgurtovoy@nvidia.com>
Cc: virtualization@lists.linux-foundation.org, kvm@vger.kernel.org,
stefanha@redhat.com, oren@nvidia.com, nitzanc@nvidia.com,
israelr@nvidia.com, hch@infradead.org,
linux-block@vger.kernel.org, axboe@kernel.dk
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
next prev parent reply other threads:[~2021-09-27 9:32 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-26 14:55 [PATCH 1/2] virtio: introduce virtio_dev_to_node helper Max Gurtovoy
2021-09-26 14:55 ` [PATCH 2/2] virtio-blk: set NUMA affinity for a tagset Max Gurtovoy
2021-09-27 8:09 ` Stefan Hajnoczi
2021-09-27 17:39 ` Max Gurtovoy
2021-09-28 6:47 ` Stefan Hajnoczi
2021-09-29 15:07 ` Max Gurtovoy
2021-09-30 13:16 ` Stefan Hajnoczi
2021-09-30 13:24 ` Max Gurtovoy
2021-09-27 11:34 ` Leon Romanovsky
2021-09-27 17:25 ` Max Gurtovoy
2021-09-27 18:23 ` Leon Romanovsky
2021-09-28 15:59 ` Max Gurtovoy
2021-09-28 16:27 ` Leon Romanovsky
2021-09-28 23:28 ` Max Gurtovoy
2021-09-29 6:50 ` Leon Romanovsky
2021-09-29 9:48 ` Max Gurtovoy
2021-09-27 8:02 ` [PATCH 1/2] virtio: introduce virtio_dev_to_node helper Stefan Hajnoczi
2021-09-27 9:31 ` Michael S. Tsirkin [this message]
2021-09-28 16:14 ` Max Gurtovoy
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).