From: Paul Durrant <Paul.Durrant@citrix.com> To: Stefano Stabellini <Stefano.Stabellini@citrix.com>, "qemu-devel@nongnu.org" <qemu-devel@nongnu.org> Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>, "liuling-it@360.cn" <liuling-it@360.cn> Subject: Re: [Qemu-devel] [PATCH] xenfb.c: avoid expensive loops when prod <= out_cons Date: Wed, 6 Jan 2016 12:27:49 +0000 [thread overview] Message-ID: <8514e238e6304412a5a94b8115d16867@AMSPEX02CL03.citrite.net> (raw) In-Reply-To: <alpine.DEB.2.02.1601061201020.31111@kaball.uk.xensource.com> > -----Original Message----- > From: qemu-devel-bounces+paul.durrant=citrix.com@nongnu.org > [mailto:qemu-devel-bounces+paul.durrant=citrix.com@nongnu.org] On > Behalf Of Stefano Stabellini > Sent: 06 January 2016 12:08 > To: qemu-devel@nongnu.org > Cc: liuling-it@360.cn; xen-devel@lists.xensource.com; Stefano Stabellini > Subject: [Qemu-devel] [PATCH] xenfb.c: avoid expensive loops when prod > <= out_cons > > If the frontend sets out_cons to a value higher than out_prod, it will > cause xenfb_handle_events to loop about 2^32 times. Avoid that by using > better checks at the beginning of the function. > What happens when out_prod wraps? Paul > Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> > > diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c > index 4e2a27a..f963cf2 100644 > --- a/hw/display/xenfb.c > +++ b/hw/display/xenfb.c > @@ -789,10 +789,11 @@ static void xenfb_handle_events(struct XenFB > *xenfb) > > prod = page->out_prod; > out_cons = page->out_cons; > - if (prod == out_cons) > - return; > + if (prod <= out_cons) { > + return; > + } > xen_rmb(); /* ensure we see ring contents up to prod */ > - for (cons = out_cons; cons != prod; cons++) { > + for (cons = out_cons; cons < prod; cons++) { > union xenfb_out_event *event = &XENFB_OUT_RING_REF(page, > cons); > uint8_t type = event->type; > int x, y, w, h;
WARNING: multiple messages have this Message-ID (diff)
From: Paul Durrant <Paul.Durrant@citrix.com> To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org> Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>, Stefano Stabellini <Stefano.Stabellini@citrix.com>, "liuling-it@360.cn" <liuling-it@360.cn> Subject: Re: [PATCH] xenfb.c: avoid expensive loops when prod <= out_cons Date: Wed, 6 Jan 2016 12:27:49 +0000 [thread overview] Message-ID: <8514e238e6304412a5a94b8115d16867@AMSPEX02CL03.citrite.net> (raw) In-Reply-To: <alpine.DEB.2.02.1601061201020.31111@kaball.uk.xensource.com> > -----Original Message----- > From: qemu-devel-bounces+paul.durrant=citrix.com@nongnu.org > [mailto:qemu-devel-bounces+paul.durrant=citrix.com@nongnu.org] On > Behalf Of Stefano Stabellini > Sent: 06 January 2016 12:08 > To: qemu-devel@nongnu.org > Cc: liuling-it@360.cn; xen-devel@lists.xensource.com; Stefano Stabellini > Subject: [Qemu-devel] [PATCH] xenfb.c: avoid expensive loops when prod > <= out_cons > > If the frontend sets out_cons to a value higher than out_prod, it will > cause xenfb_handle_events to loop about 2^32 times. Avoid that by using > better checks at the beginning of the function. > What happens when out_prod wraps? Paul > Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> > > diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c > index 4e2a27a..f963cf2 100644 > --- a/hw/display/xenfb.c > +++ b/hw/display/xenfb.c > @@ -789,10 +789,11 @@ static void xenfb_handle_events(struct XenFB > *xenfb) > > prod = page->out_prod; > out_cons = page->out_cons; > - if (prod == out_cons) > - return; > + if (prod <= out_cons) { > + return; > + } > xen_rmb(); /* ensure we see ring contents up to prod */ > - for (cons = out_cons; cons != prod; cons++) { > + for (cons = out_cons; cons < prod; cons++) { > union xenfb_out_event *event = &XENFB_OUT_RING_REF(page, > cons); > uint8_t type = event->type; > int x, y, w, h;
next prev parent reply other threads:[~2016-01-06 12:27 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-01-06 12:08 [Qemu-devel] [PATCH] xenfb.c: avoid expensive loops when prod <= out_cons Stefano Stabellini 2016-01-06 12:08 ` Stefano Stabellini 2016-01-06 12:22 ` [Qemu-devel] [Xen-devel] " David Vrabel 2016-01-06 12:22 ` David Vrabel 2016-01-06 14:14 ` [Qemu-devel] " Stefano Stabellini 2016-01-06 14:14 ` Stefano Stabellini 2016-01-06 12:27 ` Paul Durrant [this message] 2016-01-06 12:27 ` Paul Durrant
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=8514e238e6304412a5a94b8115d16867@AMSPEX02CL03.citrite.net \ --to=paul.durrant@citrix.com \ --cc=Stefano.Stabellini@citrix.com \ --cc=liuling-it@360.cn \ --cc=qemu-devel@nongnu.org \ --cc=xen-devel@lists.xensource.com \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.