mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: Andrew Morton <akpm@osdl.org>
Cc: viro@zeniv.linux.org.uk, dipankar@in.ibm.com,
	linux-kernel@vger.kernel.org
Subject: [PATCH] file: kill unnecessary timer in fdtable_defer
Date: Tue, 17 Oct 2006 20:16:34 +0900	[thread overview]
Message-ID: <20061017111634.GD13677@htj.dyndns.org> (raw)

free_fdtable_rc() schedules timer to reschedule fddef->wq if
schedule_work() on it returns 0.  However, schedule_work() guarantees
that the target work is executed at least once after the scheduling
regardless of its return value.  0 return simply means that the work
was already pending and thus no further action was required.

Another problem is that it used contant '5' as @expires argument to
mod_timer().

Kill unnecessary fddef->timer.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: Dipankar Sarma <dipankar@in.ibm.com>
---

This patch was first posted on August 20th.  The original thread can
be seen at the following URL.

http://thread.gmane.org/gmane.linux.kernel/438712/focus=438712

Dipankar objected but the discussion was dropped in the middle.
Please read the thread for more info.  I still think this patch is
correct.

Andrew, please push this patch through -mm if this looks correct.

Thanks.

 file.c |   29 ++---------------------------
  1 file changed, 2 insertions(+), 27 deletions(-)

diff --git a/fs/file.c b/fs/file.c
index 8e81775..d91db2c 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -21,7 +21,6 @@ #include <linux/workqueue.h>
 struct fdtable_defer {
 	spinlock_t lock;
 	struct work_struct wq;
-	struct timer_list timer;
 	struct fdtable *next;
 };
 
@@ -75,22 +74,6 @@ static void __free_fdtable(struct fdtabl
 	kfree(fdt);
 }
 
-static void fdtable_timer(unsigned long data)
-{
-	struct fdtable_defer *fddef = (struct fdtable_defer *)data;
-
-	spin_lock(&fddef->lock);
-	/*
-	 * If someone already emptied the queue return.
-	 */
-	if (!fddef->next)
-		goto out;
-	if (!schedule_work(&fddef->wq))
-		mod_timer(&fddef->timer, 5);
-out:
-	spin_unlock(&fddef->lock);
-}
-
 static void free_fdtable_work(struct fdtable_defer *f)
 {
 	struct fdtable *fdt;
@@ -142,13 +125,8 @@ static void free_fdtable_rcu(struct rcu_
 		spin_lock(&fddef->lock);
 		fdt->next = fddef->next;
 		fddef->next = fdt;
-		/*
-		 * vmallocs are handled from the workqueue context.
-		 * If the per-cpu workqueue is running, then we
-		 * defer work scheduling through a timer.
-		 */
-		if (!schedule_work(&fddef->wq))
-			mod_timer(&fddef->timer, 5);
+		/* vmallocs are handled from the workqueue context */
+		schedule_work(&fddef->wq);
 		spin_unlock(&fddef->lock);
 		put_cpu_var(fdtable_defer_list);
 	}
@@ -352,9 +330,6 @@ static void __devinit fdtable_defer_list
 	struct fdtable_defer *fddef = &per_cpu(fdtable_defer_list, cpu);
 	spin_lock_init(&fddef->lock);
 	INIT_WORK(&fddef->wq, (void (*)(void *))free_fdtable_work, fddef);
-	init_timer(&fddef->timer);
-	fddef->timer.data = (unsigned long)fddef;
-	fddef->timer.function = fdtable_timer;
 	fddef->next = NULL;
 }
 

             reply	other threads:[~2006-10-17 11:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-17 11:16 Tejun Heo [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-08-20 13:15 Tejun Heo
2006-08-21  4:32 ` Dipankar Sarma
2006-08-21  5:18   ` Tejun Heo
2006-08-21  7:58     ` Dipankar Sarma
2006-08-21  8:24       ` Tejun Heo
2006-09-22 15:46       ` Tejun Heo

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=20061017111634.GD13677@htj.dyndns.org \
    --to=htejun@gmail.com \
    --cc=akpm@osdl.org \
    --cc=dipankar@in.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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