From: "Jan Beulich" <JBeulich@suse.com> To: xen-devel <xen-devel@lists.xenproject.org> Cc: Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wei.liu2@citrix.com>, Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>, George Dunlap <George.Dunlap@eu.citrix.com>, Andrew Cooper <andrew.cooper3@citrix.com>, Ian Jackson <Ian.Jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>, Julien Grall <julien.grall@arm.com> Subject: [PATCH 1/4] x86/IRQ: don't keep EOI timer running without need Date: Wed, 08 May 2019 06:46:25 -0600 [thread overview] Message-ID: <5CD2CFA1020000780022CCA6@prv1-mh.provo.novell.com> (raw) In-Reply-To: <5CD2CDEC020000780022CC95@prv1-mh.provo.novell.com> The timer needs to remain active only until all pending IRQ instances have seen EOIs from their respective domains. Stop it when the in-flight count has reached zero in desc_guest_eoi(). Note that this is race free (with __do_IRQ_guest()), as the IRQ descriptor lock is being held at that point. Also pull up stopping of the timer in __do_IRQ_guest() itself: Instead of stopping it immediately before re-setting, stop it as soon as we've made it past any early returns from the function (and hence we're sure it'll get set again). Finally bail from the actual timer handler in case we find the timer already active again by the time we've managed to acquire the IRQ descriptor lock. Without this we may forcibly EOI an IRQ immediately after it got sent to a guest. For this, timer_is_active() gets split out of active_timer(), deliberately moving just one of the two ASSERT()s (to allow the function to be used also on a never initialized timer). Signed-off-by: Jan Beulich <jbeulich@suse.com> --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -1115,6 +1115,9 @@ static void irq_guest_eoi_timer_fn(void action = (irq_guest_action_t *)desc->action; + if ( timer_is_active(&action->eoi_timer) ) + goto out; + if ( action->ack_type != ACKTYPE_NONE ) { unsigned int i; @@ -1167,6 +1170,9 @@ static void __do_IRQ_guest(int irq) return; } + if ( action->ack_type != ACKTYPE_NONE ) + stop_timer(&action->eoi_timer); + if ( action->ack_type == ACKTYPE_EOI ) { sp = pending_eoi_sp(peoi); @@ -1194,7 +1200,6 @@ static void __do_IRQ_guest(int irq) if ( action->ack_type != ACKTYPE_NONE ) { - stop_timer(&action->eoi_timer); migrate_timer(&action->eoi_timer, smp_processor_id()); set_timer(&action->eoi_timer, NOW() + MILLISECS(1)); } @@ -1457,6 +1462,8 @@ void desc_guest_eoi(struct irq_desc *des return; } + stop_timer(&action->eoi_timer); + if ( action->ack_type == ACKTYPE_UNMASK ) { ASSERT(cpumask_empty(action->cpu_eoi_map)); --- a/xen/common/timer.c +++ b/xen/common/timer.c @@ -282,11 +282,10 @@ static inline void timer_unlock(struct t }) -static bool_t active_timer(struct timer *timer) +static bool active_timer(const struct timer *timer) { ASSERT(timer->status >= TIMER_STATUS_inactive); - ASSERT(timer->status <= TIMER_STATUS_in_list); - return (timer->status >= TIMER_STATUS_in_heap); + return timer_is_active(timer); } --- a/xen/include/xen/timer.h +++ b/xen/include/xen/timer.h @@ -75,6 +75,19 @@ bool timer_expires_before(struct timer * #define timer_is_expired(t) timer_expires_before(t, NOW()) +/* + * True if a timer is active. + * + * Unlike for timer_expires_before(), it is the caller's responsibility to + * use suitable locking such that the returned value isn't stale by the time + * it gets acted upon. + */ +static inline bool timer_is_active(const struct timer *timer) +{ + ASSERT(timer->status <= TIMER_STATUS_in_list); + return timer->status >= TIMER_STATUS_in_heap; +} + /* Migrate a timer to a different CPU. The timer may be currently active. */ void migrate_timer(struct timer *timer, unsigned int new_cpu); _______________________________________________ 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: "Jan Beulich" <JBeulich@suse.com> To: "xen-devel" <xen-devel@lists.xenproject.org> Cc: Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wei.liu2@citrix.com>, Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>, George Dunlap <George.Dunlap@eu.citrix.com>, Andrew Cooper <andrew.cooper3@citrix.com>, Ian Jackson <Ian.Jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>, Julien Grall <julien.grall@arm.com> Subject: [Xen-devel] [PATCH 1/4] x86/IRQ: don't keep EOI timer running without need Date: Wed, 08 May 2019 06:46:25 -0600 [thread overview] Message-ID: <5CD2CFA1020000780022CCA6@prv1-mh.provo.novell.com> (raw) Message-ID: <20190508124625.XdqoSvA1JxMVLuGVzcfZ3ML2olPHEOnLG77ZiXrZi_s@z> (raw) In-Reply-To: <5CD2CDEC020000780022CC95@prv1-mh.provo.novell.com> The timer needs to remain active only until all pending IRQ instances have seen EOIs from their respective domains. Stop it when the in-flight count has reached zero in desc_guest_eoi(). Note that this is race free (with __do_IRQ_guest()), as the IRQ descriptor lock is being held at that point. Also pull up stopping of the timer in __do_IRQ_guest() itself: Instead of stopping it immediately before re-setting, stop it as soon as we've made it past any early returns from the function (and hence we're sure it'll get set again). Finally bail from the actual timer handler in case we find the timer already active again by the time we've managed to acquire the IRQ descriptor lock. Without this we may forcibly EOI an IRQ immediately after it got sent to a guest. For this, timer_is_active() gets split out of active_timer(), deliberately moving just one of the two ASSERT()s (to allow the function to be used also on a never initialized timer). Signed-off-by: Jan Beulich <jbeulich@suse.com> --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -1115,6 +1115,9 @@ static void irq_guest_eoi_timer_fn(void action = (irq_guest_action_t *)desc->action; + if ( timer_is_active(&action->eoi_timer) ) + goto out; + if ( action->ack_type != ACKTYPE_NONE ) { unsigned int i; @@ -1167,6 +1170,9 @@ static void __do_IRQ_guest(int irq) return; } + if ( action->ack_type != ACKTYPE_NONE ) + stop_timer(&action->eoi_timer); + if ( action->ack_type == ACKTYPE_EOI ) { sp = pending_eoi_sp(peoi); @@ -1194,7 +1200,6 @@ static void __do_IRQ_guest(int irq) if ( action->ack_type != ACKTYPE_NONE ) { - stop_timer(&action->eoi_timer); migrate_timer(&action->eoi_timer, smp_processor_id()); set_timer(&action->eoi_timer, NOW() + MILLISECS(1)); } @@ -1457,6 +1462,8 @@ void desc_guest_eoi(struct irq_desc *des return; } + stop_timer(&action->eoi_timer); + if ( action->ack_type == ACKTYPE_UNMASK ) { ASSERT(cpumask_empty(action->cpu_eoi_map)); --- a/xen/common/timer.c +++ b/xen/common/timer.c @@ -282,11 +282,10 @@ static inline void timer_unlock(struct t }) -static bool_t active_timer(struct timer *timer) +static bool active_timer(const struct timer *timer) { ASSERT(timer->status >= TIMER_STATUS_inactive); - ASSERT(timer->status <= TIMER_STATUS_in_list); - return (timer->status >= TIMER_STATUS_in_heap); + return timer_is_active(timer); } --- a/xen/include/xen/timer.h +++ b/xen/include/xen/timer.h @@ -75,6 +75,19 @@ bool timer_expires_before(struct timer * #define timer_is_expired(t) timer_expires_before(t, NOW()) +/* + * True if a timer is active. + * + * Unlike for timer_expires_before(), it is the caller's responsibility to + * use suitable locking such that the returned value isn't stale by the time + * it gets acted upon. + */ +static inline bool timer_is_active(const struct timer *timer) +{ + ASSERT(timer->status <= TIMER_STATUS_in_list); + return timer->status >= TIMER_STATUS_in_heap; +} + /* Migrate a timer to a different CPU. The timer may be currently active. */ void migrate_timer(struct timer *timer, unsigned int new_cpu); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-05-08 12:46 UTC|newest] Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-05-08 12:39 [PATCH 0/4] x86: EOI timer corrections / improvements Jan Beulich 2019-05-08 12:39 ` [Xen-devel] " Jan Beulich 2019-05-08 12:46 ` Jan Beulich [this message] 2019-05-08 12:46 ` [Xen-devel] [PATCH 1/4] x86/IRQ: don't keep EOI timer running without need Jan Beulich 2019-05-16 10:32 ` Roger Pau Monné 2019-05-16 10:32 ` [Xen-devel] " Roger Pau Monné 2019-05-16 10:50 ` Jan Beulich 2019-05-16 10:50 ` [Xen-devel] " Jan Beulich 2019-05-16 11:03 ` Roger Pau Monné 2019-05-16 11:03 ` [Xen-devel] " Roger Pau Monné 2019-06-05 17:04 ` Andrew Cooper 2019-06-06 8:08 ` Jan Beulich 2019-06-06 9:30 ` Andrew Cooper 2019-05-08 12:46 ` [PATCH 2/4] x86/IRQ: bail early from irq_guest_eoi_timer_fn() when nothing is in flight Jan Beulich 2019-05-08 12:46 ` [Xen-devel] " Jan Beulich 2019-05-16 11:37 ` Roger Pau Monné 2019-05-16 11:37 ` [Xen-devel] " Roger Pau Monné 2019-05-16 12:02 ` Jan Beulich 2019-05-16 12:02 ` [Xen-devel] " Jan Beulich 2019-05-16 13:44 ` Roger Pau Monné 2019-05-16 13:44 ` [Xen-devel] " Roger Pau Monné 2019-06-05 17:15 ` Andrew Cooper 2019-06-06 8:17 ` Jan Beulich 2019-06-06 11:34 ` Andrew Cooper 2019-06-06 11:43 ` Jan Beulich 2019-06-06 11:45 ` Andrew Cooper 2019-05-08 12:47 ` [PATCH 3/4] x86/IRQ: relax locking in irq_guest_eoi_timer_fn() Jan Beulich 2019-05-08 12:47 ` [Xen-devel] " Jan Beulich 2019-05-16 13:48 ` Roger Pau Monné 2019-05-16 13:48 ` [Xen-devel] " Roger Pau Monné 2019-06-05 17:16 ` Andrew Cooper 2019-05-08 12:48 ` [PATCH 4/4] x86/IRQ: ACKTYPE_NONE cannot make it into irq_guest_eoi_timer_fn() Jan Beulich 2019-05-08 12:48 ` [Xen-devel] " Jan Beulich 2019-05-16 13:52 ` Roger Pau Monné 2019-05-16 13:52 ` [Xen-devel] " Roger Pau Monné 2019-05-16 14:48 ` Jan Beulich 2019-05-16 14:48 ` [Xen-devel] " Jan Beulich 2019-05-17 7:04 ` Jan Beulich 2019-05-17 7:04 ` [Xen-devel] " Jan Beulich 2019-06-05 17:18 ` 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=5CD2CFA1020000780022CCA6@prv1-mh.provo.novell.com \ --to=jbeulich@suse.com \ --cc=George.Dunlap@eu.citrix.com \ --cc=Ian.Jackson@eu.citrix.com \ --cc=andrew.cooper3@citrix.com \ --cc=julien.grall@arm.com \ --cc=konrad.wilk@oracle.com \ --cc=sstabellini@kernel.org \ --cc=tim@xen.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: linkBe 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.