* [KJ] [PATCH 5/20] net/pktgen: remove interruptible_sleep_on_timeout() usage
@ 2005-02-02 18:58 Nishanth Aravamudan
2005-02-03 15:24 ` Robert Olsson
0 siblings, 1 reply; 2+ messages in thread
From: Nishanth Aravamudan @ 2005-02-02 18:58 UTC (permalink / raw)
To: robert.olsson; +Cc: netdev, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 2763 bytes --]
Hello,
The first and last replacements in the following patch were slightly confusing
to me, as I have not used wait-queues that much myself. I did not exactly
understand how a locally defined wait-queue could be slept on, especially since
there are no wake_up() calls in pktgen.c. I was tempted to make the first sleep
a msleep_interruptible(100), but decided to patch for the same code before I did
that.
Description: Replace deprecated interruptible_sleep_on_timeout() with direct
wait-queue usage or wait_event_interruptible_timeout() as appropriate.
Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
--- 2.6.11-rc2-kj-v/net/core/pktgen.c 2005-01-24 09:34:21.000000000 -0800
+++ 2.6.11-rc2-kj/net/core/pktgen.c 2005-02-02 10:57:02.000000000 -0800
@@ -135,6 +135,7 @@
#include <linux/ipv6.h>
#include <linux/udp.h>
#include <linux/proc_fs.h>
+#include <linux/wait.h>
#include <net/checksum.h>
#include <net/ipv6.h>
#include <net/addrconf.h>
@@ -2409,16 +2410,18 @@ static int running(struct pktgen_thread
static int pktgen_wait_thread_run(struct pktgen_thread *t )
{
- wait_queue_head_t queue;
-
- init_waitqueue_head(&queue);
-
+ DEFINE_WAIT(wait);
+ wait_queue_head_t queue;
+ init_waitqueue_head(&queue);
+
if_lock(t);
while(running(t)) {
if_unlock(t);
-
- interruptible_sleep_on_timeout(&queue, HZ/10);
+
+ prepare_to_wait(&queue, &wait, TASK_INTERRUPTIBLE);
+ schedule_timeout(HZ/10);
+ finish_wait(&queue, &wait);
if (signal_pending(current))
goto signal;
if_lock(t);
@@ -2738,6 +2741,7 @@ __inline__ void pktgen_xmit(struct pktge
static void pktgen_thread_worker(struct pktgen_thread *t)
{
+ DEFINE_WAIT(wait);
struct pktgen_dev *pkt_dev = NULL;
int cpu = t->cpu;
sigset_t tmpsig;
@@ -2805,9 +2809,11 @@ static void pktgen_thread_worker(struct
do_softirq();
tx_since_softirq = 0;
}
+ } else {
+ prepare_to_wait(&(t->queue), &wait, TASK_INTERRUPTIBLE);
+ schedule_timeout(HZ/10);
+ finish_wait(&(t->queue), &wait);
}
- else
- interruptible_sleep_on_timeout(&(t->queue), HZ/10);
/*
* Back from sleep, either due to the timeout or signal.
@@ -3118,8 +3124,7 @@ static void __exit pg_cleanup(void)
struct pktgen_thread *t = pktgen_threads;
pktgen_threads->control |= (T_TERMINATE);
- while( t == pktgen_threads)
- interruptible_sleep_on_timeout(&queue, HZ);
+ wait_event_interruptible_timeout(queue, (t != pktgen_threads), HZ);
}
/* Un-register us from receiving netdevice events */
[-- Attachment #2: Type: text/plain, Size: 167 bytes --]
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 2+ messages in thread* [PATCH 5/20] net/pktgen: remove interruptible_sleep_on_timeout() usage
2005-02-02 18:58 [KJ] [PATCH 5/20] net/pktgen: remove interruptible_sleep_on_timeout() usage Nishanth Aravamudan
@ 2005-02-03 15:24 ` Robert Olsson
0 siblings, 0 replies; 2+ messages in thread
From: Robert Olsson @ 2005-02-03 15:24 UTC (permalink / raw)
To: Nishanth Aravamudan; +Cc: davem, robert.olsson, netdev, kernel-janitors
Nishanth Aravamudan writes:
> The first and last replacements in the following patch were slightly confusing
> to me, as I have not used wait-queues that much myself. I did not exactly
> understand how a locally defined wait-queue could be slept on, especially since
> there are no wake_up() calls in pktgen.c. I was tempted to make the first sleep
> a msleep_interruptible(100), but decided to patch for the same code before I did
> that.
>
> Description: Replace deprecated interruptible_sleep_on_timeout() with direct
> wait-queue usage or wait_event_interruptible_timeout() as appropriate.
Tbanks!
I've tested the patch w. msleep_interruptible(). It seems fine.
Dave. This is on top of a patch I sent some days ago..
--ro
--- net/core/pktgen.c.050201 2005-02-03 14:38:33.337577424 +0100
+++ net/core/pktgen.c 2005-02-03 15:44:22.959143680 +0100
@@ -104,6 +104,8 @@
* Corrections from Nikolai Malykh (nmalykh@bilim.com)
* Removed unused flags F_SET_SRCMAC & F_SET_SRCIP 041230
*
+ * interruptible_sleep_on_timeout() replaced Nishanth Aravamudan <nacc@us.ibm.com>
+ * 050103
*/
#include <linux/sys.h>
#include <linux/types.h>
@@ -135,6 +137,7 @@
#include <linux/ipv6.h>
#include <linux/udp.h>
#include <linux/proc_fs.h>
+#include <linux/wait.h>
#include <net/checksum.h>
#include <net/ipv6.h>
#include <net/addrconf.h>
@@ -148,7 +151,7 @@
#include <asm/timex.h>
-#define VERSION "pktgen v2.56: Packet Generator for packet performance testing.\n"
+#define VERSION "pktgen v2.57: Packet Generator for packet performance testing.\n"
/* #define PG_DEBUG(a) a */
#define PG_DEBUG(a)
@@ -2402,16 +2405,14 @@
static int pktgen_wait_thread_run(struct pktgen_thread *t )
{
- wait_queue_head_t queue;
-
- init_waitqueue_head(&queue);
-
if_lock(t);
while(thread_is_running(t)) {
+
if_unlock(t);
-
- interruptible_sleep_on_timeout(&queue, HZ/10);
+
+ msleep_interruptible(100);
+
if (signal_pending(current))
goto signal;
if_lock(t);
@@ -2733,6 +2734,7 @@
static void pktgen_thread_worker(struct pktgen_thread *t)
{
+ DEFINE_WAIT(wait);
struct pktgen_dev *pkt_dev = NULL;
int cpu = t->cpu;
sigset_t tmpsig;
@@ -2800,9 +2802,11 @@
do_softirq();
tx_since_softirq = 0;
}
+ } else {
+ prepare_to_wait(&(t->queue), &wait, TASK_INTERRUPTIBLE);
+ schedule_timeout(HZ/10);
+ finish_wait(&(t->queue), &wait);
}
- else
- interruptible_sleep_on_timeout(&(t->queue), HZ/10);
/*
* Back from sleep, either due to the timeout or signal.
@@ -3112,8 +3116,7 @@
struct pktgen_thread *t = pktgen_threads;
pktgen_threads->control |= (T_TERMINATE);
- while( t == pktgen_threads)
- interruptible_sleep_on_timeout(&queue, HZ);
+ wait_event_interruptible_timeout(queue, (t != pktgen_threads), HZ);
}
/* Un-register us from receiving netdevice events */
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-02-03 15:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-02 18:58 [KJ] [PATCH 5/20] net/pktgen: remove interruptible_sleep_on_timeout() usage Nishanth Aravamudan
2005-02-03 15:24 ` Robert Olsson
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).