lkml.org 
[lkml]   [2002]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] need_resched abstraction
Date
From

The attached patch abstracts access to need_resched in as many places as is
reasonable. It makes two replacements:

(1) testing current->need_resched:

if (current->need_resched) ...

is replaced with:

if (need_yield()) ...

(2) testing current->need_resched and immediately scheduling if set:

if (current->need_resched)
schedule();

is replaced with:

yield_point();

[since yield() is already defined to be something else].

David

_______________________________________________________________________________
diff -uNr linux-2.5.2/Documentation/DocBook/kernel-hacking.tmpl linux-yield-252/Documentation/DocBook/kernel-hacking.tmpl
--- linux-2.5.2/Documentation/DocBook/kernel-hacking.tmpl Tue Jan 15 08:19:49 2002
+++ linux-yield-252/Documentation/DocBook/kernel-hacking.tmpl Tue Jan 15 08:40:37 2002
@@ -371,8 +371,7 @@
</para>

<programlisting>
-if (current-&gt;need_resched)
- schedule(); /* Will sleep */
+yield_point(); /* Will sleep */
</programlisting>

<para>
diff -uNr linux-2.5.2/arch/arm/kernel/process.c linux-yield-252/arch/arm/kernel/process.c
--- linux-2.5.2/arch/arm/kernel/process.c Tue Jan 15 08:19:49 2002
+++ linux-yield-252/arch/arm/kernel/process.c Tue Jan 15 08:40:37 2002
@@ -91,7 +91,7 @@
if (!idle)
idle = arch_idle;
leds_event(led_idle_start);
- while (!current->need_resched)
+ while (!need_yield())
idle();
leds_event(led_idle_end);
schedule();
diff -uNr linux-2.5.2/arch/i386/kernel/apm.c linux-yield-252/arch/i386/kernel/apm.c
--- linux-2.5.2/arch/i386/kernel/apm.c Tue Jan 15 08:16:48 2002
+++ linux-yield-252/arch/i386/kernel/apm.c Tue Jan 15 08:40:37 2002
@@ -766,14 +766,14 @@

start_idle = jiffies;
while (1) {
- if (!current->need_resched) {
+ if (!need_yield()) {
if (jiffies - start_idle < HARD_IDLE_TIMEOUT) {
if (!current_cpu_data.hlt_works_ok)
continue;
if (hlt_counter)
continue;
__cli();
- if (!current->need_resched)
+ if (!need_yield())
safe_halt();
else
__sti();
diff -uNr linux-2.5.2/arch/i386/kernel/process.c linux-yield-252/arch/i386/kernel/process.c
--- linux-2.5.2/arch/i386/kernel/process.c Tue Jan 15 08:19:49 2002
+++ linux-yield-252/arch/i386/kernel/process.c Tue Jan 15 08:40:37 2002
@@ -81,7 +81,7 @@
{
if (current_cpu_data.hlt_works_ok && !hlt_counter) {
__cli();
- if (!current->need_resched)
+ if (!need_yield())
safe_halt();
else
__sti();
@@ -127,7 +127,7 @@
void (*idle)(void) = pm_idle;
if (!idle)
idle = default_idle;
- while (!current->need_resched)
+ while (!need_yield())
idle();
schedule();
check_pgt_cache();
diff -uNr linux-2.5.2/arch/i386/math-emu/fpu_entry.c linux-yield-252/arch/i386/math-emu/fpu_entry.c
--- linux-2.5.2/arch/i386/math-emu/fpu_entry.c Tue Jan 15 08:16:48 2002
+++ linux-yield-252/arch/i386/math-emu/fpu_entry.c Tue Jan 15 08:40:37 2002
@@ -559,7 +559,7 @@
RE_ENTRANT_CHECK_ON;
#endif /* DEBUG */

- if (FPU_lookahead && !current->need_resched)
+ if (FPU_lookahead && !need_yield())
{
FPU_ORIG_EIP = FPU_EIP - code_base;
if ( valid_prefix(&byte1, (u_char **)&FPU_EIP,
diff -uNr linux-2.5.2/arch/ia64/kernel/process.c linux-yield-252/arch/ia64/kernel/process.c
--- linux-2.5.2/arch/ia64/kernel/process.c Tue Jan 15 08:19:49 2002
+++ linux-yield-252/arch/ia64/kernel/process.c Tue Jan 15 08:40:37 2002
@@ -117,10 +117,10 @@

while (1) {
#ifdef CONFIG_SMP
- if (!current->need_resched)
+ if (!need_yield())
min_xtp();
#endif
- while (!current->need_resched)
+ while (!need_yield())
continue;
#ifdef CONFIG_SMP
normal_xtp();
diff -uNr linux-2.5.2/arch/m68k/kernel/process.c linux-yield-252/arch/m68k/kernel/process.c
--- linux-2.5.2/arch/m68k/kernel/process.c Tue Jan 15 08:19:49 2002
+++ linux-yield-252/arch/m68k/kernel/process.c Tue Jan 15 08:40:37 2002
@@ -56,7 +56,7 @@
static void default_idle(void)
{
while(1) {
- if (!current->need_resched)
+ if (!need_yield())
#if defined(MACH_ATARI_ONLY) && !defined(CONFIG_HADES)
/* block out HSYNC on the atari (falcon) */
__asm__("stop #0x2200" : : : "cc");
diff -uNr linux-2.5.2/arch/mips/kernel/process.c linux-yield-252/arch/mips/kernel/process.c
--- linux-2.5.2/arch/mips/kernel/process.c Tue Jan 15 08:19:49 2002
+++ linux-yield-252/arch/mips/kernel/process.c Tue Jan 15 08:40:37 2002
@@ -39,7 +39,7 @@
init_idle();

while (1) {
- while (!current->need_resched)
+ while (!need_yield())
if (cpu_wait)
(*cpu_wait)();
schedule();
diff -uNr linux-2.5.2/arch/mips/math-emu/cp1emu.c linux-yield-252/arch/mips/math-emu/cp1emu.c
--- linux-2.5.2/arch/mips/math-emu/cp1emu.c Tue Jan 15 08:16:51 2002
+++ linux-yield-252/arch/mips/math-emu/cp1emu.c Tue Jan 15 08:40:37 2002
@@ -1674,8 +1674,7 @@

oldepc = xcp->cp0_epc;
do {
- if (current->need_resched)
- schedule();
+ yield_point();

prevepc = xcp->cp0_epc;
insn = mips_get_word(xcp, REG_TO_VA(xcp->cp0_epc), &err);
diff -uNr linux-2.5.2/arch/mips64/kernel/process.c linux-yield-252/arch/mips64/kernel/process.c
--- linux-2.5.2/arch/mips64/kernel/process.c Tue Jan 15 08:19:49 2002
+++ linux-yield-252/arch/mips64/kernel/process.c Tue Jan 15 08:40:37 2002
@@ -35,7 +35,7 @@
init_idle();
current->nice = 20;
while (1) {
- while (!current->need_resched)
+ while (!need_yield())
if (wait_available)
__asm__("wait");
schedule();
diff -uNr linux-2.5.2/arch/mips64/math-emu/cp1emu.c linux-yield-252/arch/mips64/math-emu/cp1emu.c
--- linux-2.5.2/arch/mips64/math-emu/cp1emu.c Tue Jan 15 08:17:01 2002
+++ linux-yield-252/arch/mips64/math-emu/cp1emu.c Tue Jan 15 08:40:37 2002
@@ -1707,8 +1707,7 @@

oldepc = xcp->cp0_epc;
do {
- if (current->need_resched)
- schedule();
+ yield_point();

prevepc = xcp->cp0_epc;
insn = mips_get_word(xcp, REG_TO_VA(xcp->cp0_epc), &err);
diff -uNr linux-2.5.2/arch/parisc/kernel/process.c linux-yield-252/arch/parisc/kernel/process.c
--- linux-2.5.2/arch/parisc/kernel/process.c Tue Jan 15 08:19:49 2002
+++ linux-yield-252/arch/parisc/kernel/process.c Tue Jan 15 08:40:37 2002
@@ -73,7 +73,7 @@
current->nice = 20;

while (1) {
- while (!current->need_resched) {
+ while (!need_yield()) {
}
schedule();
check_pgt_cache();
diff -uNr linux-2.5.2/arch/ppc/kernel/idle.c linux-yield-252/arch/ppc/kernel/idle.c
--- linux-2.5.2/arch/ppc/kernel/idle.c Tue Jan 15 08:19:49 2002
+++ linux-yield-252/arch/ppc/kernel/idle.c Tue Jan 15 08:40:37 2002
@@ -71,10 +71,10 @@
}
}
#endif
- if (do_power_save && !current->need_resched)
+ if (do_power_save && !need_yield())
power_save();

- if (current->need_resched) {
+ if (need_yield()) {
schedule();
check_pgt_cache();
}
@@ -150,7 +150,7 @@

if ( atomic_read(&zero_cache_sz) >= zero_cache_water[0] )
return;
- while ( (atomic_read(&zero_cache_sz) < zero_cache_water[1]) && (!current->need_resched) )
+ while ( (atomic_read(&zero_cache_sz) < zero_cache_water[1]) && !need_yield() )
{
/*
* Mark a page as reserved so we can mess with it
@@ -161,8 +161,7 @@
if ( !pageptr )
return;

- if ( current->need_resched )
- schedule();
+ yield_point();

/*
* Make the page no cache so we don't blow our cache with 0's
@@ -181,8 +180,7 @@
*/
for ( bytecount = 0; bytecount < PAGE_SIZE ; bytecount += 4 )
{
- if ( current->need_resched )
- schedule();
+ yield_point();
*(unsigned long *)(bytecount + pageptr) = 0;
}

@@ -243,7 +241,7 @@
* -- Cort
*/
_nmask_and_or_msr(MSR_EE, 0);
- if (!current->need_resched)
+ if (!need_yield())
{
asm("mfspr %0,1008" : "=r" (hid0) :);
hid0 &= ~(HID0_NAP | HID0_SLEEP | HID0_DOZE);
diff -uNr linux-2.5.2/arch/s390/kernel/process.c linux-yield-252/arch/s390/kernel/process.c
--- linux-2.5.2/arch/s390/kernel/process.c Tue Jan 15 08:19:49 2002
+++ linux-yield-252/arch/s390/kernel/process.c Tue Jan 15 08:40:37 2002
@@ -60,7 +60,7 @@
wait_psw.mask = _WAIT_PSW_MASK;
wait_psw.addr = (unsigned long) &&idle_wakeup | 0x80000000L;
while(1) {
- if (current->need_resched) {
+ if (need_yield()) {
schedule();
check_pgt_cache();
continue;
diff -uNr linux-2.5.2/arch/s390x/kernel/process.c linux-yield-252/arch/s390x/kernel/process.c
--- linux-2.5.2/arch/s390x/kernel/process.c Tue Jan 15 08:19:49 2002
+++ linux-yield-252/arch/s390x/kernel/process.c Tue Jan 15 08:40:37 2002
@@ -60,7 +60,7 @@
wait_psw.mask = _WAIT_PSW_MASK;
wait_psw.addr = (unsigned long) &&idle_wakeup;
while(1) {
- if (current->need_resched) {
+ if (need_yield()) {
schedule();
check_pgt_cache();
continue;
diff -uNr linux-2.5.2/arch/sh/kernel/process.c linux-yield-252/arch/sh/kernel/process.c
--- linux-2.5.2/arch/sh/kernel/process.c Tue Jan 15 08:19:49 2002
+++ linux-yield-252/arch/sh/kernel/process.c Tue Jan 15 08:40:37 2002
@@ -44,11 +44,11 @@

while (1) {
if (hlt_counter) {
- if (current->need_resched)
+ if (need_yield())
break;
} else {
__cli();
- while (!current->need_resched) {
+ while (!need_yield()) {
__sti();
asm volatile("sleep" : : : "memory");
__cli();
diff -uNr linux-2.5.2/arch/sparc/kernel/process.c linux-yield-252/arch/sparc/kernel/process.c
--- linux-2.5.2/arch/sparc/kernel/process.c Tue Jan 15 08:19:49 2002
+++ linux-yield-252/arch/sparc/kernel/process.c Tue Jan 15 08:40:37 2002
@@ -106,7 +106,7 @@
{
/* endless idle loop with no priority at all */
while(1) {
- if(current->need_resched) {
+ if(need_yield()) {
schedule();
check_pgt_cache();
}
diff -uNr linux-2.5.2/arch/sparc64/kernel/process.c linux-yield-252/arch/sparc64/kernel/process.c
--- linux-2.5.2/arch/sparc64/kernel/process.c Tue Jan 15 08:19:50 2002
+++ linux-yield-252/arch/sparc64/kernel/process.c Tue Jan 15 08:40:37 2002
@@ -61,7 +61,7 @@
* But this requires writing back the contents of the
* L2 cache etc. so implement this later. -DaveM
*/
- while (!current->need_resched)
+ while (!need_yield())
barrier();

schedule();
@@ -80,7 +80,7 @@
int cpu_idle(void)
{
while(1) {
- if (current->need_resched != 0) {
+ if (need_yield()) {
unidle_me();
schedule();
check_pgt_cache();
diff -uNr linux-2.5.2/drivers/char/lp.c linux-yield-252/drivers/char/lp.c
--- linux-2.5.2/drivers/char/lp.c Tue Jan 15 08:19:50 2002
+++ linux-yield-252/drivers/char/lp.c Tue Jan 15 08:40:37 2002
@@ -367,7 +367,7 @@
= lp_negotiate (port,
lp_table[minor].best_mode);

- } else if (current->need_resched)
+ } else if (need_yield())
schedule ();

if (count) {
diff -uNr linux-2.5.2/drivers/char/mem.c linux-yield-252/drivers/char/mem.c
--- linux-2.5.2/drivers/char/mem.c Tue Jan 15 08:19:50 2002
+++ linux-yield-252/drivers/char/mem.c Tue Jan 15 08:40:37 2002
@@ -381,8 +381,7 @@
unsigned long unwritten = clear_user(buf, PAGE_SIZE);
if (unwritten)
return size + unwritten - PAGE_SIZE;
- if (current->need_resched)
- schedule();
+ yield_point();
buf += PAGE_SIZE;
size -= PAGE_SIZE;
} while (size);
diff -uNr linux-2.5.2/drivers/char/mwave/3780i.c linux-yield-252/drivers/char/mwave/3780i.c
--- linux-2.5.2/drivers/char/mwave/3780i.c Tue Jan 15 08:16:25 2002
+++ linux-yield-252/drivers/char/mwave/3780i.c Tue Jan 15 08:40:37 2002
@@ -68,11 +68,9 @@

static void PaceMsaAccess(unsigned short usDspBaseIO)
{
- if(current->need_resched)
- schedule();
+ yield_point();
udelay(100);
- if(current->need_resched)
- schedule();
+ yield_point();
}

unsigned short dsp3780I_ReadMsaCfg(unsigned short usDspBaseIO,
diff -uNr linux-2.5.2/drivers/char/ppdev.c linux-yield-252/drivers/char/ppdev.c
--- linux-2.5.2/drivers/char/ppdev.c Tue Jan 15 08:19:50 2002
+++ linux-yield-252/drivers/char/ppdev.c Tue Jan 15 08:40:37 2002
@@ -170,9 +170,7 @@
break;
}

- if (current->need_resched) {
- schedule ();
- }
+ yield_point();
}

kfree (kbuffer);
@@ -242,9 +240,7 @@
break;
}

- if (current->need_resched) {
- schedule ();
- }
+ yield_point();
}

kfree (kbuffer);
diff -uNr linux-2.5.2/drivers/char/random.c linux-yield-252/drivers/char/random.c
--- linux-2.5.2/drivers/char/random.c Tue Jan 15 08:16:22 2002
+++ linux-yield-252/drivers/char/random.c Tue Jan 15 08:40:37 2002
@@ -1313,7 +1313,7 @@
/*
* Check if we need to break out or reschedule....
*/
- if ((flags & EXTRACT_ENTROPY_USER) && current->need_resched) {
+ if ((flags & EXTRACT_ENTROPY_USER) && need_yield()) {
if (signal_pending(current)) {
if (ret == 0)
ret = -ERESTARTSYS;
diff -uNr linux-2.5.2/drivers/char/tty_io.c linux-yield-252/drivers/char/tty_io.c
--- linux-2.5.2/drivers/char/tty_io.c Tue Jan 15 08:19:51 2002
+++ linux-yield-252/drivers/char/tty_io.c Tue Jan 15 08:40:37 2002
@@ -712,8 +712,7 @@
ret = -ERESTARTSYS;
if (signal_pending(current))
break;
- if (current->need_resched)
- schedule();
+ yield_point();
}
}
if (written) {
diff -uNr linux-2.5.2/drivers/i2c/i2c-algo-bit.c linux-yield-252/drivers/i2c/i2c-algo-bit.c
--- linux-2.5.2/drivers/i2c/i2c-algo-bit.c Tue Jan 15 08:16:44 2002
+++ linux-yield-252/drivers/i2c/i2c-algo-bit.c Tue Jan 15 08:40:37 2002
@@ -50,7 +50,7 @@
/* might not like this, as they have an internal timeout of some mils */
/*
#define SLO_IO jif=jiffies;while(jiffies<=jif+i2c_table[minor].veryslow)\
- if (need_resched) schedule();
+ yield_point();
*/


@@ -120,8 +120,7 @@
if (start+adap->timeout <= jiffies) {
return -ETIMEDOUT;
}
- if (current->need_resched)
- schedule();
+ yield_point();
}
DEBSTAT(printk("needed %ld jiffies\n", jiffies-start));
#ifdef SLO_IO
diff -uNr linux-2.5.2/drivers/i2c/i2c-algo-ite.c linux-yield-252/drivers/i2c/i2c-algo-ite.c
--- linux-2.5.2/drivers/i2c/i2c-algo-ite.c Tue Jan 15 08:16:44 2002
+++ linux-yield-252/drivers/i2c/i2c-algo-ite.c Tue Jan 15 08:40:37 2002
@@ -67,7 +67,7 @@
/* might not like this, as they have an internal timeout of some mils */
/*
#define SLO_IO jif=jiffies;while(jiffies<=jif+i2c_table[minor].veryslow)\
- if (need_resched) schedule();
+ yield_point();
*/


diff -uNr linux-2.5.2/drivers/md/md.c linux-yield-252/drivers/md/md.c
--- linux-2.5.2/drivers/md/md.c Tue Jan 15 08:19:51 2002
+++ linux-yield-252/drivers/md/md.c Tue Jan 15 08:40:37 2002
@@ -3458,8 +3458,7 @@
* about not overloading the IO subsystem. (things like an
* e2fsck being done on the RAID array should execute fast)
*/
- if (current->need_resched)
- schedule();
+ yield_point();

currspeed = (j-mddev->resync_mark_cnt)/2/((jiffies-mddev->resync_mark)/HZ +1) +1;

diff -uNr linux-2.5.2/drivers/media/radio/radio-sf16fmi.c linux-yield-252/drivers/media/radio/radio-sf16fmi.c
--- linux-2.5.2/drivers/media/radio/radio-sf16fmi.c Tue Jan 15 08:16:46 2002
+++ linux-yield-252/drivers/media/radio/radio-sf16fmi.c Tue Jan 15 08:40:37 2002
@@ -94,8 +94,7 @@
for(i=0; i< 100; i++)
{
udelay(1400);
- if(current->need_resched)
- schedule();
+ yield_point();
}
/* If this becomes allowed use it ...
current->state = TASK_UNINTERRUPTIBLE;
@@ -121,8 +120,7 @@
for(i=0; i< 100; i++)
{
udelay(1400);
- if(current->need_resched)
- schedule();
+ yield_point();
}
/* If this becomes allowed use it ...
current->state = TASK_UNINTERRUPTIBLE;
diff -uNr linux-2.5.2/drivers/media/video/c-qcam.c linux-yield-252/drivers/media/video/c-qcam.c
--- linux-2.5.2/drivers/media/video/c-qcam.c Tue Jan 15 08:16:46 2002
+++ linux-yield-252/drivers/media/video/c-qcam.c Tue Jan 15 08:40:37 2002
@@ -425,8 +425,7 @@
wantlen -= t;
if (t < s)
break;
- if (current->need_resched)
- schedule();
+ yield_point();
}

len = outptr;
@@ -445,8 +444,7 @@
int l;
do {
l = qcam_read_bytes(q, tmpbuf, 3);
- if (current->need_resched)
- schedule();
+ yield_point();
} while (l && (tmpbuf[0] == 0x7e || tmpbuf[1] == 0x7e || tmpbuf[2] == 0x7e));
if (force_rgb) {
if (tmpbuf[0] != 0xe || tmpbuf[1] != 0x0 || tmpbuf[2] != 0xf)
@@ -478,8 +476,7 @@
int l;
do {
l = qcam_read_bytes(q, tmpbuf, 1);
- if (current->need_resched)
- schedule();
+ yield_point();
} while (l && tmpbuf[0] == 0x7e);
l = qcam_read_bytes(q, tmpbuf+1, 2);
if (force_rgb) {
diff -uNr linux-2.5.2/drivers/media/video/cpia.c linux-yield-252/drivers/media/video/cpia.c
--- linux-2.5.2/drivers/media/video/cpia.c Tue Jan 15 08:19:51 2002
+++ linux-yield-252/drivers/media/video/cpia.c Tue Jan 15 08:40:37 2002
@@ -2147,8 +2147,7 @@
/* loop until image ready */
do_command(cam, CPIA_COMMAND_GetCameraStatus,0,0,0,0);
while (cam->params.status.streamState != STREAM_READY) {
- if (current->need_resched)
- schedule();
+ yield_point();

current->state = TASK_INTERRUPTIBLE;

@@ -2163,8 +2162,7 @@
}

/* grab image from camera */
- if (current->need_resched)
- schedule();
+ yield_point();

oldjif = jiffies;
image_size = cam->ops->streamRead(cam->lowlevel_data,
@@ -2189,8 +2187,7 @@
/* decompress and convert image to by copying it from
* raw_image to decompressed_frame
*/
- if (current->need_resched)
- schedule();
+ yield_point();

cam->image_size = parse_picture(cam, image_size);
if (cam->image_size <= 0)
diff -uNr linux-2.5.2/drivers/media/video/cpia_pp.c linux-yield-252/drivers/media/video/cpia_pp.c
--- linux-2.5.2/drivers/media/video/cpia_pp.c Tue Jan 15 08:16:46 2002
+++ linux-yield-252/drivers/media/video/cpia_pp.c Tue Jan 15 08:40:37 2002
@@ -392,7 +392,7 @@
endseen = 0;
block_size = PARPORT_CHUNK_SIZE;
while( !cam->image_complete ) {
- if(current->need_resched) schedule();
+ yield_point();

new_bytes = cpia_pp_read(cam->port, buffer, block_size );
if( new_bytes <= 0 ) {
diff -uNr linux-2.5.2/drivers/media/video/saa5249.c linux-yield-252/drivers/media/video/saa5249.c
--- linux-2.5.2/drivers/media/video/saa5249.c Tue Jan 15 08:16:46 2002
+++ linux-yield-252/drivers/media/video/saa5249.c Tue Jan 15 08:40:37 2002
@@ -127,11 +127,7 @@
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif

-#define RESCHED \
- do { \
- if (current->need_resched) \
- schedule(); \
- } while (0)
+#define RESCHED do { yield_point(); } while(0)

static struct video_device saa_template; /* Declared near bottom */

diff -uNr linux-2.5.2/drivers/mtd/chips/amd_flash.c linux-yield-252/drivers/mtd/chips/amd_flash.c
--- linux-2.5.2/drivers/mtd/chips/amd_flash.c Tue Jan 15 08:16:46 2002
+++ linux-yield-252/drivers/mtd/chips/amd_flash.c Tue Jan 15 08:40:37 2002
@@ -889,7 +889,7 @@

times_left = 500000;
while (times_left-- && flash_is_busy(map, adr, private->interleave)) {
- if (current->need_resched) {
+ if (need_yield()) {
spin_unlock_bh(chip->mutex);
schedule();
spin_lock_bh(chip->mutex);
@@ -1126,7 +1126,7 @@
/* Latency issues. Drop the lock, wait a while and retry */
spin_unlock_bh(chip->mutex);

- if (current->need_resched)
+ if (need_yield())
schedule();
else
udelay(1);
diff -uNr linux-2.5.2/drivers/mtd/devices/doc2000.c linux-yield-252/drivers/mtd/devices/doc2000.c
--- linux-2.5.2/drivers/mtd/devices/doc2000.c Tue Jan 15 08:16:46 2002
+++ linux-yield-252/drivers/mtd/devices/doc2000.c Tue Jan 15 08:40:37 2002
@@ -97,7 +97,7 @@
DEBUG(MTD_DEBUG_LEVEL2, "_DoC_WaitReady timed out.\n");
return -EIO;
}
- if (current->need_resched) {
+ if (need_yield()) {
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(1);
}
diff -uNr linux-2.5.2/drivers/parport/ieee1284.c linux-yield-252/drivers/parport/ieee1284.c
--- linux-2.5.2/drivers/parport/ieee1284.c Tue Jan 15 08:16:44 2002
+++ linux-yield-252/drivers/parport/ieee1284.c Tue Jan 15 08:40:37 2002
@@ -128,7 +128,7 @@
return 0;
if (signal_pending (current))
return -EINTR;
- if (current->need_resched)
+ if (need_yield())
break;
if (i >= 2)
udelay (5);
diff -uNr linux-2.5.2/drivers/parport/ieee1284_ops.c linux-yield-252/drivers/parport/ieee1284_ops.c
--- linux-2.5.2/drivers/parport/ieee1284_ops.c Tue Jan 15 08:16:43 2002
+++ linux-yield-252/drivers/parport/ieee1284_ops.c Tue Jan 15 08:40:37 2002
@@ -136,7 +136,7 @@
/* Let another process run if it needs to. */
if (time_before (jiffies, expire))
if (!parport_yield_blocking (dev)
- && current->need_resched)
+ && need_yield())
schedule ();
}
stop:
diff -uNr linux-2.5.2/drivers/parport/parport_pc.c linux-yield-252/drivers/parport/parport_pc.c
--- linux-2.5.2/drivers/parport/parport_pc.c Tue Jan 15 08:16:43 2002
+++ linux-yield-252/drivers/parport/parport_pc.c Tue Jan 15 08:40:37 2002
@@ -596,7 +596,7 @@
unsigned char ecrval = inb (ECONTROL (port));
int i = 0;

- if (current->need_resched && time_before (jiffies, expire))
+ if (need_yield() && time_before (jiffies, expire))
/* Can't yield the port. */
schedule ();

@@ -622,7 +622,7 @@
}
ecrval = inb (ECONTROL (port));
if (!(ecrval & (1<<2))) {
- if (current->need_resched &&
+ if (need_yield() &&
time_before (jiffies, expire))
schedule ();

@@ -746,8 +746,7 @@
}
/* Is serviceIntr set? */
if (!(inb (ECONTROL (port)) & (1<<2))) {
- if (current->need_resched)
- schedule ();
+ yield_point();

goto false_alarm;
}
@@ -758,9 +757,7 @@
count = get_dma_residue(port->dma);
release_dma_lock(dmaflag);

- if (current->need_resched)
- /* Can't yield the port. */
- schedule ();
+ yield_point(); /* Can't yield the port. */

/* Anyone else waiting for the port? */
if (port->waithead) {
@@ -1093,7 +1090,7 @@
long int expire = jiffies + port->cad->timeout;
unsigned char ecrval = inb (ECONTROL (port));

- if (current->need_resched && time_before (jiffies, expire))
+ if (need_yield() && time_before (jiffies, expire))
/* Can't yield the port. */
schedule ();

@@ -1130,7 +1127,7 @@
}
ecrval = inb (ECONTROL (port));
if (!(ecrval & (1<<2))) {
- if (current->need_resched &&
+ if (need_yield() &&
time_before (jiffies, expire)) {
schedule ();
}
diff -uNr linux-2.5.2/drivers/sound/via82cxxx_audio.c linux-yield-252/drivers/sound/via82cxxx_audio.c
--- linux-2.5.2/drivers/sound/via82cxxx_audio.c Tue Jan 15 08:16:34 2002
+++ linux-yield-252/drivers/sound/via82cxxx_audio.c Tue Jan 15 08:40:37 2002
@@ -1995,7 +1995,7 @@
/* just to be a nice neighbor */
/* Thomas Sailer:
* But also to ourselves, release semaphore if we do so */
- if (current->need_resched) {
+ if (need_yield()) {
up(&card->syscall_sem);
schedule ();
ret = via_syscall_down (card, nonblock);
@@ -2171,7 +2171,7 @@
/* just to be a nice neighbor */
/* Thomas Sailer:
* But also to ourselves, release semaphore if we do so */
- if (current->need_resched) {
+ if (need_yield()) {
up(&card->syscall_sem);
schedule ();
ret = via_syscall_down (card, nonblock);
diff -uNr linux-2.5.2/fs/jbd/commit.c linux-yield-252/fs/jbd/commit.c
--- linux-2.5.2/fs/jbd/commit.c Tue Jan 15 08:19:54 2002
+++ linux-yield-252/fs/jbd/commit.c Tue Jan 15 08:40:37 2002
@@ -224,14 +224,13 @@
}
} while (jh != last_jh);

- if (bufs || current->need_resched) {
+ if (bufs || need_yield()) {
jbd_debug(2, "submit %d writes\n", bufs);
spin_unlock(&journal_datalist_lock);
unlock_journal(journal);
if (bufs)
ll_rw_block(WRITE, bufs, wbuf);
- if (current->need_resched)
- schedule();
+ yield_point();
journal_brelse_array(wbuf, bufs);
lock_journal(journal);
spin_lock(&journal_datalist_lock);
@@ -458,8 +457,7 @@
bh->b_end_io = journal_end_buffer_io_sync;
submit_bh(WRITE, bh);
}
- if (current->need_resched)
- schedule();
+ yield_point();
lock_journal(journal);

/* Force a new descriptor to be generated next
diff -uNr linux-2.5.2/fs/jffs2/background.c linux-yield-252/fs/jffs2/background.c
--- linux-2.5.2/fs/jffs2/background.c Tue Jan 15 08:19:55 2002
+++ linux-yield-252/fs/jffs2/background.c Tue Jan 15 08:40:37 2002
@@ -127,8 +127,7 @@
schedule();
}

- if (current->need_resched)
- schedule();
+ yield_point();

/* Put_super will send a SIGKILL and then wait on the sem.
*/
diff -uNr linux-2.5.2/fs/jffs2/erase.c linux-yield-252/fs/jffs2/erase.c
--- linux-2.5.2/fs/jffs2/erase.c Tue Jan 15 08:19:55 2002
+++ linux-yield-252/fs/jffs2/erase.c Tue Jan 15 08:40:37 2002
@@ -131,8 +131,7 @@

jffs2_erase_block(c, jeb);
/* Be nice */
- if (current->need_resched)
- schedule();
+ yield_point();
spin_lock_bh(&c->erase_completion_lock);
}
spin_unlock_bh(&c->erase_completion_lock);
diff -uNr linux-2.5.2/fs/jffs2/nodemgmt.c linux-yield-252/fs/jffs2/nodemgmt.c
--- linux-2.5.2/fs/jffs2/nodemgmt.c Tue Jan 15 08:16:02 2002
+++ linux-yield-252/fs/jffs2/nodemgmt.c Tue Jan 15 08:40:37 2002
@@ -101,8 +101,7 @@
if (ret)
return ret;

- if (current->need_resched)
- schedule();
+ yield_point();

if (signal_pending(current))
return -EINTR;
diff -uNr linux-2.5.2/fs/namei.c linux-yield-252/fs/namei.c
--- linux-2.5.2/fs/namei.c Tue Jan 15 08:19:55 2002
+++ linux-yield-252/fs/namei.c Tue Jan 15 08:40:37 2002
@@ -339,7 +339,7 @@
goto loop;
if (current->total_link_count >= 40)
goto loop;
- if (current->need_resched) {
+ if (need_yield()) {
current->state = TASK_RUNNING;
schedule();
}
diff -uNr linux-2.5.2/fs/reiserfs/inode.c linux-yield-252/fs/reiserfs/inode.c
--- linux-2.5.2/fs/reiserfs/inode.c Tue Jan 15 08:19:55 2002
+++ linux-yield-252/fs/reiserfs/inode.c Tue Jan 15 08:40:37 2002
@@ -808,8 +808,7 @@
/* inserting indirect pointers for a hole can take a
** long time. reschedule if needed
*/
- if (current->need_resched)
- schedule() ;
+ yield_point();

retval = search_for_position_by_key (inode->i_sb, &key, &path);
if (retval == IO_ERROR) {
diff -uNr linux-2.5.2/include/asm-arm/arch-arc/system.h linux-yield-252/include/asm-arm/arch-arc/system.h
--- linux-2.5.2/include/asm-arm/arch-arc/system.h Tue Jan 15 08:16:07 2002
+++ linux-yield-252/include/asm-arm/arch-arc/system.h Tue Jan 15 08:40:37 2002
@@ -10,7 +10,7 @@

static void arch_idle(void)
{
- while (!current->need_resched && !hlt_counter);
+ while (!need_yield() && !hlt_counter);
}

static inline void arch_reset(char mode)
diff -uNr linux-2.5.2/include/asm-arm/arch-cl7500/system.h linux-yield-252/include/asm-arm/arch-cl7500/system.h
--- linux-2.5.2/include/asm-arm/arch-cl7500/system.h Tue Jan 15 08:16:07 2002
+++ linux-yield-252/include/asm-arm/arch-cl7500/system.h Tue Jan 15 08:40:37 2002
@@ -10,7 +10,7 @@

static void arch_idle(void)
{
- while (!current->need_resched && !hlt_counter)
+ while (!need_yield() && !hlt_counter)
iomd_writeb(0, IOMD_SUSMODE);
}

diff -uNr linux-2.5.2/include/asm-arm/arch-ebsa110/system.h linux-yield-252/include/asm-arm/arch-ebsa110/system.h
--- linux-2.5.2/include/asm-arm/arch-ebsa110/system.h Tue Jan 15 08:16:07 2002
+++ linux-yield-252/include/asm-arm/arch-ebsa110/system.h Tue Jan 15 08:40:37 2002
@@ -17,7 +17,7 @@
* will stop our MCLK signal (which provides the clock for the glue
* logic, and therefore the timer interrupt).
*
- * Instead, we spin, waiting for either hlt_counter or need_resched
+ * Instead, we spin, waiting for either hlt_counter or need_yield()
* to be set. If we have been spinning for 2cs, then we drop the
* core clock down to the memory clock.
*/
@@ -28,13 +28,13 @@
start_idle = jiffies;

do {
- if (current->need_resched || hlt_counter)
+ if (need_yield() || hlt_counter)
goto slow_out;
} while (time_before(jiffies, start_idle + HZ/50));

cpu_do_idle(IDLE_CLOCK_SLOW);

- while (!current->need_resched && !hlt_counter) {
+ while (!need_yield() && !hlt_counter) {
/* do nothing slowly */
}

diff -uNr linux-2.5.2/include/asm-arm/arch-ebsa285/system.h linux-yield-252/include/asm-arm/arch-ebsa285/system.h
--- linux-2.5.2/include/asm-arm/arch-ebsa285/system.h Tue Jan 15 08:16:07 2002
+++ linux-yield-252/include/asm-arm/arch-ebsa285/system.h Tue Jan 15 08:40:37 2002
@@ -20,14 +20,14 @@
start_idle = jiffies;

do {
- if (current->need_resched || hlt_counter)
+ if (need_yield() || hlt_counter)
goto slow_out;
cpu_do_idle(IDLE_WAIT_FAST);
} while (time_before(jiffies, start_idle + HZ/50));

cpu_do_idle(IDLE_CLOCK_SLOW);

- while (!current->need_resched && !hlt_counter) {
+ while (!need_yield() && !hlt_counter) {
cpu_do_idle(IDLE_WAIT_SLOW);
}

diff -uNr linux-2.5.2/include/asm-arm/arch-nexuspci/system.h linux-yield-252/include/asm-arm/arch-nexuspci/system.h
--- linux-2.5.2/include/asm-arm/arch-nexuspci/system.h Tue Jan 15 08:16:07 2002
+++ linux-yield-252/include/asm-arm/arch-nexuspci/system.h Tue Jan 15 08:40:37 2002
@@ -16,7 +16,7 @@

static void arch_idle(void)
{
- while (!current->need_resched && !hlt_counter)
+ while (!need_yield() && !hlt_counter)
cpu_do_idle(IDLE_WAIT_SLOW);
}

diff -uNr linux-2.5.2/include/asm-arm/arch-rpc/system.h linux-yield-252/include/asm-arm/arch-rpc/system.h
--- linux-2.5.2/include/asm-arm/arch-rpc/system.h Tue Jan 15 08:16:07 2002
+++ linux-yield-252/include/asm-arm/arch-rpc/system.h Tue Jan 15 08:40:37 2002
@@ -18,14 +18,14 @@
start_idle = jiffies;

do {
- if (current->need_resched || hlt_counter)
+ if (need_yield() || hlt_counter)
goto slow_out;
cpu_do_idle(IDLE_WAIT_FAST);
} while (time_before(jiffies, start_idle + HZ/50));

cpu_do_idle(IDLE_CLOCK_SLOW);

- while (!current->need_resched && !hlt_counter) {
+ while (!need_yield() && !hlt_counter) {
cpu_do_idle(IDLE_WAIT_SLOW);
}

diff -uNr linux-2.5.2/include/asm-arm/arch-sa1100/system.h linux-yield-252/include/asm-arm/arch-sa1100/system.h
--- linux-2.5.2/include/asm-arm/arch-sa1100/system.h Tue Jan 15 08:16:07 2002
+++ linux-yield-252/include/asm-arm/arch-sa1100/system.h Tue Jan 15 08:40:37 2002
@@ -10,7 +10,7 @@
if (!hlt_counter) {
int flags;
local_irq_save(flags);
- if (!current->need_resched)
+ if (!need_yield())
cpu_do_idle(0);
local_irq_restore(flags);
}
diff -uNr linux-2.5.2/include/asm-arm/arch-tbox/system.h linux-yield-252/include/asm-arm/arch-tbox/system.h
--- linux-2.5.2/include/asm-arm/arch-tbox/system.h Tue Jan 15 08:16:07 2002
+++ linux-yield-252/include/asm-arm/arch-tbox/system.h Tue Jan 15 08:40:37 2002
@@ -13,14 +13,14 @@
start_idle = jiffies;

do {
- if (current->need_resched || hlt_counter)
+ if (need_yield() || hlt_counter)
goto slow_out;
cpu_do_idle(IDLE_WAIT_FAST);
} while (time_before(jiffies, start_idle + HZ/50));

cpu_do_idle(IDLE_CLOCK_SLOW);

- while (!current->need_resched && !hlt_counter) {
+ while (!need_yield() && !hlt_counter) {
cpu_do_idle(IDLE_WAIT_SLOW);
}

diff -uNr linux-2.5.2/include/linux/mtd/cfi.h linux-yield-252/include/linux/mtd/cfi.h
--- linux-2.5.2/include/linux/mtd/cfi.h Tue Jan 15 08:16:03 2002
+++ linux-yield-252/include/linux/mtd/cfi.h Tue Jan 15 08:40:37 2002
@@ -368,7 +368,7 @@
static inline void cfi_udelay(int us)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- if (current->need_resched) {
+ if (need_yield()) {
unsigned long t = us * HZ / 1000000;
if (t < 1)
t = 1;
diff -uNr linux-2.5.2/include/linux/sched.h linux-yield-252/include/linux/sched.h
--- linux-2.5.2/include/linux/sched.h Tue Jan 15 08:19:56 2002
+++ linux-yield-252/include/linux/sched.h Tue Jan 15 08:45:38 2002
@@ -25,6 +25,7 @@
#include <linux/signal.h>
#include <linux/securebits.h>
#include <linux/fs_struct.h>
+#include <linux/compiler.h>

struct exec_domain;

@@ -669,6 +670,17 @@
{
return (p->sigpending != 0);
}
+
+static inline int need_yield(void)
+{
+ return unlikely(current->need_resched != 0);
+}
+
+static inline void yield_point(void)
+{
+ if (need_yield())
+ schedule();
+}

/*
* Re-calculate pending state from the set of locally pending
diff -uNr linux-2.5.2/kernel/printk.c linux-yield-252/kernel/printk.c
--- linux-2.5.2/kernel/printk.c Tue Jan 15 08:19:57 2002
+++ linux-yield-252/kernel/printk.c Tue Jan 15 08:40:37 2002
@@ -524,7 +524,7 @@
*/
void console_conditional_schedule(void)
{
- if (console_may_schedule && current->need_resched) {
+ if (console_may_schedule && need_yield()) {
set_current_state(TASK_RUNNING);
schedule();
}
diff -uNr linux-2.5.2/kernel/sched.c linux-yield-252/kernel/sched.c
--- linux-2.5.2/kernel/sched.c Tue Jan 15 08:19:57 2002
+++ linux-yield-252/kernel/sched.c Tue Jan 15 08:40:37 2002
@@ -531,7 +531,7 @@
spin_unlock_irq(&rq->lock);

reacquire_kernel_lock(current);
- if (unlikely(current->need_resched))
+ if (need_yield())
goto need_resched_back;
return;
}
diff -uNr linux-2.5.2/kernel/softirq.c linux-yield-252/kernel/softirq.c
--- linux-2.5.2/kernel/softirq.c Tue Jan 15 08:19:57 2002
+++ linux-yield-252/kernel/softirq.c Tue Jan 15 08:40:37 2002
@@ -387,8 +387,7 @@

while (softirq_pending(cpu)) {
do_softirq();
- if (current->need_resched)
- schedule();
+ yield_point();
}

__set_current_state(TASK_INTERRUPTIBLE);
diff -uNr linux-2.5.2/mm/filemap.c linux-yield-252/mm/filemap.c
--- linux-2.5.2/mm/filemap.c Tue Jan 15 08:19:57 2002
+++ linux-yield-252/mm/filemap.c Tue Jan 15 08:40:37 2002
@@ -290,7 +290,7 @@

page_cache_release(page);

- if (current->need_resched) {
+ if (need_yield()) {
__set_current_state(TASK_RUNNING);
schedule();
}
@@ -400,7 +400,7 @@
}

page_cache_release(page);
- if (current->need_resched) {
+ if (need_yield()) {
__set_current_state(TASK_RUNNING);
schedule();
}
diff -uNr linux-2.5.2/mm/swapfile.c linux-yield-252/mm/swapfile.c
--- linux-2.5.2/mm/swapfile.c Tue Jan 15 08:19:57 2002
+++ linux-yield-252/mm/swapfile.c Tue Jan 15 08:40:37 2002
@@ -696,7 +696,7 @@
* interactive performance. Interruptible check on
* signal_pending() would be nice, but changes the spec?
*/
- if (current->need_resched)
+ if (need_yield())
schedule();
}

diff -uNr linux-2.5.2/mm/vmscan.c linux-yield-252/mm/vmscan.c
--- linux-2.5.2/mm/vmscan.c Tue Jan 15 08:19:57 2002
+++ linux-yield-252/mm/vmscan.c Tue Jan 15 08:40:37 2002
@@ -300,7 +300,7 @@

counter = mmlist_nr;
do {
- if (unlikely(current->need_resched)) {
+ if (need_yield()) {
__set_current_state(TASK_RUNNING);
schedule();
}
@@ -345,7 +345,7 @@
while (--max_scan >= 0 && (entry = inactive_list.prev) != &inactive_list) {
struct page * page;

- if (unlikely(current->need_resched)) {
+ if (need_yield()) {
spin_unlock(&pagemap_lru_lock);
__set_current_state(TASK_RUNNING);
schedule();
@@ -625,8 +625,7 @@

for (i = pgdat->nr_zones-1; i >= 0; i--) {
zone = pgdat->node_zones + i;
- if (unlikely(current->need_resched))
- schedule();
+ yield_point();
if (!zone->need_balance)
continue;
if (!try_to_free_pages(zone, GFP_KSWAPD, 0)) {
diff -uNr linux-2.5.2/net/sunrpc/sched.c linux-yield-252/net/sunrpc/sched.c
--- linux-2.5.2/net/sunrpc/sched.c Tue Jan 15 08:19:57 2002
+++ linux-yield-252/net/sunrpc/sched.c Tue Jan 15 08:40:37 2002
@@ -721,7 +721,7 @@

__rpc_execute(task);

- if (++count >= 200 || current->need_resched) {
+ if (++count >= 200 || need_yield()) {
count = 0;
schedule();
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 13:22    [W:0.071 / U:10.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site