x86/mm: Correctly indent the pin_page block of do_mmuext_op()
PATCH 1/1 x86/mm: Correctly indent the pin_page block of do_mmuext_op()
The pin_page block is missing one level of indentation, which makes the MMUEXT_UNPIN_TABLE case label appear to be outside of the switch statement.
While making this adjustment, delete one other piece of trailing whitespace.
No functional change.
---
CC: Jan Beulich <[email protected]>
--- xen/arch/x86/mm.c | 115 +++++++++++++++++++++++++++--------------------------- 1 file changed, 58 insertions(+), 57 deletions(-)
xen/arch/x86/mm.c +58 -57
@@ -3249,73 +3249,74 @@ long do_mmuext_op(break ; type = PGT_l4_page_table; - pin_page: { -struct page_info *page; + pin_page: + { +struct page_info *page; -/* Ignore pinning of invalid paging levels. */ -if ( (op.cmd -MMUEXT_PIN_L1_TABLE ) > (CONFIG_PAGING_LEVELS -1 ) ) -break ; +/* Ignore pinning of invalid paging levels. */ +if ( (op.cmd -MMUEXT_PIN_L1_TABLE ) > (CONFIG_PAGING_LEVELS -1 ) ) +break ; -if (paging_mode_refcounts (pg_owner) ) -break ; +if (paging_mode_refcounts (pg_owner) ) +break ; - page =get_page_from_gfn (pg_owner, op.arg1.mfn,NULL ,P2M_ALLOC ); -if (unlikely (!page) ) - { - rc = -EINVAL ; -break ; - } + page =get_page_from_gfn (pg_owner, op.arg1.mfn,NULL ,P2M_ALLOC ); +if (unlikely (!page) ) + { + rc = -EINVAL ; +break ; + } - rc =get_page_type_preemptible (page, type); -if (unlikely (rc) ) - { -if ( rc == -EINTR ) - rc = -ERESTART ; -else if ( rc != -ERESTART ) -gdprintk (XENLOG_WARNING , -"Error %d while pinning mfn %" PRI_mfn"\n" , - rc,page_to_mfn (page)); -if ( page != curr->arch.old_guest_table ) -put_page (page); -break ; - } + rc =get_page_type_preemptible (page, type); +if (unlikely (rc) ) + { +if ( rc == -EINTR ) + rc = -ERESTART ; +else if ( rc != -ERESTART ) +gdprintk (XENLOG_WARNING , +"Error %d while pinning mfn %" PRI_mfn"\n" , + rc,page_to_mfn (page)); +if ( page != curr->arch.old_guest_table ) +put_page (page); +break ; + } - rc =xsm_memory_pin_page (XSM_HOOK , d, pg_owner, page); -if ( !rc &&unlikely (test_and_set_bit (_PGT_pinned, - &page->u.inuse.type_info)) ) - { -gdprintk (XENLOG_WARNING , -"mfn %" PRI_mfn" already pinned\n" ,page_to_mfn (page)); - rc = -EINVAL ; - } + rc =xsm_memory_pin_page (XSM_HOOK , d, pg_owner, page); +if ( !rc &&unlikely (test_and_set_bit (_PGT_pinned, + &page->u.inuse.type_info)) ) + { +gdprintk (XENLOG_WARNING , +"mfn %" PRI_mfn" already pinned\n" ,page_to_mfn (page)); + rc = -EINVAL ; + } -if (unlikely (rc) ) - goto pin_drop; +if (unlikely (rc) ) + goto pin_drop; -/* A page is dirtied when its pin status is set. */ -paging_mark_dirty (pg_owner,_mfn (page_to_mfn (page))); +/* A page is dirtied when its pin status is set. */ +paging_mark_dirty (pg_owner,_mfn (page_to_mfn (page))); -/* We can race domain destruction (domain_relinquish_resources). */ -if (unlikely (pg_owner != d) ) - { -int drop_ref; -spin_lock (&pg_owner->page_alloc_lock); - drop_ref = (pg_owner->is_dying && -test_and_clear_bit (_PGT_pinned, - &page->u.inuse.type_info)); -spin_unlock (&pg_owner->page_alloc_lock); -if ( drop_ref ) +/* We can race domain destruction (domain_relinquish_resources). */ +if (unlikely (pg_owner != d) ) { - pin_drop: -if ( type == PGT_l1_page_table ) -put_page_and_type (page); -else - curr->arch.old_guest_table = page; +int drop_ref; +spin_lock (&pg_owner->page_alloc_lock); + drop_ref = (pg_owner->is_dying && +test_and_clear_bit (_PGT_pinned, + &page->u.inuse.type_info)); +spin_unlock (&pg_owner->page_alloc_lock); +if ( drop_ref ) + { + pin_drop: +if ( type == PGT_l1_page_table ) +put_page_and_type (page); +else + curr->arch.old_guest_table = page; + } } - } -break ; - } +break ; + }case MMUEXT_UNPIN_TABLE : {struct page_info *page;
@@ -3478,7 +3479,7 @@ long do_mmuext_op(else rc = -EPERM ;break ; - +case MMUEXT_INVLPG_ALL :if (unlikely (d != pg_owner) ) rc = -EPERM ;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 05.05.17 at 17:51, <[email protected]> wrote:
The
pin_pageblock is missing one level of indentation, which makes theMMUEXT_UNPIN_TABLEcase label appear to be outside of the switch statement.While making this adjustment, delete one other piece of trailing whitespace.
No functional change.
Signed-off-by Andrew Cooper <[email protected]>
May I suggest to do this with much less code churn? If you make the "page" local variable switch-wide (which the unpin code then can also benefit from, as could the clear-page one) you won't need to re-indent anything.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v2 1/1 x86/mm: Fix the odd indentation of the pin_page block of do_mmuext_op()
The pin_page block is missing one level of indentation, which makes the MMUEXT_UNPIN_TABLE case label appear to be outside of the switch statement.
However, the block isn't needed at all if page is declared with switch level scope. This allows for the removal of the identical local declarations for MMUEXT_UNPIN_TABLE, MMUEXT_NEW_USER_BASEPTR and MMUEXT_CLEAR_PAGE.
While making this adjustment, delete one other piece of trailing whitespace.
No functional change.
---
CC: Jan Beulich <[email protected]>
v2:
* Rearange, for far less code churn.
--- xen/arch/x86/mm.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)
xen/arch/x86/mm.c +7 -16
@@ -3232,6 +3232,8 @@ long do_mmuext_op(switch ( op.cmd ) { +struct page_info *page; +case MMUEXT_PIN_L1_TABLE : type = PGT_l1_page_table; goto pin_page;
@@ -3249,9 +3251,7 @@ long do_mmuext_op(break ; type = PGT_l4_page_table; - pin_page: { -struct page_info *page; - + pin_page:/* Ignore pinning of invalid paging levels. */ if ( (op.cmd -MMUEXT_PIN_L1_TABLE ) > (CONFIG_PAGING_LEVELS -1 ) )break ;
@@ -3313,13 +3313,9 @@ long do_mmuext_op( curr->arch.old_guest_table = page; } } -break ; - } - -case MMUEXT_UNPIN_TABLE : { -struct page_info *page; +case MMUEXT_UNPIN_TABLE :if (paging_mode_refcounts (pg_owner) )break ;
@@ -3357,9 +3353,7 @@ long do_mmuext_op(/* A page is dirtied when its pin status is cleared. */ paging_mark_dirty (pg_owner,_mfn (page_to_mfn (page))); -break ; - }case MMUEXT_NEW_BASEPTR :if (unlikely (d != pg_owner) )
@@ -3414,7 +3408,7 @@ long do_mmuext_op(if ( old_mfn !=0 ) { -struct page_info *page =mfn_to_page (old_mfn); + page =mfn_to_page (old_mfn);if (paging_mode_refcounts (d) )put_page (page);
@@ -3478,7 +3472,7 @@ long do_mmuext_op(else rc = -EPERM ;break ; - +case MMUEXT_INVLPG_ALL :if (unlikely (d != pg_owner) ) rc = -EPERM ;
@@ -3542,9 +3536,7 @@ long do_mmuext_op(break ; } -case MMUEXT_CLEAR_PAGE : { -struct page_info *page; - +case MMUEXT_CLEAR_PAGE : page =get_page_from_gfn (pg_owner, op.arg1.mfn,NULL ,P2M_ALLOC );if ( !page || !get_page_type (page, PGT_writable_page) ) {
@@ -3563,7 +3555,6 @@ long do_mmuext_op(put_page_and_type (page);break ; - }case MMUEXT_COPY_PAGE : {
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v2 for-next] x86/mm: Fix the odd indentation of the pin_page block of do_mmuext_op()
Quoted 7 lines · Andrew Cooper
The
pin_pageblock is missing one level of indentation, which makes theMMUEXT_UNPIN_TABLEcase label appear to be outside of the switch statement.However, the block isn't needed at all if page is declared with switch level scope. This allows for the removal of the identical local declarations for
MMUEXT_UNPIN_TABLE,MMUEXT_NEW_USER_BASEPTRandMMUEXT_CLEAR_PAGE.
Quoted 5 lines
While making this adjustment, delete one other piece of trailing whitespace.
No functional change.
Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 for-next] x86/mm: Fix the odd indentation of the pin_page block of do_mmuext_op()
In reply to Andrew CooperQuoted 8 lines
Quoted 1 line
Quoted 1 line · On 05.05.17 at 18:32, <[email protected]> wrote:
The
pin_pageblock is missing one level of indentation, which makes theMMUEXT_UNPIN_TABLEcase label appear to be outside of the switch statement.However, the block isn't needed at all if page is declared with switch level scope. This allows for the removal of the identical local declarations for
MMUEXT_UNPIN_TABLE,MMUEXT_NEW_USER_BASEPTRandMMUEXT_CLEAR_PAGE.
Quoted 5 lines
While making this adjustment, delete one other piece of trailing whitespace.
No functional change.
Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel