diff mbox

[v2,1/3] xenfb: use the correct condition to avoid excessive looping

Message ID 1460457796-1779-2-git-send-email-wei.liu2@citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Liu April 12, 2016, 10:43 a.m. UTC
In commit ac0487e1 ("xenfb.c: avoid expensive loops when prod <=
out_cons"), ">=" was used. In fact, a full ring is a legit state.
Correct the test to use ">".

Reported-by: "Hao, Xudong" <xudong.hao@intel.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: "Hao, Xudong" <xudong.hao@intel.com>
Acked-by: Anthony Perard <anthony.perard@citrix.com>
---
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>

Backport candidate to our own tree.
---
 hw/display/xenfb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefano Stabellini April 12, 2016, 5:12 p.m. UTC | #1
On Tue, 12 Apr 2016, Wei Liu wrote:
> In commit ac0487e1 ("xenfb.c: avoid expensive loops when prod <=
> out_cons"), ">=" was used. In fact, a full ring is a legit state.
> Correct the test to use ">".
> 
> Reported-by: "Hao, Xudong" <xudong.hao@intel.com>
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> Tested-by: "Hao, Xudong" <xudong.hao@intel.com>
> Acked-by: Anthony Perard <anthony.perard@citrix.com>

Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

I'll add it to my queue


> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Anthony Perard <anthony.perard@citrix.com>
> 
> Backport candidate to our own tree.
> ---
>  hw/display/xenfb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c
> index 40b096a..9866dfd 100644
> --- a/hw/display/xenfb.c
> +++ b/hw/display/xenfb.c
> @@ -775,7 +775,7 @@ static void xenfb_handle_events(struct XenFB *xenfb)
>  
>      prod = page->out_prod;
>      out_cons = page->out_cons;
> -    if (prod - out_cons >= XENFB_OUT_RING_LEN) {
> +    if (prod - out_cons > XENFB_OUT_RING_LEN) {
>          return;
>      }
>      xen_rmb();		/* ensure we see ring contents up to prod */
> -- 
> 2.1.4
>
Anthony PERARD April 22, 2016, 11:16 a.m. UTC | #2
On Tue, Apr 12, 2016 at 10:12:28AM -0700, Stefano Stabellini wrote:
> On Tue, 12 Apr 2016, Wei Liu wrote:
> > In commit ac0487e1 ("xenfb.c: avoid expensive loops when prod <=
> > out_cons"), ">=" was used. In fact, a full ring is a legit state.
> > Correct the test to use ">".
> > 
> > Reported-by: "Hao, Xudong" <xudong.hao@intel.com>
> > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> > Tested-by: "Hao, Xudong" <xudong.hao@intel.com>
> > Acked-by: Anthony Perard <anthony.perard@citrix.com>
> 
> Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> 
> I'll add it to my queue
> 
> 
> > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > Cc: Anthony Perard <anthony.perard@citrix.com>
> > 
> > Backport candidate to our own tree.

Patch backported to qemu-xen.git:master.
Wei Liu April 22, 2016, 11:19 a.m. UTC | #3
On Fri, Apr 22, 2016 at 12:16:09PM +0100, Anthony PERARD wrote:
> On Tue, Apr 12, 2016 at 10:12:28AM -0700, Stefano Stabellini wrote:
> > On Tue, 12 Apr 2016, Wei Liu wrote:
> > > In commit ac0487e1 ("xenfb.c: avoid expensive loops when prod <=
> > > out_cons"), ">=" was used. In fact, a full ring is a legit state.
> > > Correct the test to use ">".
> > > 
> > > Reported-by: "Hao, Xudong" <xudong.hao@intel.com>
> > > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> > > Tested-by: "Hao, Xudong" <xudong.hao@intel.com>
> > > Acked-by: Anthony Perard <anthony.perard@citrix.com>
> > 
> > Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> > 
> > I'll add it to my queue
> > 
> > 
> > > Cc: Stefano Stabellini <sstabellini@kernel.org>
> > > Cc: Anthony Perard <anthony.perard@citrix.com>
> > > 
> > > Backport candidate to our own tree.
> 
> Patch backported to qemu-xen.git:master.
> 

I think you mean staging. :-)

Wei.

> -- 
> Anthony PERARD
diff mbox

Patch

diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c
index 40b096a..9866dfd 100644
--- a/hw/display/xenfb.c
+++ b/hw/display/xenfb.c
@@ -775,7 +775,7 @@  static void xenfb_handle_events(struct XenFB *xenfb)
 
     prod = page->out_prod;
     out_cons = page->out_cons;
-    if (prod - out_cons >= XENFB_OUT_RING_LEN) {
+    if (prod - out_cons > XENFB_OUT_RING_LEN) {
         return;
     }
     xen_rmb();		/* ensure we see ring contents up to prod */