Thread (51 messages) 51 messages, 4 authors, 2017-01-19

Re: [PATCH v4 07/15] lockdep: Implement crossrelease feature

From: Peter Zijlstra <peterz@infradead.org>
Date: 2017-01-17 07:12:55
Also in: lkml

On Tue, Jan 17, 2017 at 11:05:42AM +0900, Byungchul Park wrote:
On Mon, Jan 16, 2017 at 04:10:01PM +0100, Peter Zijlstra wrote:
quoted
On Fri, Dec 09, 2016 at 02:12:03PM +0900, Byungchul Park wrote:
quoted
quoted
+
+	/*
+	 * Whenever irq happens, these are updated so that we can
+	 * distinguish each irq context uniquely.
+	 */
+	unsigned int		hardirq_id;
+	unsigned int		softirq_id;
An alternative approach would be to 'unwind' or discard all historical
events from a nested context once we exit it.
That's one of what I considered. However, it would make code complex to
detect if pend_lock ring buffer was wrapped.
I'm not sure I see the need for detecting that...
quoted
After all, all we care about is the history of the release context, once
the context is gone, we don't care.
We must care it and decide if the next plock in the ring buffer might be
valid one or not.
So I was thinking this was an overwriting ring buffer; something like
so:

struct pend_lock plocks[64];
unsigned int plocks_idx;

static void plocks_add(..)
{
	unsigned int idx = (plocks_idx++) % 64;

	plocks[idx] = ...;
}

static void plocks_close_context(int ctx)
{
	for (i = 0; i < 64; i++) {
		int idx = (plocks_idx - 1) % 64;
		if (plocks[idx].ctx != ctx)
			break;

		plocks_idx--;
	}
}

Similarly for the release, it need only look at 64 entries and terminate
early if the generation number is too old.

static void plocks_release(unsigned int gen)
{
	for (i = 0; i < 64; i++) {
		int idx = (plocks_idx - 1 - i) % 64;
		if ((int)(plocks[idx].gen_id - gen) < 0)
			break;

		/* do release muck */
	}
}

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help