mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Fengguang Wu <fengguang.wu@intel.com>
Cc: "Boqun Feng" <boqun.feng@gmail.com>,
	"Nicolai Hähnle" <Nicolai.Haehnle@amd.com>,
	"Chris Wilson" <chris@chris-wilson.co.uk>,
	"Ingo Molnar" <mingo@kernel.org>,
	linux-kernel@vger.kernel.org, LKP <lkp@01.org>
Subject: Re: [locking/ww_mutex] 2a0c112828 WARNING: CPU: 0 PID: 18 at kernel/locking/mutex.c:305 __ww_mutex_wakeup_for_backoff
Date: Wed, 1 Mar 2017 16:54:14 +0100	[thread overview]
Message-ID: <20170301155414.GN6515@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20170301154043.hcsbpgooc3kqt45j@wfg-t540p.sh.intel.com>

On Wed, Mar 01, 2017 at 11:40:43PM +0800, Fengguang Wu wrote:
> Thanks for the patch! I applied the patch on top of "locking/ww_mutex:
> Add kselftests for ww_mutex stress", and find no "bad unlock balance
> detected" but this warning. Attached is the new dmesg which is a bit
> large due to lots of repeated errors.

So with all the various patches it works for me.

I also have the following on top; which I did when I was looking through
this code trying to figure out wth was happening.

Chris, does this make sense to you?

It makes each loop a fully new 'instance', otherwise we'll never update
the ww_class->stamp and the threads will aways have the same order.

---

diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c
index da6c9a34f62f..d0fd06429c9d 100644
--- a/kernel/locking/test-ww_mutex.c
+++ b/kernel/locking/test-ww_mutex.c
@@ -398,12 +398,11 @@ static void stress_inorder_work(struct work_struct *work)
 	if (!order)
 		return;
 
-	ww_acquire_init(&ctx, &ww_class);
-
 	do {
 		int contended = -1;
 		int n, err;
 
+		ww_acquire_init(&ctx, &ww_class);
 retry:
 		err = 0;
 		for (n = 0; n < nlocks; n++) {
@@ -433,9 +432,9 @@ static void stress_inorder_work(struct work_struct *work)
 				    __func__, err);
 			break;
 		}
-	} while (--stress->nloops);
 
-	ww_acquire_fini(&ctx);
+		ww_acquire_fini(&ctx);
+	} while (--stress->nloops);
 
 	kfree(order);
 	kfree(stress);
@@ -470,9 +469,9 @@ static void stress_reorder_work(struct work_struct *work)
 	kfree(order);
 	order = NULL;
 
-	ww_acquire_init(&ctx, &ww_class);
-
 	do {
+		ww_acquire_init(&ctx, &ww_class);
+
 		list_for_each_entry(ll, &locks, link) {
 			err = ww_mutex_lock(ll->lock, &ctx);
 			if (!err)
@@ -495,9 +494,9 @@ static void stress_reorder_work(struct work_struct *work)
 		dummy_load(stress);
 		list_for_each_entry(ll, &locks, link)
 			ww_mutex_unlock(ll->lock);
-	} while (--stress->nloops);
 
-	ww_acquire_fini(&ctx);
+		ww_acquire_fini(&ctx);
+	} while (--stress->nloops);
 
 out:
 	list_for_each_entry_safe(ll, ln, &locks, link)

  parent reply	other threads:[~2017-03-01 15:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-27  5:14 Fengguang Wu
2017-02-27 10:28 ` Peter Zijlstra
2017-02-27 10:35   ` Peter Zijlstra
2017-03-01 15:01     ` Boqun Feng
2017-03-01 15:18       ` Peter Zijlstra
     [not found]       ` <20170301154043.hcsbpgooc3kqt45j@wfg-t540p.sh.intel.com>
2017-03-01 15:51         ` Peter Zijlstra
2017-03-01 15:55           ` Fengguang Wu
2017-03-01 15:54         ` Peter Zijlstra [this message]
2017-03-01 16:11           ` Chris Wilson
2017-03-01 16:26             ` Chris Wilson
2017-03-01 16:54               ` Peter Zijlstra
2017-03-01 17:39                 ` Fengguang Wu
2017-03-02  8:21       ` [tip:locking/urgent] locking/ww_mutex: Adjust the lock number for stress test tip-bot for Boqun Feng

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=20170301155414.GN6515@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=Nicolai.Haehnle@amd.com \
    --cc=boqun.feng@gmail.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=fengguang.wu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@01.org \
    --cc=mingo@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome