All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Stefano Stabellini" <sstabellini@kernel.org>,
	"Wei Liu" <wei.liu2@citrix.com>,
	"George Dunlap" <george.dunlap@eu.citrix.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Christian Lindig" <christian.lindig@citrix.com>,
	"Pau Ruiz Safont" <pau.safont@citrix.com>,
	"Julien Grall" <julien.grall@arm.com>,
	"Edwin Török" <edvin.torok@citrix.com>,
	"Jan Beulich" <JBeulich@suse.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH 1/4] xen/watchdog: Fold exit paths to have a single unlock
Date: Fri, 10 May 2019 19:28:01 +0100	[thread overview]
Message-ID: <1557512884-32395-2-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <1557512884-32395-1-git-send-email-andrew.cooper3@citrix.com>

This is mostly to simplify future logical changes, but it does come with a
modest redunction in compiled code size (-55, 345 => 290).

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>
CC: George Dunlap <george.dunlap@eu.citrix.com>
CC: Edwin Török <edvin.torok@citrix.com>
CC: Christian Lindig <christian.lindig@citrix.com>
CC: Pau Ruiz Safont <pau.safont@citrix.com>
---
 xen/common/schedule.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index 66f1e26..47f5d04 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -1050,6 +1050,8 @@ static void domain_watchdog_timeout(void *data)
 
 static long domain_watchdog(struct domain *d, uint32_t id, uint32_t timeout)
 {
+    long rc = 0;
+
     if ( id > NR_DOMAIN_WATCHDOG_TIMERS )
         return -EINVAL;
 
@@ -1064,15 +1066,15 @@ static long domain_watchdog(struct domain *d, uint32_t id, uint32_t timeout)
             set_timer(&d->watchdog_timer[id], NOW() + SECONDS(timeout));
             break;
         }
-        spin_unlock(&d->watchdog_lock);
-        return id == NR_DOMAIN_WATCHDOG_TIMERS ? -ENOSPC : id + 1;
+        rc = id == NR_DOMAIN_WATCHDOG_TIMERS ? -ENOSPC : id + 1;
+        goto unlock;
     }
 
     id -= 1;
     if ( !test_bit(id, &d->watchdog_inuse_map) )
     {
-        spin_unlock(&d->watchdog_lock);
-        return -EINVAL;
+        rc = -EINVAL;
+        goto unlock;
     }
 
     if ( timeout == 0 )
@@ -1085,8 +1087,10 @@ static long domain_watchdog(struct domain *d, uint32_t id, uint32_t timeout)
         set_timer(&d->watchdog_timer[id], NOW() + SECONDS(timeout));
     }
 
+ unlock:
     spin_unlock(&d->watchdog_lock);
-    return 0;
+
+    return rc;
 }
 
 void watchdog_domain_init(struct domain *d)
-- 
2.1.4


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

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Stefano Stabellini" <sstabellini@kernel.org>,
	"Wei Liu" <wei.liu2@citrix.com>,
	"George Dunlap" <george.dunlap@eu.citrix.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Christian Lindig" <christian.lindig@citrix.com>,
	"Pau Ruiz Safont" <pau.safont@citrix.com>,
	"Julien Grall" <julien.grall@arm.com>,
	"Edwin Török" <edvin.torok@citrix.com>,
	"Jan Beulich" <JBeulich@suse.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [Xen-devel] [PATCH 1/4] xen/watchdog: Fold exit paths to have a single unlock
Date: Fri, 10 May 2019 19:28:01 +0100	[thread overview]
Message-ID: <1557512884-32395-2-git-send-email-andrew.cooper3@citrix.com> (raw)
Message-ID: <20190510182801.dmR7vACnWvtO3QDLo6Fh4bTvXLV974yU0rXvjcdScNM@z> (raw)
In-Reply-To: <1557512884-32395-1-git-send-email-andrew.cooper3@citrix.com>

This is mostly to simplify future logical changes, but it does come with a
modest redunction in compiled code size (-55, 345 => 290).

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>
CC: George Dunlap <george.dunlap@eu.citrix.com>
CC: Edwin Török <edvin.torok@citrix.com>
CC: Christian Lindig <christian.lindig@citrix.com>
CC: Pau Ruiz Safont <pau.safont@citrix.com>
---
 xen/common/schedule.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index 66f1e26..47f5d04 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -1050,6 +1050,8 @@ static void domain_watchdog_timeout(void *data)
 
 static long domain_watchdog(struct domain *d, uint32_t id, uint32_t timeout)
 {
+    long rc = 0;
+
     if ( id > NR_DOMAIN_WATCHDOG_TIMERS )
         return -EINVAL;
 
@@ -1064,15 +1066,15 @@ static long domain_watchdog(struct domain *d, uint32_t id, uint32_t timeout)
             set_timer(&d->watchdog_timer[id], NOW() + SECONDS(timeout));
             break;
         }
-        spin_unlock(&d->watchdog_lock);
-        return id == NR_DOMAIN_WATCHDOG_TIMERS ? -ENOSPC : id + 1;
+        rc = id == NR_DOMAIN_WATCHDOG_TIMERS ? -ENOSPC : id + 1;
+        goto unlock;
     }
 
     id -= 1;
     if ( !test_bit(id, &d->watchdog_inuse_map) )
     {
-        spin_unlock(&d->watchdog_lock);
-        return -EINVAL;
+        rc = -EINVAL;
+        goto unlock;
     }
 
     if ( timeout == 0 )
@@ -1085,8 +1087,10 @@ static long domain_watchdog(struct domain *d, uint32_t id, uint32_t timeout)
         set_timer(&d->watchdog_timer[id], NOW() + SECONDS(timeout));
     }
 
+ unlock:
     spin_unlock(&d->watchdog_lock);
-    return 0;
+
+    return rc;
 }
 
 void watchdog_domain_init(struct domain *d)
-- 
2.1.4


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

  reply	other threads:[~2019-05-10 18:28 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-10 18:28 [PATCH 0/4] xen/watchdog: Code and API improvements to the domain watchdog Andrew Cooper
2019-05-10 18:28 ` [Xen-devel] " Andrew Cooper
2019-05-10 18:28 ` Andrew Cooper [this message]
2019-05-10 18:28   ` [Xen-devel] [PATCH 1/4] xen/watchdog: Fold exit paths to have a single unlock Andrew Cooper
2019-05-13 13:14   ` Wei Liu
2019-05-13 13:14     ` [Xen-devel] " Wei Liu
2019-05-13 13:47   ` Jan Beulich
2019-05-13 13:47     ` [Xen-devel] " Jan Beulich
2019-05-13 13:51     ` Andrew Cooper
2019-05-13 13:51       ` [Xen-devel] " Andrew Cooper
2019-05-13 14:01       ` Jan Beulich
2019-05-13 14:01         ` [Xen-devel] " Jan Beulich
2019-05-13 15:22   ` George Dunlap
2019-05-13 15:22     ` [Xen-devel] " George Dunlap
2019-05-10 18:28 ` [PATCH 2/4] xen/watchdog: Rearrange the logic to fold the timer-arming paths Andrew Cooper
2019-05-10 18:28   ` [Xen-devel] " Andrew Cooper
2019-05-13 13:18   ` Andrew Cooper
2019-05-13 13:18     ` [Xen-devel] " Andrew Cooper
2019-05-10 18:28 ` [PATCH 3/4] xen/watchdog: Drop all locked operations on the watchdog_inuse_map Andrew Cooper
2019-05-10 18:28   ` [Xen-devel] " Andrew Cooper
2019-05-13 15:01   ` Jan Beulich
2019-05-13 15:01     ` [Xen-devel] " Jan Beulich
2019-05-13 15:17     ` Andrew Cooper
2019-05-13 15:17       ` [Xen-devel] " Andrew Cooper
2019-05-13 15:39       ` Jan Beulich
2019-05-13 15:39         ` [Xen-devel] " Jan Beulich
2019-05-10 18:28 ` [PATCH 4/4] xen/watchdog: Support disable all watchdog timers in one go Andrew Cooper
2019-05-10 18:28   ` [Xen-devel] " Andrew Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1557512884-32395-2-git-send-email-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=christian.lindig@citrix.com \
    --cc=edvin.torok@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=julien.grall@arm.com \
    --cc=pau.safont@citrix.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.