* [[PATCH -v2]] XenBus: Don't wait for the producer to fill the ring if
@ 2017-05-23 14:12 Anshul Makkar
2017-05-23 15:14 ` Jan Beulich
0 siblings, 1 reply; 4+ messages in thread
From: Anshul Makkar @ 2017-05-23 14:12 UTC (permalink / raw)
To: xen-devel; +Cc: ian.jackson, Anshul Makkar, wei.liu2, jbeulich, andrew.cooper3
The condition: if there is a space in the ring then wait for the producer
to fill the ring also evaluates to true even if the ring if full. It
leads to a deadlock where producer is waiting for consumer
to consume the items and consumer is waiting for producer to fill the ring.
Fix for the issue: check if the ring is full and then break from
the loop to consume the items from the ring.
eg. case: prod = 1272, cons = 248.
Signed-off-by: Anshul Makkar <anshul.makkar@citrix.com>
---
v2:
* resolved the coding style issue.
* modified the "if" condition statement to make it simpler.
tools/firmware/hvmloader/xenbus.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/tools/firmware/hvmloader/xenbus.c b/tools/firmware/hvmloader/xenbus.c
index 448157d..2b89a56 100644
--- a/tools/firmware/hvmloader/xenbus.c
+++ b/tools/firmware/hvmloader/xenbus.c
@@ -141,7 +141,19 @@ static void ring_read(char *data, uint32_t len)
/* Don't overrun the producer pointer */
while ( (part = MASK_XENSTORE_IDX(rings->rsp_prod -
rings->rsp_cons)) == 0 )
+ {
+ /*
+ * Don't wait for producer to fill the ring if it is already full.
+ * Condition happens when you write string > 1K into the ring.
+ * eg case prod=1272 cons=248.
+ */
+ if ( rings->rsp_prod - rings->rsp_cons == XENSTORE_RING_SIZE )
+ {
+ part = XENSTORE_RING_SIZE;
+ break;
+ }
ring_wait();
+ }
/* Don't overrun the end of the ring */
if ( part > (XENSTORE_RING_SIZE - MASK_XENSTORE_IDX(rings->rsp_cons)) )
part = XENSTORE_RING_SIZE - MASK_XENSTORE_IDX(rings->rsp_cons);
--
2.7.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [[PATCH -v2]] XenBus: Don't wait for the producer to fill the ring if
2017-05-23 14:12 [[PATCH -v2]] XenBus: Don't wait for the producer to fill the ring if Anshul Makkar
@ 2017-05-23 15:14 ` Jan Beulich
2017-05-24 14:16 ` Andrew Cooper
0 siblings, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2017-05-23 15:14 UTC (permalink / raw)
To: Julien Grall, Anshul Makkar
Cc: andrew.cooper3, wei.liu2, ian.jackson, xen-devel
>>> On 23.05.17 at 16:12, <anshul.makkar@citrix.com> wrote:
> The condition: if there is a space in the ring then wait for the producer
> to fill the ring also evaluates to true even if the ring if full. It
> leads to a deadlock where producer is waiting for consumer
> to consume the items and consumer is waiting for producer to fill the ring.
>
> Fix for the issue: check if the ring is full and then break from
> the loop to consume the items from the ring.
> eg. case: prod = 1272, cons = 248.
>
> Signed-off-by: Anshul Makkar <anshul.makkar@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Julien,
do you want to consider this for 4.9?
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [[PATCH -v2]] XenBus: Don't wait for the producer to fill the ring if
2017-05-23 15:14 ` Jan Beulich
@ 2017-05-24 14:16 ` Andrew Cooper
2017-05-25 7:29 ` Julien Grall
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cooper @ 2017-05-24 14:16 UTC (permalink / raw)
To: Jan Beulich, Julien Grall, Anshul Makkar; +Cc: ian.jackson, wei.liu2, xen-devel
On 23/05/17 16:14, Jan Beulich wrote:
>>>> On 23.05.17 at 16:12, <anshul.makkar@citrix.com> wrote:
>> The condition: if there is a space in the ring then wait for the producer
>> to fill the ring also evaluates to true even if the ring if full. It
>> leads to a deadlock where producer is waiting for consumer
>> to consume the items and consumer is waiting for producer to fill the ring.
>>
>> Fix for the issue: check if the ring is full and then break from
>> the loop to consume the items from the ring.
>> eg. case: prod = 1272, cons = 248.
>>
>> Signed-off-by: Anshul Makkar <anshul.makkar@citrix.com>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
>
> Julien,
>
> do you want to consider this for 4.9?
I'd agree with including this in 4.9
~Andrew
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [[PATCH -v2]] XenBus: Don't wait for the producer to fill the ring if
2017-05-24 14:16 ` Andrew Cooper
@ 2017-05-25 7:29 ` Julien Grall
0 siblings, 0 replies; 4+ messages in thread
From: Julien Grall @ 2017-05-25 7:29 UTC (permalink / raw)
To: Andrew Cooper, Jan Beulich, Anshul Makkar
Cc: ian.jackson, nd, wei.liu2, xen-devel
On 24/05/2017 15:16, Andrew Cooper wrote:
> On 23/05/17 16:14, Jan Beulich wrote:
>>>>> On 23.05.17 at 16:12, <anshul.makkar@citrix.com> wrote:
>>> The condition: if there is a space in the ring then wait for the producer
>>> to fill the ring also evaluates to true even if the ring if full. It
>>> leads to a deadlock where producer is waiting for consumer
>>> to consume the items and consumer is waiting for producer to fill the ring.
>>>
>>> Fix for the issue: check if the ring is full and then break from
>>> the loop to consume the items from the ring.
>>> eg. case: prod = 1272, cons = 248.
>>>
>>> Signed-off-by: Anshul Makkar <anshul.makkar@citrix.com>
>> Reviewed-by: Jan Beulich <jbeulich@suse.com>
>>
>> Julien,
>>
>> do you want to consider this for 4.9?
>
> I'd agree with including this in 4.9
Release-acked-by: Julien Grall <julien.grall@arm.com>
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-05-25 7:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-23 14:12 [[PATCH -v2]] XenBus: Don't wait for the producer to fill the ring if Anshul Makkar
2017-05-23 15:14 ` Jan Beulich
2017-05-24 14:16 ` Andrew Cooper
2017-05-25 7:29 ` Julien Grall
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.