All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-next] x86/mm: Correctly indent the pin_page block of do_mmuext_op()
@ 2017-05-05 15:51 Andrew Cooper
  2017-05-05 16:11 ` Jan Beulich
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cooper @ 2017-05-05 15:51 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich

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.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
---
 xen/arch/x86/mm.c | 115 +++++++++++++++++++++++++++---------------------------
 1 file changed, 58 insertions(+), 57 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 77b0af1..a54b000 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -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;
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH for-next] x86/mm: Correctly indent the pin_page block of do_mmuext_op()
  2017-05-05 15:51 [PATCH for-next] x86/mm: Correctly indent the pin_page block of do_mmuext_op() Andrew Cooper
@ 2017-05-05 16:11 ` Jan Beulich
  2017-05-05 16:32   ` [PATCH v2 for-next] x86/mm: Fix the odd indentation of " Andrew Cooper
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2017-05-05 16:11 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Wei Liu, Xen-devel

>>> On 05.05.17 at 17:51, <andrew.cooper3@citrix.com> wrote:
> 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.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

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
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 for-next] x86/mm: Fix the odd indentation of the pin_page block of do_mmuext_op()
  2017-05-05 16:11 ` Jan Beulich
@ 2017-05-05 16:32   ` Andrew Cooper
  2017-05-05 16:35     ` Wei Liu
  2017-05-08  7:20     ` Jan Beulich
  0 siblings, 2 replies; 5+ messages in thread
From: Andrew Cooper @ 2017-05-05 16:32 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich

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.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>

v2:
 * Rearange, for far less code churn.
---
 xen/arch/x86/mm.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 411eed0..2914d1d 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -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:
         {
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 for-next] x86/mm: Fix the odd indentation of the pin_page block of do_mmuext_op()
  2017-05-05 16:32   ` [PATCH v2 for-next] x86/mm: Fix the odd indentation of " Andrew Cooper
@ 2017-05-05 16:35     ` Wei Liu
  2017-05-08  7:20     ` Jan Beulich
  1 sibling, 0 replies; 5+ messages in thread
From: Wei Liu @ 2017-05-05 16:35 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Wei Liu, Jan Beulich, Xen-devel

On Fri, May 05, 2017 at 05:32:43PM +0100, Andrew Cooper wrote:
> 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.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Wei Liu <wei.liu2@citrix.com>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 for-next] x86/mm: Fix the odd indentation of the pin_page block of do_mmuext_op()
  2017-05-05 16:32   ` [PATCH v2 for-next] x86/mm: Fix the odd indentation of " Andrew Cooper
  2017-05-05 16:35     ` Wei Liu
@ 2017-05-08  7:20     ` Jan Beulich
  1 sibling, 0 replies; 5+ messages in thread
From: Jan Beulich @ 2017-05-08  7:20 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Wei Liu, Xen-devel

>>> On 05.05.17 at 18:32, <andrew.cooper3@citrix.com> wrote:
> 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.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-05-08  7:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-05 15:51 [PATCH for-next] x86/mm: Correctly indent the pin_page block of do_mmuext_op() Andrew Cooper
2017-05-05 16:11 ` Jan Beulich
2017-05-05 16:32   ` [PATCH v2 for-next] x86/mm: Fix the odd indentation of " Andrew Cooper
2017-05-05 16:35     ` Wei Liu
2017-05-08  7:20     ` Jan Beulich

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.