] XenBus: Don't wait for the producer to fill the ring if
PATCH 1/1 ] XenBus: Don't wait for the producer to fill the ring if
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.
---
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(+)
tools/firmware/hvmloader/xenbus.c +12 -0
@@ -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);
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 23.05.17 at 16:12, <[email protected]> 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 <[email protected]>
Julien,
do you want to consider this for 4.9?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 10 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 23.05.17 at 16:12, <[email protected]> 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.
Quoted 6 lines
Quoted 1 line
Signed-off-by Anshul Makkar <[email protected]>Reviewed-by Jan Beulich <[email protected]>Julien,
do you want to consider this for 4.9?
I'd agree with including this in 4.9
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 11 lines · Andrew Cooper
Quoted 10 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 23.05.17 at 16:12, <[email protected]> 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.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Signed-off-by Anshul Makkar <[email protected]>Reviewed-by Jan Beulich <[email protected]>Julien,
do you want to consider this for 4.9?
I'd agree with including this in 4.9
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel