* [KJ] Re: [PATCH 14/21] net/s2io: replace schedule_timeout() with
2005-01-17 23:15 [KJ] RE: [PATCH 14/21] net/s2io: replace schedule_timeout() with Raghavendra Koushik
@ 2005-01-17 23:29 ` Nishanth Aravamudan
2005-02-09 18:37 ` [KJ] " Ravinandan Arakali
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Nishanth Aravamudan @ 2005-01-17 23:29 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1216 bytes --]
On Mon, Jan 17, 2005 at 03:15:05PM -0800, Raghavendra Koushik wrote:
> Correct me if Iam wrong, but isn't HZ always defined as
> "number of jiffies" on the machine that equals 1sec in duration.
> So even if duration of jiffy varies, Macro HZ is assured to be 1 sec.
> This way schedule_timeout (HZ / 2) on any machine is supposed to
> timeout after half a second and so on and so forth.
You are correct that timing out relative to HZ is ok. However, I would like to
remove this dependency wherever it exists. That way requesting a delay of
500 milliseconds can always be done via msleep() and if the behind-the-scenes
workings of schedule_timeout() change (for instance relative to tickless
systems), msleep() should still succeed.
There are some issues with the task states (more applicable to
TASK_INTERRUPTIBLE than TASK_UNINTERRUPTIBLE), but they are not relevant to your
code.
The patch really is more for consistency's sake. I don't want people to see your
driver and then assume they should use schedule_timeout() because someone else
has. msleep() is the preferred interface for longer unconditional delays. It
also makes it clearer that the sleep is for 500 msecs (e.g.) than HZ/2, IMO.
Thanks,
Nish
[-- 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] 8+ messages in thread* [KJ] RE: [PATCH 14/21] net/s2io: replace schedule_timeout() with
2005-01-17 23:15 [KJ] RE: [PATCH 14/21] net/s2io: replace schedule_timeout() with Raghavendra Koushik
2005-01-17 23:29 ` [KJ] " Nishanth Aravamudan
@ 2005-02-09 18:37 ` Ravinandan Arakali
2005-02-16 13:25 ` Domen Puncer
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Ravinandan Arakali @ 2005-02-09 18:37 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 6847 bytes --]
Nishanth,
We did some basic testing after applying your patch and it seems okay.
Pls submit the patch to maintainer. But I've couple of comments on
your patch.
The below code change is incorrect. It should be msleep(500).
> @@ -3808,8 +3797,7 @@ static int s2io_rldram_test(nic_t * sp,
> val64 = readq(&bar0->mc_rldram_test_ctrl);
> if (val64 & MC_RLDRAM_TEST_DONE)
> break;
> - set_current_state(TASK_UNINTERRUPTIBLE);
> - schedule_timeout(HZ / 2);
> + msleep(200);
In the function s2io_ethtool_idnic(), call to schedule_timeout() has not
been replaced with msleep(). I've given below the code change I did before
testing.
@@ -3284,11 +3277,10 @@
sp->id_timer.data = (unsigned long) sp;
}
mod_timer(&sp->id_timer, jiffies);
- set_current_state(TASK_INTERRUPTIBLE);
if (data)
- schedule_timeout(data * HZ);
+ msleep(data*1000);
else
- schedule_timeout(MAX_SCHEDULE_TIMEOUT);
+ msleep(0xFFFFFFFF);
del_timer_sync(&sp->id_timer);
if (CARDS_WITH_FAULTY_LINK_INDICATORS(subid)) {
Thanks,
Ravi
-----Original Message-----
From: Raghavendra Koushik [mailto:raghavendra.koushik@s2io.com]
Sent: Monday, January 17, 2005 3:15 PM
To: 'Nishanth Aravamudan'
Cc: kernel-janitors@lists.osdl.org; 'Ravinandan Arakali'
Subject: RE: [PATCH 14/21] net/s2io: replace schedule_timeout() with
msleep()
Correct me if Iam wrong, but isn't HZ always defined as
"number of jiffies" on the machine that equals 1sec in duration.
So even if duration of jiffy varies, Macro HZ is assured to be 1 sec.
This way schedule_timeout (HZ / 2) on any machine is supposed to
timeout after half a second and so on and so forth.
-Koushik
> -----Original Message-----
> From: Nishanth Aravamudan [mailto:nacc@us.ibm.com]
> Sent: Monday, January 17, 2005 3:06 PM
> To: raghavendra.koushik@s2io.com
> Cc: kernel-janitors@lists.osdl.org
> Subject: [PATCH 14/21] net/s2io: replace schedule_timeout()
> with msleep()
>
> Hi,
>
> Please consider applying.
>
> Description: Use msleep() instead of schedule_timeout() to
> guarantee the task
> delays as expected. This makes the code independent of HZ
> values (particularly
> important when HZ changes or is dynamic).
>
> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
>
>
> --- 2.6.11-rc1-kj-v/drivers/net/s2io.c 2005-01-15
> 16:55:41.000000000 -0800
> +++ 2.6.11-rc1-kj/drivers/net/s2io.c 2005-01-16
> 23:50:59.000000000 -0800
> @@ -684,8 +684,7 @@ static int init_nic(struct s2io_nic *nic
> val64 = 0;
> writeq(val64, &bar0->sw_reset);
> val64 = readq(&bar0->sw_reset);
> - set_current_state(TASK_UNINTERRUPTIBLE);
> - schedule_timeout(HZ / 2);
> + msleep(500);
>
> /* Enable Receiving broadcasts */
> add = (void *) &bar0->mac_cfg;
> @@ -938,8 +937,7 @@ static int init_nic(struct s2io_nic *nic
> dev->name);
> return -1;
> }
> - set_current_state(TASK_UNINTERRUPTIBLE);
> - schedule_timeout(HZ / 20);
> + msleep(50);
> time++;
> }
>
> @@ -977,8 +975,7 @@ static int init_nic(struct s2io_nic *nic
> return -1;
> }
> time++;
> - set_current_state(TASK_UNINTERRUPTIBLE);
> - schedule_timeout(HZ / 20);
> + msleep(50);
> }
>
> /*
> @@ -1407,8 +1404,7 @@ static int start_nic(struct s2io_nic *ni
> SPECIAL_REG_WRITE(val64, &bar0->mc_rldram_mrs, UF);
> val64 = readq(&bar0->mc_rldram_mrs);
>
> - set_current_state(TASK_UNINTERRUPTIBLE);
> - schedule_timeout(HZ / 10); /* Delay by around 100 ms. */
> + msleep(100); /* Delay by around 100 ms. */
>
> /* Enabling ECC Protection. */
> val64 = readq(&bar0->adapter_control);
> @@ -2423,8 +2419,7 @@ int wait_for_cmd_complete(nic_t * sp)
> ret = SUCCESS;
> break;
> }
> - set_current_state(TASK_UNINTERRUPTIBLE);
> - schedule_timeout(HZ / 20);
> + msleep(50);
> if (cnt++ > 10)
> break;
> }
> @@ -2463,15 +2458,13 @@ void s2io_reset(nic_t * sp)
> * As of now I'am just giving a 250ms delay and hoping that the
> * PCI write to sw_reset register is done by this time.
> */
> - set_current_state(TASK_UNINTERRUPTIBLE);
> - schedule_timeout(HZ / 4);
> + msleep(250);
>
> /* Restore the PCI state saved during initializarion. */
> pci_restore_state(sp->pdev);
> s2io_init_pci(sp);
>
> - set_current_state(TASK_UNINTERRUPTIBLE);
> - schedule_timeout(HZ / 4);
> + msleep(250);
>
> /* SXE-002: Configure link and activity LED to turn it off */
> subid = sp->pdev->subsystem_device;
> @@ -3391,8 +3384,7 @@ static int read_eeprom(nic_t * sp, int o
> ret = 0;
> break;
> }
> - set_current_state(TASK_UNINTERRUPTIBLE);
> - schedule_timeout(HZ / 20);
> + msleep(50);
> exit_cnt++;
> }
>
> @@ -3432,8 +3424,7 @@ static int write_eeprom(nic_t * sp, int
> ret = 0;
> break;
> }
> - set_current_state(TASK_UNINTERRUPTIBLE);
> - schedule_timeout(HZ / 20);
> + msleep(50);
> exit_cnt++;
> }
>
> @@ -3689,8 +3680,7 @@ static int s2io_bist_test(nic_t * sp, ui
> ret = 0;
> break;
> }
> - set_current_state(TASK_UNINTERRUPTIBLE);
> - schedule_timeout(HZ / 10);
> + msleep(100);
> cnt++;
> }
>
> @@ -3791,8 +3781,7 @@ static int s2io_rldram_test(nic_t * sp,
> val64 = readq(&bar0->mc_rldram_test_ctrl);
> if (val64 & MC_RLDRAM_TEST_DONE)
> break;
> - set_current_state(TASK_UNINTERRUPTIBLE);
> - schedule_timeout(HZ / 5);
> + msleep(200);
> }
>
> if (cnt == 5)
> @@ -3808,8 +3797,7 @@ static int s2io_rldram_test(nic_t * sp,
> val64 = readq(&bar0->mc_rldram_test_ctrl);
> if (val64 & MC_RLDRAM_TEST_DONE)
> break;
> - set_current_state(TASK_UNINTERRUPTIBLE);
> - schedule_timeout(HZ / 2);
> + msleep(200);
> }
>
> if (cnt == 5)
> @@ -4169,8 +4157,7 @@ static void s2io_set_link(unsigned long
> * Allow a small delay for the NICs self initiated
> * cleanup to complete.
> */
> - set_current_state(TASK_UNINTERRUPTIBLE);
> - schedule_timeout(HZ / 10);
> + msleep(100);
>
> val64 = readq(&bar0->adapter_status);
> if (verify_xena_quiescence(val64, nic->device_enabled_once)) {
> @@ -4224,10 +4211,8 @@ static void s2io_card_down(nic_t * sp)
> register u64 val64 = 0;
>
> /* If s2io_set_link task is executing, wait till it
> completes. */
> - while (test_and_set_bit(0, &(sp->link_state))) {
> - set_current_state(TASK_UNINTERRUPTIBLE);
> - schedule_timeout(HZ / 20);
> - }
> + while (test_and_set_bit(0, &(sp->link_state)))
> + msleep(50);
> atomic_set(&sp->card_state, CARD_DOWN);
>
> /* disable Tx and Rx traffic on the NIC */
> @@ -4243,8 +4228,7 @@ static void s2io_card_down(nic_t * sp)
> break;
> }
>
> - set_current_state(TASK_UNINTERRUPTIBLE);
> - schedule_timeout(HZ / 20);
> + msleep(50);
> cnt++;
> if (cnt == 10) {
> DBG_PRINT(ERR_DBG,
>
[-- 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] 8+ messages in thread* Re: [KJ] RE: [PATCH 14/21] net/s2io: replace schedule_timeout() with
2005-01-17 23:15 [KJ] RE: [PATCH 14/21] net/s2io: replace schedule_timeout() with Raghavendra Koushik
2005-01-17 23:29 ` [KJ] " Nishanth Aravamudan
2005-02-09 18:37 ` [KJ] " Ravinandan Arakali
@ 2005-02-16 13:25 ` Domen Puncer
2005-02-16 14:31 ` Domen Puncer
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Domen Puncer @ 2005-02-16 13:25 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1068 bytes --]
On 09/02/05 10:37 -0800, Ravinandan Arakali wrote:
> Nishanth,
> We did some basic testing after applying your patch and it seems okay.
...
>
> In the function s2io_ethtool_idnic(), call to schedule_timeout() has not
> been replaced with msleep(). I've given below the code change I did before
> testing.
>
> @@ -3284,11 +3277,10 @@
> sp->id_timer.data = (unsigned long) sp;
> }
> mod_timer(&sp->id_timer, jiffies);
> - set_current_state(TASK_INTERRUPTIBLE);
> if (data)
> - schedule_timeout(data * HZ);
> + msleep(data*1000);
> else
> - schedule_timeout(MAX_SCHEDULE_TIMEOUT);
> + msleep(0xFFFFFFFF);
Was this code path tested too? It looks weird, as msleep _will_ sleep
for almost a day.
I don't know ethtool, but might this 'idnic' with undefined sleep time
just wait for ctrl+c for example? If that is so, msleep_interruptible
is what you want.
> del_timer_sync(&sp->id_timer);
>
> if (CARDS_WITH_FAULTY_LINK_INDICATORS(subid)) {
>
[-- 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] 8+ messages in thread* Re: [KJ] RE: [PATCH 14/21] net/s2io: replace schedule_timeout() with
2005-01-17 23:15 [KJ] RE: [PATCH 14/21] net/s2io: replace schedule_timeout() with Raghavendra Koushik
` (2 preceding siblings ...)
2005-02-16 13:25 ` Domen Puncer
@ 2005-02-16 14:31 ` Domen Puncer
2005-02-16 23:54 ` Ravinandan Arakali
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Domen Puncer @ 2005-02-16 14:31 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 373 bytes --]
On 16/02/05 14:25 +0100, Domen Puncer wrote:
> On 09/02/05 10:37 -0800, Ravinandan Arakali wrote:
> > - schedule_timeout(MAX_SCHEDULE_TIMEOUT);
> > + msleep(0xFFFFFFFF);
>
> Was this code path tested too? It looks weird, as msleep _will_ sleep
> for almost a day.
That was a bad miscalculation... almost 50 days should be more right.
Domen
[-- 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] 8+ messages in thread* RE: [KJ] RE: [PATCH 14/21] net/s2io: replace schedule_timeout() with
2005-01-17 23:15 [KJ] RE: [PATCH 14/21] net/s2io: replace schedule_timeout() with Raghavendra Koushik
` (3 preceding siblings ...)
2005-02-16 14:31 ` Domen Puncer
@ 2005-02-16 23:54 ` Ravinandan Arakali
2005-02-17 0:13 ` Nishanth Aravamudan
2005-02-17 0:24 ` Ravinandan Arakali
6 siblings, 0 replies; 8+ messages in thread
From: Ravinandan Arakali @ 2005-02-16 23:54 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1718 bytes --]
Domen,
Thanks for pointing that out. As you mention, the intention is
indeed to wait for Ctrl+C.
Nishanth, are you planning to modify it to msleep_interruptible().
If so, pls note that I submitted a Multicast fix after your below
patch. Pls apply multicast patch before changing to msleep_interruptible().
Ravi
-----Original Message-----
From: Domen Puncer [mailto:domen@coderock.org]
Sent: Wednesday, February 16, 2005 5:26 AM
To: Ravinandan Arakali
Cc: 'Raghavendra Koushik'; 'Nishanth Aravamudan';
kernel-janitors@lists.osdl.org; leonid.grossman@neterion.com
Subject: Re: [KJ] RE: [PATCH 14/21] net/s2io: replace schedule_timeout()
with msleep()
On 09/02/05 10:37 -0800, Ravinandan Arakali wrote:
> Nishanth,
> We did some basic testing after applying your patch and it seems okay.
...
>
> In the function s2io_ethtool_idnic(), call to schedule_timeout() has not
> been replaced with msleep(). I've given below the code change I did before
> testing.
>
> @@ -3284,11 +3277,10 @@
> sp->id_timer.data = (unsigned long) sp;
> }
> mod_timer(&sp->id_timer, jiffies);
> - set_current_state(TASK_INTERRUPTIBLE);
> if (data)
> - schedule_timeout(data * HZ);
> + msleep(data*1000);
> else
> - schedule_timeout(MAX_SCHEDULE_TIMEOUT);
> + msleep(0xFFFFFFFF);
Was this code path tested too? It looks weird, as msleep _will_ sleep
for almost a day.
I don't know ethtool, but might this 'idnic' with undefined sleep time
just wait for ctrl+c for example? If that is so, msleep_interruptible
is what you want.
> del_timer_sync(&sp->id_timer);
>
> if (CARDS_WITH_FAULTY_LINK_INDICATORS(subid)) {
>
[-- 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] 8+ messages in thread* Re: [KJ] RE: [PATCH 14/21] net/s2io: replace schedule_timeout() with
2005-01-17 23:15 [KJ] RE: [PATCH 14/21] net/s2io: replace schedule_timeout() with Raghavendra Koushik
` (4 preceding siblings ...)
2005-02-16 23:54 ` Ravinandan Arakali
@ 2005-02-17 0:13 ` Nishanth Aravamudan
2005-02-17 0:24 ` Ravinandan Arakali
6 siblings, 0 replies; 8+ messages in thread
From: Nishanth Aravamudan @ 2005-02-17 0:13 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 534 bytes --]
On Wed, Feb 16, 2005 at 03:54:06PM -0800, Ravinandan Arakali wrote:
> Domen,
> Thanks for pointing that out. As you mention, the intention is
> indeed to wait for Ctrl+C.
> Nishanth, are you planning to modify it to msleep_interruptible().
> If so, pls note that I submitted a Multicast fix after your below
> patch. Pls apply multicast patch before changing to msleep_interruptible().
I would be happy to send an incremental fix, but I don't seem to have a
copy of your multicast patch at hand. Could you send me one?
Thanks,
Nish
[-- 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] 8+ messages in thread* RE: [KJ] RE: [PATCH 14/21] net/s2io: replace schedule_timeout() with
2005-01-17 23:15 [KJ] RE: [PATCH 14/21] net/s2io: replace schedule_timeout() with Raghavendra Koushik
` (5 preceding siblings ...)
2005-02-17 0:13 ` Nishanth Aravamudan
@ 2005-02-17 0:24 ` Ravinandan Arakali
6 siblings, 0 replies; 8+ messages in thread
From: Ravinandan Arakali @ 2005-02-17 0:24 UTC (permalink / raw)
To: kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 907 bytes --]
Will forward you the patch.
Ravi
-----Original Message-----
From: Nishanth Aravamudan [mailto:nacc@us.ibm.com]
Sent: Wednesday, February 16, 2005 4:13 PM
To: Ravinandan Arakali
Cc: 'Domen Puncer'; 'Raghavendra Koushik';
kernel-janitors@lists.osdl.org; leonid.grossman@neterion.com
Subject: Re: [KJ] RE: [PATCH 14/21] net/s2io: replace schedule_timeout()
with msleep()
On Wed, Feb 16, 2005 at 03:54:06PM -0800, Ravinandan Arakali wrote:
> Domen,
> Thanks for pointing that out. As you mention, the intention is
> indeed to wait for Ctrl+C.
> Nishanth, are you planning to modify it to msleep_interruptible().
> If so, pls note that I submitted a Multicast fix after your below
> patch. Pls apply multicast patch before changing to
msleep_interruptible().
I would be happy to send an incremental fix, but I don't seem to have a
copy of your multicast patch at hand. Could you send me one?
Thanks,
Nish
[-- 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] 8+ messages in thread