linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [ANNOUNCE] 3.18.7-rt2
@ 2015-02-23  9:06 Sebastian Andrzej Siewior
  2015-02-24 13:41 ` Mike Galbraith
  0 siblings, 1 reply; 11+ messages in thread
From: Sebastian Andrzej Siewior @ 2015-02-23  9:06 UTC (permalink / raw)
  To: linux-rt-users; +Cc: LKML, Thomas Gleixner, rostedt, John Kacur

Dear RT folks!

I'm pleased to announce the v3.18.7-rt2 patch set.
There are still patches to collect but I had this tested for a couple of
days, got big and did not want to sit on it any longer.

Changes since v3.18.7-rt1

- a patch for sched/deadline to get it work in RT (Juri Lelli)
- a patch for proper lockdep annotation for the ww-mutex (Mike Galbraith)
- a patch for AIO to avoid "sleeping while atomic". Reported by Mike
  Galbraith, fix suggested by Benjamin LaHaise
- a patch to use cmpxchg() on armv6+ in the locking path on ARM which
  actually improves performance (from Yong Zhang, resent by Nathan
  Sullivan)
- a patch to avoid "sleeping while atomic" on ARM while accessing kernel
  memory (Yadi Hu)
- a patch to avoid a race in futex code (on ARM) which may results that
  the unlock-er still owns the lock.
- a patch for memcontrol / cgroup to avoid "sleeping while atomic".
  Reported by Nikita Yushchenko, stuffed by Mike Galbraith
- a patch to avoid NULL-pointer dereference if a rtmutex is locked by
  the owner (again)
- a patch to avoid a crashes and get RT working on MIPS platforms with
  dcache aliasing (Yang Shi)
- a patch to properly use the rtmutex deadlock detector in ww-mutex
  which seems to cure a nouveau deadlock (Gustavo Bittencourt)
- a patch to properly check for a waiter in rtmutex instead
  dereferencing an invalid pointer (Brad Mouring)
- a patch to not disable interrupts in the sas_ata on -RT (Paul
  Gortmaker)
- a patch for better support of the UV x86 platform (Mike Galbraith)
- a patch not to wake up the mcework queue if it has not yet been
  initialized (Paul Gortmaker)

Known issues:

      - bcache is disabled.

      - lazy preempt on x86_64 leads to a crash with some load.

      - CPU hotplug works in general. Steven's test script however
        deadlocks usually on the second invocation.

      - xor / raid_pq
        I had max latency jumping up to 67563us on one CPU while the next
        lower max was 58us. I tracked it down to module's init code of
        xor and raid_pq. Both disable preemption while measuring the
        measuring the performance of the individual implementation.

      - cpufreq deadlocks
        the issue has been identified and will be fixed in the next -RT
        release

The delta patch against 3.18.7-rt1 is appended below and can be found here: 

   https://www.kernel.org/pub/linux/kernel/projects/rt/3.18/incr/patch-3.18.7-rt1-rt2.patch.xz

The RT patch against 3.18.7 can be found here:

   https://www.kernel.org/pub/linux/kernel/projects/rt/3.18/patch-3.18.7-rt2.patch.xz

The split quilt queue is available at:

   https://www.kernel.org/pub/linux/kernel/projects/rt/3.18/patches-3.18.7-rt2.tar.xz

Sebastian

diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
index abb2c3769b01..2386e9745ba4 100644
--- a/arch/arm/include/asm/cmpxchg.h
+++ b/arch/arm/include/asm/cmpxchg.h
@@ -129,6 +129,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
 
 #else	/* min ARCH >= ARMv6 */
 
+#define __HAVE_ARCH_CMPXCHG 1
+
 extern void __bad_cmpxchg(volatile void *ptr, int size);
 
 /*
diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
index 53e69dae796f..9d861f9f215b 100644
--- a/arch/arm/include/asm/futex.h
+++ b/arch/arm/include/asm/futex.h
@@ -93,6 +93,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
 	if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
 		return -EFAULT;
 
+	preempt_disable_rt();
+
 	__asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
 	"1:	" TUSER(ldr) "	%1, [%4]\n"
 	"	teq	%1, %2\n"
@@ -104,6 +106,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
 	: "cc", "memory");
 
 	*uval = val;
+
+	preempt_enable_rt();
 	return ret;
 }
 
diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index b40d4bab8e07..c15d2a0826c6 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -431,6 +431,9 @@ do_translation_fault(unsigned long addr, unsigned int fsr,
 	if (addr < TASK_SIZE)
 		return do_page_fault(addr, fsr, regs);
 
+	if (interrupts_enabled(regs))
+		local_irq_enable();
+
 	if (user_mode(regs))
 		goto bad_area;
 
@@ -498,6 +501,9 @@ do_translation_fault(unsigned long addr, unsigned int fsr,
 static int
 do_sect_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
 {
+	if (interrupts_enabled(regs))
+		local_irq_enable();
+
 	do_bad_area(addr, fsr, regs);
 	return 0;
 }
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index f42e35e42790..e09dae6ce80d 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -90,7 +90,7 @@ static void *__kmap_pgprot(struct page *page, unsigned long addr, pgprot_t prot)
 
 	BUG_ON(Page_dcache_dirty(page));
 
-	pagefault_disable();
+	raw_pagefault_disable();
 	idx = (addr >> PAGE_SHIFT) & (FIX_N_COLOURS - 1);
 	idx += in_interrupt() ? FIX_N_COLOURS : 0;
 	vaddr = __fix_to_virt(FIX_CMAP_END - idx);
@@ -146,7 +146,7 @@ void kunmap_coherent(void)
 	tlbw_use_hazard();
 	write_c0_entryhi(old_ctx);
 	local_irq_restore(flags);
-	pagefault_enable();
+	raw_pagefault_enable();
 }
 
 void copy_user_highpage(struct page *to, struct page *from,
diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h
index 2d60a7813dfe..ddc4c9e3d09d 100644
--- a/arch/x86/include/asm/uv/uv_bau.h
+++ b/arch/x86/include/asm/uv/uv_bau.h
@@ -615,9 +615,9 @@ struct bau_control {
 	cycles_t		send_message;
 	cycles_t		period_end;
 	cycles_t		period_time;
-	spinlock_t		uvhub_lock;
-	spinlock_t		queue_lock;
-	spinlock_t		disable_lock;
+	raw_spinlock_t		uvhub_lock;
+	raw_spinlock_t		queue_lock;
+	raw_spinlock_t		disable_lock;
 	/* tunables */
 	int			max_concurr;
 	int			max_concurr_const;
@@ -776,15 +776,15 @@ static inline int atom_asr(short i, struct atomic_short *v)
  * to be lowered below the current 'v'.  atomic_add_unless can only stop
  * on equal.
  */
-static inline int atomic_inc_unless_ge(spinlock_t *lock, atomic_t *v, int u)
+static inline int atomic_inc_unless_ge(raw_spinlock_t *lock, atomic_t *v, int u)
 {
-	spin_lock(lock);
+	raw_spin_lock(lock);
 	if (atomic_read(v) >= u) {
-		spin_unlock(lock);
+		raw_spin_unlock(lock);
 		return 0;
 	}
 	atomic_inc(v);
-	spin_unlock(lock);
+	raw_spin_unlock(lock);
 	return 1;
 }
 
diff --git a/arch/x86/include/asm/uv/uv_hub.h b/arch/x86/include/asm/uv/uv_hub.h
index a00ad8f2a657..c2729abe02bc 100644
--- a/arch/x86/include/asm/uv/uv_hub.h
+++ b/arch/x86/include/asm/uv/uv_hub.h
@@ -492,7 +492,7 @@ struct uv_blade_info {
 	unsigned short	nr_online_cpus;
 	unsigned short	pnode;
 	short		memory_nid;
-	spinlock_t	nmi_lock;	/* obsolete, see uv_hub_nmi */
+	raw_spinlock_t	nmi_lock;	/* obsolete, see uv_hub_nmi */
 	unsigned long	nmi_count;	/* obsolete, see uv_hub_nmi */
 };
 extern struct uv_blade_info *uv_blade_info;
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
index 8e9dcfd630e4..2cfedcae31b9 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -918,7 +918,7 @@ void __init uv_system_init(void)
 			uv_blade_info[blade].pnode = pnode;
 			uv_blade_info[blade].nr_possible_cpus = 0;
 			uv_blade_info[blade].nr_online_cpus = 0;
-			spin_lock_init(&uv_blade_info[blade].nmi_lock);
+			raw_spin_lock_init(&uv_blade_info[blade].nmi_lock);
 			min_pnode = min(pnode, min_pnode);
 			max_pnode = max(pnode, max_pnode);
 			blade++;
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index c23856109466..718fc6cc6c64 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -1411,6 +1411,11 @@ static int mce_notify_work_init(void)
 
 static void mce_notify_work(void)
 {
+	if (WARN_ON_ONCE(!mce_notify_helper)) {
+		pr_info(HW_ERR "Machine check event before MCE init; ignored\n");
+		return;
+	}
+
 	wake_up_process(mce_notify_helper);
 }
 #else
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 3968d67d366b..7d444650bdd4 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -714,9 +714,9 @@ static void destination_plugged(struct bau_desc *bau_desc,
 
 		quiesce_local_uvhub(hmaster);
 
-		spin_lock(&hmaster->queue_lock);
+		raw_spin_lock(&hmaster->queue_lock);
 		reset_with_ipi(&bau_desc->distribution, bcp);
-		spin_unlock(&hmaster->queue_lock);
+		raw_spin_unlock(&hmaster->queue_lock);
 
 		end_uvhub_quiesce(hmaster);
 
@@ -736,9 +736,9 @@ static void destination_timeout(struct bau_desc *bau_desc,
 
 		quiesce_local_uvhub(hmaster);
 
-		spin_lock(&hmaster->queue_lock);
+		raw_spin_lock(&hmaster->queue_lock);
 		reset_with_ipi(&bau_desc->distribution, bcp);
-		spin_unlock(&hmaster->queue_lock);
+		raw_spin_unlock(&hmaster->queue_lock);
 
 		end_uvhub_quiesce(hmaster);
 
@@ -759,7 +759,7 @@ static void disable_for_period(struct bau_control *bcp, struct ptc_stats *stat)
 	cycles_t tm1;
 
 	hmaster = bcp->uvhub_master;
-	spin_lock(&hmaster->disable_lock);
+	raw_spin_lock(&hmaster->disable_lock);
 	if (!bcp->baudisabled) {
 		stat->s_bau_disabled++;
 		tm1 = get_cycles();
@@ -772,7 +772,7 @@ static void disable_for_period(struct bau_control *bcp, struct ptc_stats *stat)
 			}
 		}
 	}
-	spin_unlock(&hmaster->disable_lock);
+	raw_spin_unlock(&hmaster->disable_lock);
 }
 
 static void count_max_concurr(int stat, struct bau_control *bcp,
@@ -835,7 +835,7 @@ static void record_send_stats(cycles_t time1, cycles_t time2,
  */
 static void uv1_throttle(struct bau_control *hmaster, struct ptc_stats *stat)
 {
-	spinlock_t *lock = &hmaster->uvhub_lock;
+	raw_spinlock_t *lock = &hmaster->uvhub_lock;
 	atomic_t *v;
 
 	v = &hmaster->active_descriptor_count;
@@ -968,7 +968,7 @@ static int check_enable(struct bau_control *bcp, struct ptc_stats *stat)
 	struct bau_control *hmaster;
 
 	hmaster = bcp->uvhub_master;
-	spin_lock(&hmaster->disable_lock);
+	raw_spin_lock(&hmaster->disable_lock);
 	if (bcp->baudisabled && (get_cycles() >= bcp->set_bau_on_time)) {
 		stat->s_bau_reenabled++;
 		for_each_present_cpu(tcpu) {
@@ -980,10 +980,10 @@ static int check_enable(struct bau_control *bcp, struct ptc_stats *stat)
 				tbcp->period_giveups = 0;
 			}
 		}
-		spin_unlock(&hmaster->disable_lock);
+		raw_spin_unlock(&hmaster->disable_lock);
 		return 0;
 	}
-	spin_unlock(&hmaster->disable_lock);
+	raw_spin_unlock(&hmaster->disable_lock);
 	return -1;
 }
 
@@ -1899,9 +1899,9 @@ static void __init init_per_cpu_tunables(void)
 		bcp->cong_reps			= congested_reps;
 		bcp->disabled_period =		sec_2_cycles(disabled_period);
 		bcp->giveup_limit =		giveup_limit;
-		spin_lock_init(&bcp->queue_lock);
-		spin_lock_init(&bcp->uvhub_lock);
-		spin_lock_init(&bcp->disable_lock);
+		raw_spin_lock_init(&bcp->queue_lock);
+		raw_spin_lock_init(&bcp->uvhub_lock);
+		raw_spin_lock_init(&bcp->disable_lock);
 	}
 }
 
diff --git a/arch/x86/platform/uv/uv_time.c b/arch/x86/platform/uv/uv_time.c
index a244237f3cfa..a718fe0d2e73 100644
--- a/arch/x86/platform/uv/uv_time.c
+++ b/arch/x86/platform/uv/uv_time.c
@@ -58,7 +58,7 @@ static DEFINE_PER_CPU(struct clock_event_device, cpu_ced);
 
 /* There is one of these allocated per node */
 struct uv_rtc_timer_head {
-	spinlock_t	lock;
+	raw_spinlock_t	lock;
 	/* next cpu waiting for timer, local node relative: */
 	int		next_cpu;
 	/* number of cpus on this node: */
@@ -178,7 +178,7 @@ static __init int uv_rtc_allocate_timers(void)
 				uv_rtc_deallocate_timers();
 				return -ENOMEM;
 			}
-			spin_lock_init(&head->lock);
+			raw_spin_lock_init(&head->lock);
 			head->ncpus = uv_blade_nr_possible_cpus(bid);
 			head->next_cpu = -1;
 			blade_info[bid] = head;
@@ -232,7 +232,7 @@ static int uv_rtc_set_timer(int cpu, u64 expires)
 	unsigned long flags;
 	int next_cpu;
 
-	spin_lock_irqsave(&head->lock, flags);
+	raw_spin_lock_irqsave(&head->lock, flags);
 
 	next_cpu = head->next_cpu;
 	*t = expires;
@@ -244,12 +244,12 @@ static int uv_rtc_set_timer(int cpu, u64 expires)
 		if (uv_setup_intr(cpu, expires)) {
 			*t = ULLONG_MAX;
 			uv_rtc_find_next_timer(head, pnode);
-			spin_unlock_irqrestore(&head->lock, flags);
+			raw_spin_unlock_irqrestore(&head->lock, flags);
 			return -ETIME;
 		}
 	}
 
-	spin_unlock_irqrestore(&head->lock, flags);
+	raw_spin_unlock_irqrestore(&head->lock, flags);
 	return 0;
 }
 
@@ -268,7 +268,7 @@ static int uv_rtc_unset_timer(int cpu, int force)
 	unsigned long flags;
 	int rc = 0;
 
-	spin_lock_irqsave(&head->lock, flags);
+	raw_spin_lock_irqsave(&head->lock, flags);
 
 	if ((head->next_cpu == bcpu && uv_read_rtc(NULL) >= *t) || force)
 		rc = 1;
@@ -280,7 +280,7 @@ static int uv_rtc_unset_timer(int cpu, int force)
 			uv_rtc_find_next_timer(head, pnode);
 	}
 
-	spin_unlock_irqrestore(&head->lock, flags);
+	raw_spin_unlock_irqrestore(&head->lock, flags);
 
 	return rc;
 }
@@ -300,13 +300,18 @@ static int uv_rtc_unset_timer(int cpu, int force)
 static cycle_t uv_read_rtc(struct clocksource *cs)
 {
 	unsigned long offset;
+	cycle_t cycles;
 
+	preempt_disable();
 	if (uv_get_min_hub_revision_id() == 1)
 		offset = 0;
 	else
 		offset = (uv_blade_processor_id() * L1_CACHE_BYTES) % PAGE_SIZE;
 
-	return (cycle_t)uv_read_local_mmr(UVH_RTC | offset);
+	cycles = (cycle_t)uv_read_local_mmr(UVH_RTC | offset);
+	preempt_enable();
+
+	return cycles;
 }
 
 /*
diff --git a/block/blk-mq.c b/block/blk-mq.c
index dce02cef145c..ec679b2c2229 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1272,9 +1272,7 @@ static void blk_sq_make_request(struct request_queue *q, struct bio *bio)
 			if (list_empty(&plug->mq_list))
 				trace_block_plug(q);
 			else if (request_count >= BLK_MAX_REQUEST_COUNT) {
-				spin_unlock(&data.ctx->cpu_lock);
 				blk_flush_plug_list(plug, false);
-				spin_lock(&data.ctx->cpu_lock);
 				trace_block_plug(q);
 			}
 			list_add_tail(&rq->queuelist, &plug->mq_list);
@@ -1470,7 +1468,6 @@ static int blk_mq_hctx_cpu_offline(struct blk_mq_hw_ctx *hctx, int cpu)
 		blk_mq_hctx_clear_pending(hctx, ctx);
 	}
 	spin_unlock(&ctx->lock);
-	__blk_mq_put_ctx(ctx);
 
 	if (list_empty(&tmp))
 		return NOTIFY_OK;
@@ -1680,7 +1677,6 @@ static void blk_mq_init_cpu_queues(struct request_queue *q,
 		memset(__ctx, 0, sizeof(*__ctx));
 		__ctx->cpu = i;
 		spin_lock_init(&__ctx->lock);
-		spin_lock_init(&__ctx->cpu_lock);
 		INIT_LIST_HEAD(&__ctx->rq_list);
 		__ctx->queue = q;
 
diff --git a/block/blk-mq.h b/block/blk-mq.h
index d0d4780ddfb6..d1d78dfe4123 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -9,7 +9,6 @@ struct blk_mq_ctx {
 		struct list_head	rq_list;
 	}  ____cacheline_aligned_in_smp;
 
-	spinlock_t		cpu_lock;
 	unsigned int		cpu;
 	unsigned int		index_hw;
 
@@ -77,7 +76,6 @@ static inline struct blk_mq_ctx *__blk_mq_get_ctx(struct request_queue *q,
 	struct blk_mq_ctx *ctx;
 
 	ctx = per_cpu_ptr(q->queue_ctx, cpu);
-	spin_lock(&ctx->cpu_lock);
 	return ctx;
 }
 
@@ -92,14 +90,8 @@ static inline struct blk_mq_ctx *blk_mq_get_ctx(struct request_queue *q)
 	return __blk_mq_get_ctx(q, get_cpu_light());
 }
 
-static void __blk_mq_put_ctx(struct blk_mq_ctx *ctx)
-{
-	spin_unlock(&ctx->cpu_lock);
-}
-
 static inline void blk_mq_put_ctx(struct blk_mq_ctx *ctx)
 {
-	__blk_mq_put_ctx(ctx);
 	put_cpu_light();
 }
 
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index 766098af4eb7..d79daca3b00b 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -191,7 +191,7 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc)
 	/* TODO: audit callers to ensure they are ready for qc_issue to
 	 * unconditionally re-enable interrupts
 	 */
-	local_irq_save(flags);
+	local_irq_save_nort(flags);
 	spin_unlock(ap->lock);
 
 	/* If the device fell off, no sense in issuing commands */
@@ -261,7 +261,7 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc)
 
  out:
 	spin_lock(ap->lock);
-	local_irq_restore(flags);
+	local_irq_restore_nort(flags);
 	return ret;
 }
 
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 5906c14a4e64..e257819480a9 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -360,7 +360,8 @@ int max_lock_depth = 1024;
 
 static inline struct rt_mutex *task_blocked_on_lock(struct task_struct *p)
 {
-	return p->pi_blocked_on ? p->pi_blocked_on->lock : NULL;
+	return rt_mutex_real_waiter(p->pi_blocked_on) ?
+		p->pi_blocked_on->lock : NULL;
 }
 
 /*
@@ -1700,7 +1701,8 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state,
 	set_current_state(TASK_RUNNING);
 
 	if (unlikely(ret)) {
-		remove_waiter(lock, &waiter);
+		if (rt_mutex_has_waiters(lock))
+			remove_waiter(lock, &waiter);
 		rt_mutex_handle_deadlock(ret, chwalk, &waiter);
 	} else if (ww_ctx) {
 		ww_mutex_account_lock(lock, ww_ctx);
@@ -2242,7 +2244,8 @@ __ww_mutex_lock_interruptible(struct ww_mutex *lock, struct ww_acquire_ctx *ww_c
 	might_sleep();
 
 	mutex_acquire_nest(&lock->base.dep_map, 0, 0, &ww_ctx->dep_map, _RET_IP_);
-	ret = rt_mutex_slowlock(&lock->base.lock, TASK_INTERRUPTIBLE, NULL, 0, ww_ctx);
+	ret = rt_mutex_slowlock(&lock->base.lock, TASK_INTERRUPTIBLE, NULL,
+				RT_MUTEX_FULL_CHAINWALK, ww_ctx);
 	if (ret)
 		mutex_release(&lock->base.dep_map, 1, _RET_IP_);
 	else if (!ret && ww_ctx->acquired > 1)
@@ -2260,7 +2263,8 @@ __ww_mutex_lock(struct ww_mutex *lock, struct ww_acquire_ctx *ww_ctx)
 	might_sleep();
 
 	mutex_acquire_nest(&lock->base.dep_map, 0, 0, &ww_ctx->dep_map, _RET_IP_);
-	ret = rt_mutex_slowlock(&lock->base.lock, TASK_UNINTERRUPTIBLE, NULL, 0, ww_ctx);
+	ret = rt_mutex_slowlock(&lock->base.lock, TASK_UNINTERRUPTIBLE, NULL,
+				RT_MUTEX_FULL_CHAINWALK, ww_ctx);
 	if (ret)
 		mutex_release(&lock->base.dep_map, 1, _RET_IP_);
 	else if (!ret && ww_ctx->acquired > 1)
diff --git a/localversion-rt b/localversion-rt
index 6f206be67cd2..c3054d08a112 100644
--- a/localversion-rt
+++ b/localversion-rt
@@ -1 +1 @@
--rt1
+-rt2
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 498e8844a142..0c4538811188 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2379,14 +2379,17 @@ static void __init memcg_stock_init(void)
  */
 static void refill_stock(struct mem_cgroup *memcg, unsigned int nr_pages)
 {
-	struct memcg_stock_pcp *stock = &get_cpu_var(memcg_stock);
+	struct memcg_stock_pcp *stock;
+	int cpu = get_cpu_light();
+
+	stock = &per_cpu(memcg_stock, cpu);
 
 	if (stock->cached != memcg) { /* reset if necessary */
 		drain_stock(stock);
 		stock->cached = memcg;
 	}
 	stock->nr_pages += nr_pages;
-	put_cpu_var(memcg_stock);
+	put_cpu_light();
 }
 
 /*

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

* Re: [ANNOUNCE] 3.18.7-rt2
  2015-02-23  9:06 [ANNOUNCE] 3.18.7-rt2 Sebastian Andrzej Siewior
@ 2015-02-24 13:41 ` Mike Galbraith
  2015-02-24 14:13   ` Mike Galbraith
  2015-02-24 16:19   ` Gustavo Bittencourt
  0 siblings, 2 replies; 11+ messages in thread
From: Mike Galbraith @ 2015-02-24 13:41 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-rt-users, LKML, Thomas Gleixner, rostedt, John Kacur,
	Gustavo Bittencourt

On Mon, 2015-02-23 at 10:06 +0100, Sebastian Andrzej Siewior wrote:

> - a patch to properly use the rtmutex deadlock detector in ww-mutex
>   which seems to cure a nouveau deadlock (Gustavo Bittencourt)

How about the below instead.  In 4.0.0-rt, i915 deadlocked, and the
below fixed that.  DRM doesn't actually _work_ in 4.0-rt mind you,
there's something else lurking as well, but the locking is now happy,
and 3.18-rt continues to work just fine.


locking, ww_mutex: fix ww_mutex vs self-deadlock

If the caller already holds the mutex, task_blocks_on_rt_mutex()
returns -EDEADLK, we proceed directly to rt_mutex_handle_deadlock()
where it's instant game over.

Let ww_mutexes return EDEADLK/EALREADY as they want to instead.

Signed-off-by: Mike Galbraith <umgwanakikbuti@gmail.com>
---
 kernel/locking/rtmutex.c |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -1706,8 +1706,12 @@ rt_mutex_slowlock(struct rt_mutex *lock,
 	ret = task_blocks_on_rt_mutex(lock, &waiter, current, chwalk);
 
 	if (likely(!ret))
-		ret = __rt_mutex_slowlock(lock, state, timeout, &waiter,
-					  ww_ctx);
+		ret = __rt_mutex_slowlock(lock, state, timeout, &waiter, ww_ctx);
+	else if (ww_ctx) {
+		/* ww_mutex received EDEADLK, let it become EALREADY */
+		ret = __mutex_lock_check_stamp(lock, ww_ctx);
+		BUG_ON(!ret);
+	}
 
 	set_current_state(TASK_RUNNING);
 
@@ -1715,6 +1719,9 @@ rt_mutex_slowlock(struct rt_mutex *lock,
 		if (rt_mutex_has_waiters(lock))
 			remove_waiter(lock, &waiter);
 		rt_mutex_handle_deadlock(ret, chwalk, &waiter);
+		/* ww_mutex want to report EDEADLK/EALREADY, let them */
+		if (!ww_ctx)
+			rt_mutex_handle_deadlock(ret, chwalk, &waiter);
 	} else if (ww_ctx) {
 		ww_mutex_account_lock(lock, ww_ctx);
 	}
@@ -2258,8 +2265,7 @@ __ww_mutex_lock_interruptible(struct ww_
 	might_sleep();
 
 	mutex_acquire_nest(&lock->base.dep_map, 0, 0, &ww_ctx->dep_map, _RET_IP_);
-	ret = rt_mutex_slowlock(&lock->base.lock, TASK_INTERRUPTIBLE, NULL,
-				RT_MUTEX_FULL_CHAINWALK, ww_ctx);
+	ret = rt_mutex_slowlock(&lock->base.lock, TASK_INTERRUPTIBLE, NULL, 0, ww_ctx);
 	if (ret)
 		mutex_release(&lock->base.dep_map, 1, _RET_IP_);
 	else if (!ret && ww_ctx->acquired > 1)
@@ -2277,8 +2283,7 @@ __ww_mutex_lock(struct ww_mutex *lock, s
 	might_sleep();
 
 	mutex_acquire_nest(&lock->base.dep_map, 0, 0, &ww_ctx->dep_map, _RET_IP_);
-	ret = rt_mutex_slowlock(&lock->base.lock, TASK_UNINTERRUPTIBLE, NULL,
-				RT_MUTEX_FULL_CHAINWALK, ww_ctx);
+	ret = rt_mutex_slowlock(&lock->base.lock, TASK_UNINTERRUPTIBLE, NULL, 0, ww_ctx);
 	if (ret)
 		mutex_release(&lock->base.dep_map, 1, _RET_IP_);
 	else if (!ret && ww_ctx->acquired > 1)



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

* Re: [ANNOUNCE] 3.18.7-rt2
  2015-02-24 13:41 ` Mike Galbraith
@ 2015-02-24 14:13   ` Mike Galbraith
  2015-02-24 16:19   ` Gustavo Bittencourt
  1 sibling, 0 replies; 11+ messages in thread
From: Mike Galbraith @ 2015-02-24 14:13 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-rt-users, LKML, Thomas Gleixner, rostedt, John Kacur,
	Gustavo Bittencourt

On Tue, 2015-02-24 at 14:41 +0100, Mike Galbraith wrote:
> On Mon, 2015-02-23 at 10:06 +0100, Sebastian Andrzej Siewior wrote:
> 
> > - a patch to properly use the rtmutex deadlock detector in ww-mutex
> >   which seems to cure a nouveau deadlock (Gustavo Bittencourt)
> 
> How about the below instead.  In 4.0.0-rt, i915 deadlocked, and the
> below fixed that.  DRM doesn't actually _work_ in 4.0-rt mind you,

Well how 'bout that.  I take that back, there's still something lurking
on my old Toshiba Satellite in 4.0-rt, but my shiny new desktop box now
works fine, whereas it was deadlocking as well (I used it to debug).

[   156.293] (II) Module intel: vendor="X.Org Foundation"
[   156.293]    compiled for 1.16.1, module version = 2.99.916
[   156.293]    Module class: X.Org Video Driver
[   156.293]    ABI class: X.Org Video Driver, version 18.0
[   156.293] (II) intel: Driver for Intel(R) Integrated Graphics Chipsets:
        i810, i810-dc100, i810e, i815, i830M, 845G, 854, 852GM/855GM, 865G,
        915G, E7221 (i915), 915GM, 945G, 945GM, 945GME, Pineview GM,
        Pineview G, 965G, G35, 965Q, 946GZ, 965GM, 965GME/GLE, G33, Q35, Q33,
        GM45, 4 Series, G45/G43, Q45/Q43, G41, B43
[   156.294] (II) intel: Driver for Intel(R) HD Graphics: 2000-6000
[   156.294] (II) intel: Driver for Intel(R) Iris(TM) Graphics: 5100, 6100
[   156.294] (II) intel: Driver for Intel(R) Iris(TM) Pro Graphics: 5200, 6200, P6300
[   156.294] (++) using VT number 7

[   156.294] (II) intel(0): Using Kernel Mode Setting driver: i915, version 1.6.0 20150130
[   156.294] (--) intel(0): Integrated Graphics Chipset: Intel(R) HD Graphics 4600
[   156.294] (--) intel(0): CPU: x86-64, sse2, sse3, ssse3, sse4.1, sse4.2, avx, avx2
[   156.294] (II) intel(0): Creating default Display subsection in Screen section
        "intel" for depth/fbbpp 24/32
[   156.294] (==) intel(0): Depth 24, (--) framebuffer bpp 32
[   156.294] (==) intel(0): RGB weight 888
[   156.294] (==) intel(0): Default visual is TrueColor
[   156.294] (II) intel(0): Output VGA1 has no monitor section
[   156.294] (II) intel(0): Enabled output VGA1
[   156.294] (II) intel(0): Output HDMI2 has no monitor section
[   156.294] (II) intel(0): Enabled output HDMI2
[   156.294] (--) intel(0): Using a maximum size of 256x256 for hardware cursors
[   156.294] (II) intel(0): Output VIRTUAL1 has no monitor section
[   156.294] (II) intel(0): Enabled output VIRTUAL1
[   156.294] (--) intel(0): Output VGA1 using initial mode 1680x1050 on pipe 0
[   156.294] (==) intel(0): TearFree disabled
[   156.294] (==) intel(0): DPI set to (96, 96)
[   156.294] (II) Loading sub module "dri2"
[   156.294] (II) LoadModule: "dri2"
[   156.294] (II) Module "dri2" already built-in
[   156.294] (II) Loading sub module "present"
[   156.294] (II) LoadModule: "present"
[   156.294] (II) Module "present" already built-in
[   156.294] (==) Depth 24 pixmap format is 32 bpp
[   156.294] (II) intel(0): SNA initialized with Haswell (gen7.5, gt2) backend
[   156.294] (==) intel(0): Backing store enabled
[   156.294] (==) intel(0): Silken mouse enabled
[   156.294] (II) intel(0): HW Cursor enabled
[   156.294] (II) intel(0): RandR 1.2 enabled, ignore the following RandR disabled message.
[   156.294] (==) intel(0): DPMS enabled
[   156.294] (II) intel(0): [DRI2] Setup complete
[   156.294] (II) intel(0): [DRI2]   DRI driver: i965
[   156.294] (II) intel(0): [DRI2]   VDPAU driver: i965
[   156.294] (II) intel(0): direct rendering: DRI2 enabled
[   156.294] (II) intel(0): hardware support for Present enabled
[   156.294] (==) intel(0): display hotplug detection enabled
[   156.294] (--) RandR disabled
[   156.305] (II) AIGLX: enabled GLX_MESA_copy_sub_buffer
[   156.305] (II) AIGLX: enabled GLX_ARB_create_context
[   156.305] (II) AIGLX: enabled GLX_ARB_create_context_profile
[   156.305] (II) AIGLX: enabled GLX_EXT_create_context_es2_profile
[   156.305] (II) AIGLX: enabled GLX_INTEL_swap_event
[   156.305] (II) AIGLX: enabled GLX_SGI_swap_control and GLX_MESA_swap_control
[   156.305] (II) AIGLX: enabled GLX_EXT_framebuffer_sRGB
[   156.305] (II) AIGLX: enabled GLX_ARB_fbconfig_float
[   156.305] (II) AIGLX: GLX_EXT_texture_from_pixmap backed by buffer objects
[   156.305] (II) AIGLX: enabled GLX_ARB_create_context_robustness
[   156.305] (II) AIGLX: Loaded and initialized i965
[   156.305] (II) GLX: Initialized DRI2 GL provider for screen 0
[   156.307] (II) intel(0): switch to mode 1680x1050@60.0 on VGA1 using pipe 0, position (0, 0), rotation normal, reflection none
[   156.321] (II) intel(0): Setting screen physical size to 444 x 277




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

* Re: [ANNOUNCE] 3.18.7-rt2
  2015-02-24 13:41 ` Mike Galbraith
  2015-02-24 14:13   ` Mike Galbraith
@ 2015-02-24 16:19   ` Gustavo Bittencourt
  2015-02-24 17:50     ` Mike Galbraith
  2015-02-26  8:02     ` Mike Galbraith
  1 sibling, 2 replies; 11+ messages in thread
From: Gustavo Bittencourt @ 2015-02-24 16:19 UTC (permalink / raw)
  To: Mike Galbraith
  Cc: Sebastian Andrzej Siewior, linux-rt-users, LKML, Thomas Gleixner,
	rostedt, John Kacur

On Tue, Feb 24, 2015 at 10:41 AM, Mike Galbraith
<umgwanakikbuti@gmail.com> wrote:
> locking, ww_mutex: fix ww_mutex vs self-deadlock
>
> If the caller already holds the mutex, task_blocks_on_rt_mutex()
> returns -EDEADLK, we proceed directly to rt_mutex_handle_deadlock()
> where it's instant game over.
>
> Let ww_mutexes return EDEADLK/EALREADY as they want to instead.
>
> Signed-off-by: Mike Galbraith <umgwanakikbuti@gmail.com>
> ---
>  kernel/locking/rtmutex.c |   17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
>
> --- a/kernel/locking/rtmutex.c
> +++ b/kernel/locking/rtmutex.c

The deadlock returned after I applied this patch in v3.18.7-rt2. Here is my log:

[  244.476210] BUG: scheduling while atomic: Xorg/1549/0x00000002
[  244.476258] Modules linked in: ctr ccm nouveau arc4 ath9k
ath9k_common ath9k_hw ath mac80211 uvcvideo snd_hda_codec_hdmi
videobuf2_vmalloc snd_hda_codec_realtek videobuf2_memops
videobuf2_core snd_hda_codec_generic v4l2_common snd_hda_intel
videodev mxm_wmi wmi i2c_algo_bit drm_kms_helper snd_hda_controller
snd_hda_codec ttm drm snd_pcm snd_hwdep snd_seq_midi
snd_seq_midi_event snd_rawmidi intel_rapl snd_seq bnep
x86_pkg_temp_thermal cfg80211 intel_powerclamp snd_timer mei_me
snd_seq_device rfcomm snd btusb mei joydev soundcore bluetooth
serio_raw mac_hid coretemp lpc_ich sony_laptop crc32_pclmul video
parport_pc ppdev lp parport firewire_ohci psmouse ahci sdhci_pci
firewire_core r8169 libahci sdhci mii crc_itu_t
[  244.476261] Preemption disabled at:[<c1685f5b>] rt_mutex_slowlock+0x3b/0x200
[  244.476262]
[  244.476263] CPU: 2 PID: 1549 Comm: Xorg Tainted: G        W
3.18.7-rt2-00002-g8c033b9 #3
[  244.476264] Hardware name: Sony Corporation VPCF215FB/VAIO, BIOS
R0200V3 02/10/2011
[  244.476271]  00000000 00000000 f1a5fc5c c1681e38 f1968f20 f1a5fc74
c167eacf c18f581c
[  244.476278]  c1685f5b c1685f5b 00000002 f1a5fcf8 c1684a3e f1a5fcfc
c187136c 0000001d
[  244.476287]  c1adabc0 c1adabc0 00000000 f168fc00 00000038 f1968f20
f7774bc0 f1968f20
[  244.476288] Call Trace:
[  244.476291]  [<c1681e38>] dump_stack+0x4b/0x88
[  244.476294]  [<c167eacf>] __schedule_bug+0x9e/0xac
[  244.476297]  [<c1685f5b>] ? rt_mutex_slowlock+0x3b/0x200
[  244.476300]  [<c1685f5b>] ? rt_mutex_slowlock+0x3b/0x200
[  244.476303]  [<c1684a3e>] __schedule+0x6ce/0x7a0
[  244.476306]  [<c105fb6b>] ? print_oops_end_marker+0x3b/0x40
[  244.476308]  [<c105fbff>] ? warn_slowpath_common+0x8f/0xa0
[  244.476311]  [<c167ec42>] ?
rt_mutex_handle_deadlock.isra.21.part.22+0x2f/0x48
[  244.476313]  [<c167ec42>] ?
rt_mutex_handle_deadlock.isra.21.part.22+0x2f/0x48
[  244.476315]  [<c1684b3b>] schedule+0x2b/0x90
[  244.476318]  [<c167ec59>] rt_mutex_handle_deadlock.isra.21.part.22+0x46/0x48
[  244.476320]  [<c168610d>] rt_mutex_slowlock+0x1ed/0x200
[  244.476322]  [<c10848eb>] ? get_parent_ip+0xb/0x40
[  244.476325]  [<c1686142>] __ww_mutex_lock_interruptible+0x22/0x30
[  244.476343]  [<f8ddb7fb>] nouveau_gem_ioctl_pushbuf+0x68b/0x13c0 [nouveau]
[  244.476345]  [<c132d022>] ? debug_smp_processor_id+0x12/0x20
[  244.476348]  [<c1060283>] ? unpin_current_cpu+0x13/0x60
[  244.476365]  [<f8ddb170>] ? nouveau_gem_ioctl_new+0x1d0/0x1d0 [nouveau]
[  244.476373]  [<f891d137>] drm_ioctl+0x1b7/0x510 [drm]
[  244.476390]  [<f8ddb170>] ? nouveau_gem_ioctl_new+0x1d0/0x1d0 [nouveau]
[  244.476393]  [<c132d022>] ? debug_smp_processor_id+0x12/0x20
[  244.476395]  [<c1060283>] ? unpin_current_cpu+0x13/0x60
[  244.476397]  [<c1084e40>] ? migrate_enable+0xa0/0x1c0
[  244.476400]  [<c143f6b1>] ? __pm_runtime_resume+0x41/0x50
[  244.476417]  [<f8dd2707>] nouveau_drm_ioctl+0x47/0xb0 [nouveau]
[  244.476434]  [<f8dd26c0>] ? nouveau_pmops_thaw+0x20/0x20 [nouveau]
[  244.476436]  [<c11a9e82>] do_vfs_ioctl+0x2f2/0x4f0
[  244.476438]  [<c10c5132>] ? ktime_get_ts64+0x52/0x1a0
[  244.476441]  [<c10be330>] ? __remove_hrtimer+0xd0/0xd0
[  244.476443]  [<c11aa0e0>] SyS_ioctl+0x60/0x90
[  244.476446]  [<c1687d70>] sysenter_do_call+0x12/0x12

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

* Re: [ANNOUNCE] 3.18.7-rt2
  2015-02-24 16:19   ` Gustavo Bittencourt
@ 2015-02-24 17:50     ` Mike Galbraith
  2015-02-24 20:00       ` Gustavo Bittencourt
  2015-02-26  8:02     ` Mike Galbraith
  1 sibling, 1 reply; 11+ messages in thread
From: Mike Galbraith @ 2015-02-24 17:50 UTC (permalink / raw)
  To: Gustavo Bittencourt
  Cc: Sebastian Andrzej Siewior, linux-rt-users, LKML, Thomas Gleixner,
	rostedt, John Kacur

On Tue, 2015-02-24 at 13:19 -0300, Gustavo Bittencourt wrote:
> On Tue, Feb 24, 2015 at 10:41 AM, Mike Galbraith
> <umgwanakikbuti@gmail.com> wrote:
> > locking, ww_mutex: fix ww_mutex vs self-deadlock
> >
> > If the caller already holds the mutex, task_blocks_on_rt_mutex()
> > returns -EDEADLK, we proceed directly to rt_mutex_handle_deadlock()
> > where it's instant game over.
> >
> > Let ww_mutexes return EDEADLK/EALREADY as they want to instead.
> >
> > Signed-off-by: Mike Galbraith <umgwanakikbuti@gmail.com>
> > ---
> >  kernel/locking/rtmutex.c |   17 +++++++++++------
> >  1 file changed, 11 insertions(+), 6 deletions(-)
> >
> > --- a/kernel/locking/rtmutex.c
> > +++ b/kernel/locking/rtmutex.c
> 
> The deadlock returned after I applied this patch in v3.18.7-rt2. Here is my log:


Hrmph.  I definitely want your patch to die ;-)  It adds a whole new
dimension to ww_mutex that only now exists in -rt.  That's not good.  My
patchlet may not be perfect either, but it lets ww_mutex do that return
EALREADY business it's supposed to, vs going straight to while(1).  We
can't have it both ways, so I suppose I'll fire up my old Q6600 box
(that doesn't have annoying GTX980 that my userspace can't deal with DRM
wise), and see if I can chase the nouveau thing down.  I'm not all that
enthusiastic though, as there are or at least were other issues with
nouveau.  Sebastian reported some completely _missing_ locking IIRC,
that led to his box exploding. 

	-Mike



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

* Re: [ANNOUNCE] 3.18.7-rt2
  2015-02-24 17:50     ` Mike Galbraith
@ 2015-02-24 20:00       ` Gustavo Bittencourt
  2015-02-25  2:27         ` Mike Galbraith
  0 siblings, 1 reply; 11+ messages in thread
From: Gustavo Bittencourt @ 2015-02-24 20:00 UTC (permalink / raw)
  To: Mike Galbraith
  Cc: Sebastian Andrzej Siewior, linux-rt-users, LKML, Thomas Gleixner,
	Steven Rostedt, John Kacur

On Tue, Feb 24, 2015 at 2:50 PM, Mike Galbraith
<umgwanakikbuti@gmail.com> wrote:
> On Tue, 2015-02-24 at 13:19 -0300, Gustavo Bittencourt wrote:

>>
>> The deadlock returned after I applied this patch in v3.18.7-rt2. Here is my log:
>
>
> Hrmph.  I definitely want your patch to die ;-)  It adds a whole new
> dimension to ww_mutex that only now exists in -rt.  That's not good.

No problem.

> My
> patchlet may not be perfect either, but it lets ww_mutex do that return
> EALREADY business it's supposed to, vs going straight to while(1).  We
> can't have it both ways, so I suppose I'll fire up my old Q6600 box
> (that doesn't have annoying GTX980 that my userspace can't deal with DRM
> wise), and see if I can chase the nouveau thing down.  I'm not all that
> enthusiastic though, as there are or at least were other issues with
> nouveau.  Sebastian reported some completely _missing_ locking IIRC,
> that led to his box exploding.

Is there anyway that I could help? I think I can write a code to
reproduce the deadlock without the nouveau driver.

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

* Re: [ANNOUNCE] 3.18.7-rt2
  2015-02-24 20:00       ` Gustavo Bittencourt
@ 2015-02-25  2:27         ` Mike Galbraith
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Galbraith @ 2015-02-25  2:27 UTC (permalink / raw)
  To: Gustavo Bittencourt
  Cc: Sebastian Andrzej Siewior, linux-rt-users, LKML, Thomas Gleixner,
	Steven Rostedt, John Kacur

On Tue, 2015-02-24 at 17:00 -0300, Gustavo Bittencourt wrote:

> Is there anyway that I could help? I think I can write a code to
> reproduce the deadlock without the nouveau driver.

A non-drm testcase would be nice.  The people who decided that serial
ports could just _go away_ should be pelted mightily with frozen shark.

	-Mike



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

* Re: [ANNOUNCE] 3.18.7-rt2
  2015-02-24 16:19   ` Gustavo Bittencourt
  2015-02-24 17:50     ` Mike Galbraith
@ 2015-02-26  8:02     ` Mike Galbraith
  2015-02-26 10:53       ` Sebastian Andrzej Siewior
  2015-02-26 16:40       ` Gustavo Bittencourt
  1 sibling, 2 replies; 11+ messages in thread
From: Mike Galbraith @ 2015-02-26  8:02 UTC (permalink / raw)
  To: Gustavo Bittencourt
  Cc: Sebastian Andrzej Siewior, linux-rt-users, LKML, Thomas Gleixner,
	rostedt, John Kacur

On Tue, 2015-02-24 at 13:19 -0300, Gustavo Bittencourt wrote:

> The deadlock returned after I applied this patch in v3.18.7-rt2.

Grr, because dummy here munged a reject when he backported to 3.18-rt.
Please try the below, my trusty old Q6600 box is now running with
nouveau/drm in both 3.18-rt and 4.0-rt.

I found what was breaking my core2 lappy in 4.0-rt as well, namely the
rtmutex.c set_current_state() munging that went into mainline recently,
and that also broke my Q6600 box with nouveau/drm as well!  Seems you
need a slow box and drm to experience the breakage nice and repeatably,
which is kinda worrisome.  Anyway, all of my boxen can use drm just fine
in both rt trees now, so your box _should_ be happy too.

WRT nouveau locking, per lockdep it has at least one rt issue with or
without my patch. i915 OTOH runs lockdep clean.


locking, ww_mutex: fix ww_mutex vs self-deadlock

If the caller already holds the mutex, task_blocks_on_rt_mutex()
returns -EDEADLK, we proceed directly to rt_mutex_handle_deadlock()
where it's instant game over.

Let ww_mutexes return EDEADLK/EALREADY as they want to instead.

Signed-off-by: Mike Galbraith <umgwanakikbuti@gmail.com>
---
 kernel/locking/rtmutex.c |   24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -1706,15 +1706,21 @@ rt_mutex_slowlock(struct rt_mutex *lock,
 	ret = task_blocks_on_rt_mutex(lock, &waiter, current, chwalk);
 
 	if (likely(!ret))
-		ret = __rt_mutex_slowlock(lock, state, timeout, &waiter,
-					  ww_ctx);
+		ret = __rt_mutex_slowlock(lock, state, timeout, &waiter, ww_ctx);
+	else if (ww_ctx) {
+		/* ww_mutex received EDEADLK, let it become EALREADY */
+		ret = __mutex_lock_check_stamp(lock, ww_ctx);
+		BUG_ON(!ret);
+	}
 
 	set_current_state(TASK_RUNNING);
 
 	if (unlikely(ret)) {
 		if (rt_mutex_has_waiters(lock))
 			remove_waiter(lock, &waiter);
-		rt_mutex_handle_deadlock(ret, chwalk, &waiter);
+		/* ww_mutex want to report EDEADLK/EALREADY, let them */
+		if (!ww_ctx)
+			rt_mutex_handle_deadlock(ret, chwalk, &waiter);
 	} else if (ww_ctx) {
 		ww_mutex_account_lock(lock, ww_ctx);
 	}
@@ -2258,8 +2264,7 @@ __ww_mutex_lock_interruptible(struct ww_
 	might_sleep();
 
 	mutex_acquire_nest(&lock->base.dep_map, 0, 0, &ww_ctx->dep_map, _RET_IP_);
-	ret = rt_mutex_slowlock(&lock->base.lock, TASK_INTERRUPTIBLE, NULL,
-				RT_MUTEX_FULL_CHAINWALK, ww_ctx);
+	ret = rt_mutex_slowlock(&lock->base.lock, TASK_INTERRUPTIBLE, NULL, 0, ww_ctx);
 	if (ret)
 		mutex_release(&lock->base.dep_map, 1, _RET_IP_);
 	else if (!ret && ww_ctx->acquired > 1)
@@ -2277,8 +2282,7 @@ __ww_mutex_lock(struct ww_mutex *lock, s
 	might_sleep();
 
 	mutex_acquire_nest(&lock->base.dep_map, 0, 0, &ww_ctx->dep_map, _RET_IP_);
-	ret = rt_mutex_slowlock(&lock->base.lock, TASK_UNINTERRUPTIBLE, NULL,
-				RT_MUTEX_FULL_CHAINWALK, ww_ctx);
+	ret = rt_mutex_slowlock(&lock->base.lock, TASK_UNINTERRUPTIBLE, NULL, 0, ww_ctx);
 	if (ret)
 		mutex_release(&lock->base.dep_map, 1, _RET_IP_);
 	else if (!ret && ww_ctx->acquired > 1)
@@ -2290,11 +2294,13 @@ EXPORT_SYMBOL_GPL(__ww_mutex_lock);
 
 void __sched ww_mutex_unlock(struct ww_mutex *lock)
 {
+	int nest = !!lock->ctx;
+
 	/*
 	 * The unlocking fastpath is the 0->1 transition from 'locked'
 	 * into 'unlocked' state:
 	 */
-	if (lock->ctx) {
+	if (nest) {
 #ifdef CONFIG_DEBUG_MUTEXES
 		DEBUG_LOCKS_WARN_ON(!lock->ctx->acquired);
 #endif
@@ -2303,7 +2309,7 @@ void __sched ww_mutex_unlock(struct ww_m
 		lock->ctx = NULL;
 	}
 
-	mutex_release(&lock->base.dep_map, 1, _RET_IP_);
+	mutex_release(&lock->base.dep_map, nest, _RET_IP_);
 	rt_mutex_unlock(&lock->base.lock);
 }
 EXPORT_SYMBOL(ww_mutex_unlock);





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

* Re: [ANNOUNCE] 3.18.7-rt2
  2015-02-26  8:02     ` Mike Galbraith
@ 2015-02-26 10:53       ` Sebastian Andrzej Siewior
  2015-02-26 11:30         ` Mike Galbraith
  2015-02-26 16:40       ` Gustavo Bittencourt
  1 sibling, 1 reply; 11+ messages in thread
From: Sebastian Andrzej Siewior @ 2015-02-26 10:53 UTC (permalink / raw)
  To: Mike Galbraith
  Cc: Gustavo Bittencourt, linux-rt-users, LKML, Thomas Gleixner,
	rostedt, John Kacur

* Mike Galbraith | 2015-02-26 09:02:05 [+0100]:

>I found what was breaking my core2 lappy in 4.0-rt as well, namely the
4.0-rt? So you are a time traveler?

>locking, ww_mutex: fix ww_mutex vs self-deadlock
>
>If the caller already holds the mutex, task_blocks_on_rt_mutex()
>returns -EDEADLK, we proceed directly to rt_mutex_handle_deadlock()
>where it's instant game over.

The EDDEADLK / ELREADY seem to got broken duering the rtmutex rework.
Now I see:
| Wound/wait tests |
---------------------
                ww api failures:  ok  |  ok  |  ok  |
             ww contexts mixing:  ok  |  ok  |
           finishing ww context:  ok  |  ok  |  ok  |  ok  |
             locking mismatches:  ok  |  ok  |  ok  |
               EDEADLK handling:  ok  |  ok  |  ok  |  ok  |  ok  |  ok  |  ok  |  ok  |  ok  |  ok  |
         spinlock nest unlocked:  ok  |

with no backtrace from the ww code which I haven't seen before that
patch. Applied.

Sebastian

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

* Re: [ANNOUNCE] 3.18.7-rt2
  2015-02-26 10:53       ` Sebastian Andrzej Siewior
@ 2015-02-26 11:30         ` Mike Galbraith
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Galbraith @ 2015-02-26 11:30 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Gustavo Bittencourt, linux-rt-users, LKML, Thomas Gleixner,
	rostedt, John Kacur

On Thu, 2015-02-26 at 11:53 +0100, Sebastian Andrzej Siewior wrote:

> 4.0-rt? So you are a time traveler?

Nah, I just didn't want to stop at 3.18, so rolled forward to master.
When Linus switched to 4.0, I didn't have to do anything other than to
change the directory name :)  If you're interested, I can tar up the
tree and send it to you.  It might save you some keyboard time.

	-Mike


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

* Re: [ANNOUNCE] 3.18.7-rt2
  2015-02-26  8:02     ` Mike Galbraith
  2015-02-26 10:53       ` Sebastian Andrzej Siewior
@ 2015-02-26 16:40       ` Gustavo Bittencourt
  1 sibling, 0 replies; 11+ messages in thread
From: Gustavo Bittencourt @ 2015-02-26 16:40 UTC (permalink / raw)
  To: Mike Galbraith
  Cc: Sebastian Andrzej Siewior, linux-rt-users, LKML, Thomas Gleixner,
	Steven Rostedt, John Kacur

On Thu, Feb 26, 2015 at 5:02 AM, Mike Galbraith
<umgwanakikbuti@gmail.com> wrote:
> On Tue, 2015-02-24 at 13:19 -0300, Gustavo Bittencourt wrote:
>
>> The deadlock returned after I applied this patch in v3.18.7-rt2.
>
> Grr, because dummy here munged a reject when he backported to 3.18-rt.
> Please try the below, my trusty old Q6600 box is now running with
> nouveau/drm in both 3.18-rt and 4.0-rt.
>
> I found what was breaking my core2 lappy in 4.0-rt as well, namely the
> rtmutex.c set_current_state() munging that went into mainline recently,
> and that also broke my Q6600 box with nouveau/drm as well!  Seems you
> need a slow box and drm to experience the breakage nice and repeatably,
> which is kinda worrisome.  Anyway, all of my boxen can use drm just fine
> in both rt trees now, so your box _should_ be happy too.
>

Mike, my box is running very well now. Thanks.

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

end of thread, other threads:[~2015-02-26 16:40 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-23  9:06 [ANNOUNCE] 3.18.7-rt2 Sebastian Andrzej Siewior
2015-02-24 13:41 ` Mike Galbraith
2015-02-24 14:13   ` Mike Galbraith
2015-02-24 16:19   ` Gustavo Bittencourt
2015-02-24 17:50     ` Mike Galbraith
2015-02-24 20:00       ` Gustavo Bittencourt
2015-02-25  2:27         ` Mike Galbraith
2015-02-26  8:02     ` Mike Galbraith
2015-02-26 10:53       ` Sebastian Andrzej Siewior
2015-02-26 11:30         ` Mike Galbraith
2015-02-26 16:40       ` Gustavo Bittencourt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).