Skip to contentSkip to conversation

Replaces yield() with schedule_timeout()

PATCH In review Gustavo Franco 5 participants 12 messages Apr 24, 2004 – Apr 28, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Replaces yield() with schedule_timeout()

Hi list,

Following what i've said, i'm looking each yield() call to check if it needs to be
replaced.I'll send two more patches today and a status message, if everything
is ok, i'm planning to complete this task on the next week.

Thanks,
Gustavo Franco

scsi/megaraid.c 2004-04-24 13:54:36.000000000 -0300 renamed from scsi/megaraid.c.orig 2004-04-24 13:54:26.000000000 -0300 +1 -1
@@ -1691,7 +1691,7 @@
        for (counter = 0; counter < 10000; counter++) {
                if (!mbox->m_in.busy)
                        return 0;
-               udelay(100); yield();
+               udelay(100); schedule_timeout(1);
        }
        return -1;              /* give up after 1 second */
 }

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#1 lore raw

PATCH 1/1 Replaces yield() with schedule_timeout()

Hi list,

I guess that it's ok, please apply.

Thanks,
Gustavo Franco

net/sb1000.c 2004-04-24 13:47:01.000000000 -0300 renamed from net/sb1000.c.orig 2004-04-24 13:46:26.000000000 -0300 +1 -1
@@ -271,7 +271,7 @@
        timeout = jiffies + TimeOutJiffies;
        while (a & 0x80 || a & 0x40) {
                /* a little sleep */
-               yield();
+               schedule_timeout(1);
                                                                                                 
 
                a = inb(ioaddr[0] + 7);
                if (time_after_eq(jiffies, timeout)) {
@@ -295,7 +295,7 @@
        timeout = jiffies + TimeOutJiffies;
        while (a & 0x80 || !(a & 0x40)) {
                /* a little sleep */

- yield();
+ schedule_timeout(1);

                a = inb(ioaddr[1] + 6);
                if (time_after_eq(jiffies, timeout)) {

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#2 lore raw

PATCH 1/1 Replaces yield() with schedule_timeout()

In reply to Gustavo Franco

Hi list,

I guess that it's ok, please apply.

Thanks,
Gustavo Franco

cdrom/sonycd535.c 2004-04-24 13:47:38.000000000 -0300 renamed from cdrom/sonycd535.c.orig 2004-04-24 13:46:28.000000000 -0300 +1 -1
@@ -342,7 +342,7 @@
 sony_sleep(void)
 {
        if (sony535_irq_used <= 0) {    /* poll */
-               yield();
+               schedule_timeout(1);
        } else {        /* Interrupt driven */
                DEFINE_WAIT(wait);
 

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#3 lore raw

Re: [Kernel-janitors] [PATCH] Replaces yield() with

In reply to Gustavo Franco
Quoted 14 lines · Gustavo Franco

Hi list,

Following what i've said, i'm looking each yield() call to check if it needs to be
replaced.I'll send two more patches today and a status message, if everything
is ok, i'm planning to complete this task on the next week.

Thanks,
Gustavo Franco

scsi/megaraid.c 2004-04-24 13:54:36.000000000 -0300 line 1694

Quoted 5 lines
scsi/megaraid.c 2004-04-24 13:54:36.000000000 -0300 renamed from scsi/megaraid.c.orig 2004-04-24 13:54:26.000000000 -0300 +1 -1
@@ -1691,7 +1691,7 @@
       for (counter = 0; counter < 10000; counter++) {
               if (!mbox->m_in.busy)
                       return 0;
-               udelay(100); yield();
+               udelay(100); schedule_timeout(1);

This makes no sense to me.
schedule without set_current_state (also missing in other patches); Why leave udelay?

How about something like:

	for (counter = 0; counter < 1000; counter++) {
		if (!mbox->m_in.busy)
			return 0;
		set_current_state(TASK_INTERRUPTIBLE);
		schedule_timeout(1);

counter < 1000 test is on purpose, to get >= 1 second, not 10.

Comments?

Domen

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#4 lore raw
In reply to Gustavo Franco
Quoted 27 lines · Domen Puncer
Quoted 12 lines · Gustavo Franco

Hi list,

Following what i've said, i'm looking each yield() call to check if it needs to be replaced.I'll send two more patches today and a status message, if everything is ok, i'm planning to complete this task on the next week.

Thanks,
Gustavo Franco

scsi/megaraid.c 2004-04-24 13:54:36.000000000 -0300 line 1696

Quoted 7 lines
scsi/megaraid.c 2004-04-24 13:54:36.000000000 -0300 renamed from scsi/megaraid.c.orig 2004-04-24 13:54:26.000000000 -0300 +1 -1
@@ -1691,7 +1691,7 @@
      for (counter = 0; counter < 10000; counter++) {
              if (!mbox->m_in.busy)
                      return 0;
-               udelay(100); yield();
+               udelay(100); schedule_timeout(1);
 
 

This makes no sense to me.
schedule without set_current_state (also missing in other patches); Why leave udelay?

Quoted 11 lines

How about something like:

	for (counter = 0; counter < 1000; counter++) {
		if (!mbox->m_in.busy)
			return 0;
		set_current_state(TASK_INTERRUPTIBLE);
		schedule_timeout(1);

counter < 1000 test is on purpose, to get >= 1 second, not 10.

Hi Domen,

My failure, i haven't checked if the set_current_state() was really needed.I'm working on the TODO item "Calling yield() Considered Harmful" written by Matthew Wilcox.Since set_current_state() isn't cited by him and wasn't by Randy, i'll wait until Randy ask for rediffied patches.Randy?

Thanks,
Gustavo Franco

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#5 lore raw

Re: [Kernel-janitors] [PATCH] Replaces yield() with

In reply to Gustavo Franco

On Sun, 25 Apr 2004 20:10:41 -0300 Gustavo Franco <[email protected]> wrote:

| Domen Puncer wrote:
| 
| >On Sat, Apr 24, 2004 at 03:34:44PM -0300, Gustavo Franco wrote:
| >  
| >
| >>Hi list,
| >>
| >>Following what i've said, i'm looking each yield() call to check if it 
| >>needs to be
| >>replaced.I'll send two more patches today and a status message, if 
| >>everything
| >>is ok, i'm planning to complete this task on the next week.
| >>
| >>Thanks,
| >>Gustavo Franco
| >>
| >>--- drivers/scsi/megaraid.c.orig     2004-04-24 13:54:26.000000000 -0300
| >>+++ drivers/scsi/megaraid.c  2004-04-24 13:54:36.000000000 -0300
| >>@@ -1691,7 +1691,7 @@
| >>       for (counter = 0; counter < 10000; counter++) {
| >>               if (!mbox->m_in.busy)
| >>                       return 0;
| >>-               udelay(100); yield();
| >>+               udelay(100); schedule_timeout(1);
| >>    
| >>
| >
| >This makes no sense to me.
| >schedule without set_current_state (also missing in other patches);
| >Why leave udelay?
| >
| >How about something like:
| >	for (counter = 0; counter < 1000; counter++) {
| >		if (!mbox->m_in.busy)
| >			return 0;
| >		set_current_state(TASK_INTERRUPTIBLE);
| >		schedule_timeout(1);
| >
| >counter < 1000 test is on purpose, to get >= 1 second, not 10.
| >
| >  
| >
| Hi Domen,
| 
| My failure, i haven't checked if the set_current_state() was really 
| needed.I'm working
| on the TODO item "Calling yield() Considered Harmful" written by Matthew 
| Wilcox.Since
| set_current_state() isn't cited by him and wasn't by Randy, i'll wait 
| until Randy ask for rediffied
| patches.Randy?

Yes, looks like Domen is correct. He's right about the source code comment. Then I looked at 25 source files that use schedule_timeout() and all of them set current state first.

I'll update the TODO list with this info.

Thanks, all.

--
~Randy

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#6 lore raw
In reply to Gustavo Franco
Quoted 6 lines · Randy.Dunlap
| Hi Domen,
| | My failure, i haven't checked if the set_current_state() was really | needed.I'm working
| on the TODO item "Calling yield() Considered Harmful" written by Matthew | Wilcox.Since
| set_current_state() isn't cited by him and wasn't by Randy, i'll wait | until Randy ask for rediffied
| patches.Randy?
Quoted 8 lines

Yes, looks like Domen is correct. He's right about the source code comment. Then I looked at 25 source files that use schedule_timeout() and all of them set current state first.

I'll update the TODO list with this info.

Randy,

So, do you need "rediffied" patches with set_current_state() calls, right?

Thanks,
Gustavo Franco

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#7 lore raw

Re: [Kernel-janitors] [PATCH] Replaces yield() with

In reply to Gustavo Franco

On Sun, 25 Apr 2004 21:47:33 -0300 Gustavo Franco <[email protected]> wrote:

| Randy.Dunlap wrote:
| 
| >| Hi Domen,
| >| 
| >| My failure, i haven't checked if the set_current_state() was really 
| >| needed.I'm working
| >| on the TODO item "Calling yield() Considered Harmful" written by Matthew 
| >| Wilcox.Since
| >| set_current_state() isn't cited by him and wasn't by Randy, i'll wait 
| >| until Randy ask for rediffied
| >| patches.Randy?
| >
| >Yes, looks like Domen is correct.  He's right about the source code comment.
| >Then I looked at 25 source files that use schedule_timeout() and all of
| >them set current state first.
| >
| >I'll update the TODO list with this info.
| >
| >  
| >
| Randy,
| 
| So, do you need "rediffied" patches with set_current_state() calls, right?

Oh, yes, sorry I wasn't clear about that.

Thanks,
--
~Randy

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#8 lore raw
In reply to Gustavo Franco
	Hi,
Quoted 9 lines · Gustavo Franco

I guess that it's ok, please apply.

Thanks,
Gustavo Franco

cdrom/sonycd535.c 2004-04-24 13:47:38.000000000 -0300 line 345

Quoted 5 lines
cdrom/sonycd535.c 2004-04-24 13:47:38.000000000 -0300 renamed from cdrom/sonycd535.c.orig 2004-04-24 13:46:28.000000000 -0300 +1 -1
@@ -342,7 +342,7 @@
 sony_sleep(void)
 {
       if (sony535_irq_used <= 0) {    /* poll */
-               yield();
+               schedule_timeout(1);

I don't think it's that cut-and-dry...shouldn't you use something
relevant to HZ on this? Please see the patch maximilian sent on sis900 net driver.

Also, don't forget to use TASK_INTERRUPTITBLE (with a set_current_state
that uses a memory barrier) before using schedule_timeout, please.

Cheers,

Felipe

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#9 lore raw

Re: [Kernel-janitors] [PATCH] Replaces yield() with

In reply to Gustavo Franco

hello,

Quoted 13 lines · Felipe W Damasio

cdrom/sonycd535.c 2004-04-24 13:47:38.000000000 -0300 line 345

Quoted 8 lines · Gustavo Franco
cdrom/sonycd535.c 2004-04-24 13:47:38.000000000 -0300 renamed from cdrom/sonycd535.c.orig 2004-04-24 13:46:28.000000000 -0300 +1 -1
@@ -342,7 +342,7 @@
 sony_sleep(void)
 {
      if (sony535_irq_used <= 0) {    /* poll */
-               yield();
+               schedule_timeout(1);

I don't think it's that cut-and-dry...shouldn't you use something
relevant to HZ on this? Please see the patch maximilian sent on sis900 net driver.

jeff garzik prefers schedule_timeout(1) in the case of the sis900, "that's IMO closer to the intention.."

regards maks

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#10 lore raw

Re: [Kernel-janitors] [PATCH] Replaces yield() with

In reply to Gustavo Franco

On Wed, 28 Apr 2004 23:03:56 +0200 maximilian attems wrote:

| hello,
| 
| On Mon, 26 Apr 2004, Felipe W Damasio wrote:
| 
| > Gustavo Franco wrote:
| > >--- drivers/cdrom/sonycd535.c.orig    2004-04-24 13:46:28.000000000 -0300
| > >+++ drivers/cdrom/sonycd535.c 2004-04-24 13:47:38.000000000 -0300
| > >@@ -342,7 +342,7 @@
| > >sony_sleep(void)
| > >{
| > >       if (sony535_irq_used <= 0) {    /* poll */
| > >-               yield();
| > >+               schedule_timeout(1);
| > 
| > 	I don't think it's that cut-and-dry...shouldn't you use something 
| > relevant to HZ on this? Please see the patch maximilian sent on sis900 
| > net driver.
| 
| jeff garzik prefers schedule_timeout(1) in the case of the sis900,
| "that's IMO closer to the intention.."

Yes, and I've already sent an updated sis900.c patch to Jeff.

--
~Randy

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors

#11 lore raw
In reply to Gustavo Franco
Quoted 2 lines · maximilian attems

jeff garzik prefers schedule_timeout(1) in the case of the sis900, "that's IMO closer to the intention.."

Sounds fair, since he's the one whom chooses which patches get in ;)

Anyway, we still need set_current_state before calling schedule_timeout.

Cheers,

Felipe

_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors