Thread (107 messages) 107 messages, 12 authors, 2007-04-21

Re: [PATCH] nfs: fix congestion control -v4

From: Peter Zijlstra <hidden>
Date: 2007-01-26 08:00:57
Also in: lkml

On Thu, 2007-01-25 at 21:02 -0800, Andrew Morton wrote:
On Thu, 25 Jan 2007 16:32:28 +0100
Peter Zijlstra [off-list ref] wrote:
quoted
+long congestion_wait_interruptible(int rw, long timeout)
+{
+	long ret;
+	DEFINE_WAIT(wait);
+	wait_queue_head_t *wqh = &congestion_wqh[rw];
+
+	prepare_to_wait(wqh, &wait, TASK_INTERRUPTIBLE);
+	if (signal_pending(current))
+		ret = -ERESTARTSYS;
+	else
+		ret = io_schedule_timeout(timeout);
+	finish_wait(wqh, &wait);
+	return ret;
+}
+EXPORT_SYMBOL(congestion_wait_interruptible);
I think this can share code with congestion_wait()?

static long __congestion_wait(int rw, long timeout, int state)
{
	long ret;
	DEFINE_WAIT(wait);
	wait_queue_head_t *wqh = &congestion_wqh[rw];

	prepare_to_wait(wqh, &wait, state);
	ret = io_schedule_timeout(timeout);
	finish_wait(wqh, &wait);
	return ret;
}

long congestion_wait_interruptible(int rw, long timeout)
{
	long ret = __congestion_wait(rw, timeout);

	if (signal_pending(current))
		ret = -ERESTARTSYS;
	return ret;
}

it's only infinitesimally less efficient..
All the other _interruptible functions check signal_pending before
calling schedule. Which seems to make sense since its called in a loop
anyway, and if the loop condition turns false when interrupted you might
as well just finish up instead of bailing out.

However if you'd rather see your version, who am I to object ;-)

--
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