* [Qemu-devel] [PATCH 0/2] virtio-blk: clean up around g_free() and inline a few functions
@ 2017-02-07 13:27 Fam Zheng
2017-02-07 13:27 ` [Qemu-devel] [PATCH 1/2] virtio-blk: Remove useless condition around g_free() Fam Zheng
2017-02-07 13:27 ` [Qemu-devel] [PATCH 2/2] virtio-blk: Inline request init, complete and free functions Fam Zheng
0 siblings, 2 replies; 10+ messages in thread
From: Fam Zheng @ 2017-02-07 13:27 UTC (permalink / raw)
To: qemu-devel; +Cc: Laszlo Ersek, Stefan Hajnoczi, qemu-block
Fam Zheng (2):
virtio-blk: Remove useless condition around g_free()
virtio-blk: Inline request init, complete and free functions
hw/block/virtio-blk.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
--
2.9.3
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 1/2] virtio-blk: Remove useless condition around g_free()
2017-02-07 13:27 [Qemu-devel] [PATCH 0/2] virtio-blk: clean up around g_free() and inline a few functions Fam Zheng
@ 2017-02-07 13:27 ` Fam Zheng
2017-02-07 13:48 ` Laszlo Ersek
` (3 more replies)
2017-02-07 13:27 ` [Qemu-devel] [PATCH 2/2] virtio-blk: Inline request init, complete and free functions Fam Zheng
1 sibling, 4 replies; 10+ messages in thread
From: Fam Zheng @ 2017-02-07 13:27 UTC (permalink / raw)
To: qemu-devel; +Cc: Laszlo Ersek, Stefan Hajnoczi, qemu-block
Laszlo spotted and studied this wasteful "if". He pointed out:
The original virtio_blk_free_request needed an "if" as it accesses one
field, since 671ec3f05655 ("virtio-blk: Convert VirtIOBlockReq.elem to
pointer", 2014-06-11); later on in f897bf751fbd ("virtio-blk: embed
VirtQueueElement in VirtIOBlockReq", 2014-07-09) the field became
embedded, so the "if" became unnecessary (at which point we were using
g_slice_free(), but it is the same.
Now drop it.
Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
---
hw/block/virtio-blk.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 702eda8..2858c31 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -42,9 +42,7 @@ static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
static void virtio_blk_free_request(VirtIOBlockReq *req)
{
- if (req) {
- g_free(req);
- }
+ g_free(req);
}
static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status)
--
2.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [Qemu-devel] [PATCH 2/2] virtio-blk: Inline request init, complete and free functions
2017-02-07 13:27 [Qemu-devel] [PATCH 0/2] virtio-blk: clean up around g_free() and inline a few functions Fam Zheng
2017-02-07 13:27 ` [Qemu-devel] [PATCH 1/2] virtio-blk: Remove useless condition around g_free() Fam Zheng
@ 2017-02-07 13:27 ` Fam Zheng
2017-02-07 13:52 ` Laszlo Ersek
1 sibling, 1 reply; 10+ messages in thread
From: Fam Zheng @ 2017-02-07 13:27 UTC (permalink / raw)
To: qemu-devel; +Cc: Laszlo Ersek, Stefan Hajnoczi, qemu-block
These are used in each request handling, inline them.
Signed-off-by: Fam Zheng <famz@redhat.com>
---
hw/block/virtio-blk.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 2858c31..1da9570 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -29,8 +29,8 @@
#include "hw/virtio/virtio-bus.h"
#include "hw/virtio/virtio-access.h"
-static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
- VirtIOBlockReq *req)
+static inline void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
+ VirtIOBlockReq *req)
{
req->dev = s;
req->vq = vq;
@@ -40,12 +40,13 @@ static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
req->mr_next = NULL;
}
-static void virtio_blk_free_request(VirtIOBlockReq *req)
+static inline void virtio_blk_free_request(VirtIOBlockReq *req)
{
g_free(req);
}
-static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status)
+static inline void virtio_blk_req_complete(VirtIOBlockReq *req,
+ unsigned char status)
{
VirtIOBlock *s = req->dev;
VirtIODevice *vdev = VIRTIO_DEVICE(s);
--
2.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] virtio-blk: Remove useless condition around g_free()
2017-02-07 13:27 ` [Qemu-devel] [PATCH 1/2] virtio-blk: Remove useless condition around g_free() Fam Zheng
@ 2017-02-07 13:48 ` Laszlo Ersek
2017-02-13 14:27 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Laszlo Ersek @ 2017-02-07 13:48 UTC (permalink / raw)
To: Fam Zheng, qemu-devel; +Cc: Stefan Hajnoczi, qemu-block
On 02/07/17 14:27, Fam Zheng wrote:
> Laszlo spotted and studied this wasteful "if". He pointed out:
>
> The original virtio_blk_free_request needed an "if" as it accesses one
> field, since 671ec3f05655 ("virtio-blk: Convert VirtIOBlockReq.elem to
> pointer", 2014-06-11); later on in f897bf751fbd ("virtio-blk: embed
> VirtQueueElement in VirtIOBlockReq", 2014-07-09) the field became
> embedded, so the "if" became unnecessary (at which point we were using
> g_slice_free(), but it is the same.
>
> Now drop it.
>
> Reported-by: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> hw/block/virtio-blk.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> index 702eda8..2858c31 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -42,9 +42,7 @@ static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
>
> static void virtio_blk_free_request(VirtIOBlockReq *req)
> {
> - if (req) {
> - g_free(req);
> - }
> + g_free(req);
> }
>
> static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status)
>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Thanks!
Laszlo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] virtio-blk: Inline request init, complete and free functions
2017-02-07 13:27 ` [Qemu-devel] [PATCH 2/2] virtio-blk: Inline request init, complete and free functions Fam Zheng
@ 2017-02-07 13:52 ` Laszlo Ersek
2017-02-13 14:28 ` Stefan Hajnoczi
0 siblings, 1 reply; 10+ messages in thread
From: Laszlo Ersek @ 2017-02-07 13:52 UTC (permalink / raw)
To: Fam Zheng, qemu-devel; +Cc: Stefan Hajnoczi, qemu-block
On 02/07/17 14:27, Fam Zheng wrote:
> These are used in each request handling, inline them.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> hw/block/virtio-blk.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> index 2858c31..1da9570 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -29,8 +29,8 @@
> #include "hw/virtio/virtio-bus.h"
> #include "hw/virtio/virtio-access.h"
>
> -static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
> - VirtIOBlockReq *req)
> +static inline void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
> + VirtIOBlockReq *req)
> {
> req->dev = s;
> req->vq = vq;
> @@ -40,12 +40,13 @@ static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
> req->mr_next = NULL;
> }
>
> -static void virtio_blk_free_request(VirtIOBlockReq *req)
> +static inline void virtio_blk_free_request(VirtIOBlockReq *req)
> {
> g_free(req);
> }
>
> -static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status)
> +static inline void virtio_blk_req_complete(VirtIOBlockReq *req,
> + unsigned char status)
> {
> VirtIOBlock *s = req->dev;
> VirtIODevice *vdev = VIRTIO_DEVICE(s);
>
Hm, virtio_blk_req_complete() looks a bit too "meaty" and seems to be
called from a little too many places for me to feel convenient about
inlining it. I guess I'd leave it to the compiler to optimize the
function call. Does the explicit hint offer a noticeable perf improvement?
Inlining virtio_blk_free_request() looks reasonable.
virtio_blk_init_request() looks okay too.
Other reviewers should feel free to override my concerns :) My view on
this is distant.
Thanks
Laszlo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [Qemu-block] [PATCH 1/2] virtio-blk: Remove useless condition around g_free()
2017-02-07 13:27 ` [Qemu-devel] [PATCH 1/2] virtio-blk: Remove useless condition around g_free() Fam Zheng
2017-02-07 13:48 ` Laszlo Ersek
@ 2017-02-13 14:27 ` Stefan Hajnoczi
2017-03-07 10:28 ` [Qemu-devel] " Fam Zheng
2017-04-23 17:30 ` Michael Tokarev
3 siblings, 0 replies; 10+ messages in thread
From: Stefan Hajnoczi @ 2017-02-13 14:27 UTC (permalink / raw)
To: Fam Zheng; +Cc: qemu-devel, Laszlo Ersek, qemu-block, Stefan Hajnoczi
[-- Attachment #1: Type: text/plain, Size: 797 bytes --]
On Tue, Feb 07, 2017 at 09:27:22PM +0800, Fam Zheng wrote:
> Laszlo spotted and studied this wasteful "if". He pointed out:
>
> The original virtio_blk_free_request needed an "if" as it accesses one
> field, since 671ec3f05655 ("virtio-blk: Convert VirtIOBlockReq.elem to
> pointer", 2014-06-11); later on in f897bf751fbd ("virtio-blk: embed
> VirtQueueElement in VirtIOBlockReq", 2014-07-09) the field became
> embedded, so the "if" became unnecessary (at which point we were using
> g_slice_free(), but it is the same.
>
> Now drop it.
>
> Reported-by: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> hw/block/virtio-blk.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] virtio-blk: Inline request init, complete and free functions
2017-02-07 13:52 ` Laszlo Ersek
@ 2017-02-13 14:28 ` Stefan Hajnoczi
2017-02-14 0:54 ` Fam Zheng
0 siblings, 1 reply; 10+ messages in thread
From: Stefan Hajnoczi @ 2017-02-13 14:28 UTC (permalink / raw)
To: Laszlo Ersek; +Cc: Fam Zheng, qemu-devel, qemu-block, Stefan Hajnoczi
[-- Attachment #1: Type: text/plain, Size: 2231 bytes --]
On Tue, Feb 07, 2017 at 02:52:38PM +0100, Laszlo Ersek wrote:
> On 02/07/17 14:27, Fam Zheng wrote:
> > These are used in each request handling, inline them.
> >
> > Signed-off-by: Fam Zheng <famz@redhat.com>
> > ---
> > hw/block/virtio-blk.c | 9 +++++----
> > 1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> > index 2858c31..1da9570 100644
> > --- a/hw/block/virtio-blk.c
> > +++ b/hw/block/virtio-blk.c
> > @@ -29,8 +29,8 @@
> > #include "hw/virtio/virtio-bus.h"
> > #include "hw/virtio/virtio-access.h"
> >
> > -static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
> > - VirtIOBlockReq *req)
> > +static inline void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
> > + VirtIOBlockReq *req)
> > {
> > req->dev = s;
> > req->vq = vq;
> > @@ -40,12 +40,13 @@ static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
> > req->mr_next = NULL;
> > }
> >
> > -static void virtio_blk_free_request(VirtIOBlockReq *req)
> > +static inline void virtio_blk_free_request(VirtIOBlockReq *req)
> > {
> > g_free(req);
> > }
> >
> > -static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status)
> > +static inline void virtio_blk_req_complete(VirtIOBlockReq *req,
> > + unsigned char status)
> > {
> > VirtIOBlock *s = req->dev;
> > VirtIODevice *vdev = VIRTIO_DEVICE(s);
> >
>
> Hm, virtio_blk_req_complete() looks a bit too "meaty" and seems to be
> called from a little too many places for me to feel convenient about
> inlining it. I guess I'd leave it to the compiler to optimize the
> function call. Does the explicit hint offer a noticeable perf improvement?
>
> Inlining virtio_blk_free_request() looks reasonable.
>
> virtio_blk_init_request() looks okay too.
>
> Other reviewers should feel free to override my concerns :) My view on
> this is distant.
I'm not a big fan of manually inlining functions. Let the compiler
decide whether these static functions should be inlined.
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] virtio-blk: Inline request init, complete and free functions
2017-02-13 14:28 ` Stefan Hajnoczi
@ 2017-02-14 0:54 ` Fam Zheng
0 siblings, 0 replies; 10+ messages in thread
From: Fam Zheng @ 2017-02-14 0:54 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: Laszlo Ersek, Stefan Hajnoczi, qemu-devel, qemu-block
On Mon, 02/13 14:28, Stefan Hajnoczi wrote:
> On Tue, Feb 07, 2017 at 02:52:38PM +0100, Laszlo Ersek wrote:
> > On 02/07/17 14:27, Fam Zheng wrote:
> > > These are used in each request handling, inline them.
> > >
> > > Signed-off-by: Fam Zheng <famz@redhat.com>
> > > ---
> > > hw/block/virtio-blk.c | 9 +++++----
> > > 1 file changed, 5 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> > > index 2858c31..1da9570 100644
> > > --- a/hw/block/virtio-blk.c
> > > +++ b/hw/block/virtio-blk.c
> > > @@ -29,8 +29,8 @@
> > > #include "hw/virtio/virtio-bus.h"
> > > #include "hw/virtio/virtio-access.h"
> > >
> > > -static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
> > > - VirtIOBlockReq *req)
> > > +static inline void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
> > > + VirtIOBlockReq *req)
> > > {
> > > req->dev = s;
> > > req->vq = vq;
> > > @@ -40,12 +40,13 @@ static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
> > > req->mr_next = NULL;
> > > }
> > >
> > > -static void virtio_blk_free_request(VirtIOBlockReq *req)
> > > +static inline void virtio_blk_free_request(VirtIOBlockReq *req)
> > > {
> > > g_free(req);
> > > }
> > >
> > > -static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status)
> > > +static inline void virtio_blk_req_complete(VirtIOBlockReq *req,
> > > + unsigned char status)
> > > {
> > > VirtIOBlock *s = req->dev;
> > > VirtIODevice *vdev = VIRTIO_DEVICE(s);
> > >
> >
> > Hm, virtio_blk_req_complete() looks a bit too "meaty" and seems to be
> > called from a little too many places for me to feel convenient about
> > inlining it. I guess I'd leave it to the compiler to optimize the
> > function call. Does the explicit hint offer a noticeable perf improvement?
> >
> > Inlining virtio_blk_free_request() looks reasonable.
> >
> > virtio_blk_init_request() looks okay too.
> >
> > Other reviewers should feel free to override my concerns :) My view on
> > this is distant.
>
> I'm not a big fan of manually inlining functions. Let the compiler
> decide whether these static functions should be inlined.
>
Fair enough, let's drop this one.
Fam
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] virtio-blk: Remove useless condition around g_free()
2017-02-07 13:27 ` [Qemu-devel] [PATCH 1/2] virtio-blk: Remove useless condition around g_free() Fam Zheng
2017-02-07 13:48 ` Laszlo Ersek
2017-02-13 14:27 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
@ 2017-03-07 10:28 ` Fam Zheng
2017-04-23 17:30 ` Michael Tokarev
3 siblings, 0 replies; 10+ messages in thread
From: Fam Zheng @ 2017-03-07 10:28 UTC (permalink / raw)
To: qemu-devel, qemu-trivial; +Cc: Laszlo Ersek, qemu-block, Stefan Hajnoczi
On Tue, 02/07 21:27, Fam Zheng wrote:
> Laszlo spotted and studied this wasteful "if". He pointed out:
>
> The original virtio_blk_free_request needed an "if" as it accesses one
> field, since 671ec3f05655 ("virtio-blk: Convert VirtIOBlockReq.elem to
> pointer", 2014-06-11); later on in f897bf751fbd ("virtio-blk: embed
> VirtQueueElement in VirtIOBlockReq", 2014-07-09) the field became
> embedded, so the "if" became unnecessary (at which point we were using
> g_slice_free(), but it is the same.
>
> Now drop it.
>
> Reported-by: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> hw/block/virtio-blk.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> index 702eda8..2858c31 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -42,9 +42,7 @@ static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq,
>
> static void virtio_blk_free_request(VirtIOBlockReq *req)
> {
> - if (req) {
> - g_free(req);
> - }
> + g_free(req);
> }
>
> static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status)
> --
> 2.9.3
>
>
Cc: qemu-trivial@nongnu.org
(Let's drop 2/2 and perhaps merge this via trivial)
Fam
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] virtio-blk: Remove useless condition around g_free()
2017-02-07 13:27 ` [Qemu-devel] [PATCH 1/2] virtio-blk: Remove useless condition around g_free() Fam Zheng
` (2 preceding siblings ...)
2017-03-07 10:28 ` [Qemu-devel] " Fam Zheng
@ 2017-04-23 17:30 ` Michael Tokarev
3 siblings, 0 replies; 10+ messages in thread
From: Michael Tokarev @ 2017-04-23 17:30 UTC (permalink / raw)
To: Fam Zheng, qemu-devel
Cc: Laszlo Ersek, qemu-block, Stefan Hajnoczi, QEMU Trivial
07.02.2017 16:27, Fam Zheng wrote:
> Laszlo spotted and studied this wasteful "if". He pointed out:
>
> The original virtio_blk_free_request needed an "if" as it accesses one
> field, since 671ec3f05655 ("virtio-blk: Convert VirtIOBlockReq.elem to
> pointer", 2014-06-11); later on in f897bf751fbd ("virtio-blk: embed
> VirtQueueElement in VirtIOBlockReq", 2014-07-09) the field became
> embedded, so the "if" became unnecessary (at which point we were using
> g_slice_free(), but it is the same.
>
> Now drop it.
Applied to -trivial, thanks!
/mjt
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-04-23 17:30 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-07 13:27 [Qemu-devel] [PATCH 0/2] virtio-blk: clean up around g_free() and inline a few functions Fam Zheng
2017-02-07 13:27 ` [Qemu-devel] [PATCH 1/2] virtio-blk: Remove useless condition around g_free() Fam Zheng
2017-02-07 13:48 ` Laszlo Ersek
2017-02-13 14:27 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-03-07 10:28 ` [Qemu-devel] " Fam Zheng
2017-04-23 17:30 ` Michael Tokarev
2017-02-07 13:27 ` [Qemu-devel] [PATCH 2/2] virtio-blk: Inline request init, complete and free functions Fam Zheng
2017-02-07 13:52 ` Laszlo Ersek
2017-02-13 14:28 ` Stefan Hajnoczi
2017-02-14 0:54 ` Fam Zheng
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.