Re: [Xen-devel] [PATCH 4/5] x86: use switch() in _put_page_type()

2017-12-05 Thread Jan Beulich
>>> On 04.12.17 at 16:40,  wrote:
> On 04/12/17 10:46, Jan Beulich wrote:
>> Use this to cheaply add another assertion.
>>
>> Signed-off-by: Jan Beulich 
>> ---
>> TBD: Would it perhaps be better to return after the assertion?
> 
> Yes, otherwise we risk falling into an infinite continue loop.

I've used -EILSEQ, but no, there's no infinite loop potential here, as
there's a preemption check past the switch() statement (and there
was "break" rather than "continue" after the assertion). This and
the lack of reasonably suitable error code to return here was why
I didn't use "return" in the first version. Or did you mean "infinite
continuation loop" (affecting just the guest)?

> With a suitable return value, Reviewed-by: Andrew Cooper
> 

Thanks.

Jan


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH 4/5] x86: use switch() in _put_page_type()

2017-12-04 Thread Andrew Cooper
On 04/12/17 10:46, Jan Beulich wrote:
> Use this to cheaply add another assertion.
>
> Signed-off-by: Jan Beulich 
> ---
> TBD: Would it perhaps be better to return after the assertion?

Yes, otherwise we risk falling into an infinite continue loop.

With a suitable return value, Reviewed-by: Andrew Cooper


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH 4/5] x86: use switch() in _put_page_type()

2017-12-04 Thread Jan Beulich
Use this to cheaply add another assertion.

Signed-off-by: Jan Beulich 
---
TBD: Would it perhaps be better to return after the assertion?

--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -2460,8 +2460,9 @@ static int _put_page_type(struct page_in
 
 ASSERT((x & PGT_count_mask) != 0);
 
-if ( unlikely((nx & PGT_count_mask) == 0) )
+switch ( nx & (PGT_locked | PGT_count_mask) )
 {
+case 0:
 if ( unlikely((nx & PGT_type_mask) <= PGT_l4_page_table) &&
  likely(nx & (PGT_validated|PGT_partial)) )
 {
@@ -2496,10 +2497,14 @@ static int _put_page_type(struct page_in
 }
 else
 BUG_ON(!IS_ENABLED(CONFIG_PV_LINEAR_PT));
-}
-else if ( unlikely((nx & (PGT_locked | PGT_count_mask)) ==
-   (PGT_locked | 1)) )
-{
+
+break;
+
+case PGT_locked:
+ASSERT_UNREACHABLE();
+break;
+
+case PGT_locked | 1:
 /*
  * We must not drop the second to last reference when the page is
  * locked, as page_unlock() doesn't do any cleanup of the type.




___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel