Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1184806

Re: [PATCH v2 3/3] sched/preempt: fix cond_resched_lock() and cond_resched_softirq()

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: [PATCH v2 3/3] sched/preempt: fix cond_resched_lock() and cond_resched_softirq()
Date 2015-07-15 15:40 +0200
Message-ID <pMv4K-va-9@gated-at.bofh.it> (permalink)
References <pMrDR-3RV-33@gated-at.bofh.it> <pMrDS-3RV-53@gated-at.bofh.it> <pMtPj-7dE-1@gated-at.bofh.it> <pMus2-7Xo-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Jul 15, 2015 at 03:52:34PM +0300, Konstantin Khlebnikov wrote:
> On 15.07.2015 15:16, Eric Dumazet wrote:
> >On Wed, 2015-07-15 at 12:52 +0300, Konstantin Khlebnikov wrote:
> >>These functions check should_resched() before unlocking spinlock/bh-enable:
> >>preempt_count always non-zero => should_resched() always returns false.
> >>cond_resched_lock() worked iff spin_needbreak is set.
> >
> >Interesting, this definitely used to work (linux-3.11)
> >
> >Any idea of which commit broke things ?
> >
> 
> Searching... done
> 
> This one: bdb43806589096ac4272fe1307e789846ac08d7c in v3.13
> 
> before
> 
> -static inline int should_resched(void)
> -{
> -       return need_resched() && !(preempt_count() & PREEMPT_ACTIVE);
> -}
> 
> after
> 
> +static __always_inline bool should_resched(void)
> +{
> +       return unlikely(!*preempt_count_ptr());
> +}

Argh, indeed!

> 
> So,
> 
> Fixes: bdb438065890 ("sched: Extract the basic add/sub preempt_count
> modifiers")

Thanks!
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 1/3] drivers/xen/preempt: use need_resched() instead of  should_resched() Konstantin Khlebnikov <khlebnikov@yandex-team.ru> - 2015-07-15 12:00 +0200
  [PATCH v2 2/3] KVM: PPC: Book3S HV: Use need_resched() instead of  should_resched() Konstantin Khlebnikov <khlebnikov@yandex-team.ru> - 2015-07-15 12:00 +0200
  [PATCH v2 3/3] sched/preempt: fix cond_resched_lock() and  cond_resched_softirq() Konstantin Khlebnikov <khlebnikov@yandex-team.ru> - 2015-07-15 12:00 +0200
    Re: [PATCH v2 3/3] sched/preempt: fix cond_resched_lock() and  cond_resched_softirq() Eric Dumazet <eric.dumazet@gmail.com> - 2015-07-15 14:20 +0200
      Re: [PATCH v2 3/3] sched/preempt: fix cond_resched_lock() and cond_resched_softirq() Konstantin Khlebnikov <khlebnikov@yandex-team.ru> - 2015-07-15 15:00 +0200
        Re: [PATCH v2 3/3] sched/preempt: fix cond_resched_lock() and  cond_resched_softirq() Peter Zijlstra <peterz@infradead.org> - 2015-07-15 15:40 +0200
  Re: [Xen-devel] [PATCH v2 1/3] drivers/xen/preempt: use need_resched()  instead of should_resched() David Vrabel <david.vrabel@citrix.com> - 2015-07-20 15:50 +0200

csiph-web