need_resched abstraction
Subsystems (28)
PATCH 1/1 need_resched abstraction
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
_______________________________________________________________________________
Documentation/DocBook/kernel-hacking.tmpl +1 -2
@@ -371,8 +371,7 @@ </para> <programlisting> -if (current->need_resched) - schedule(); /* Will sleep */ +yield_point(); /* Will sleep */ </programlisting> <para>
arch/arm/kernel/process.c +1 -1
@@ -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 ();
arch/i386/kernel/apm.c +2 -2
@@ -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 ();
arch/i386/kernel/process.c +2 -2
@@ -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 ();
arch/i386/math-emu/fpu_entry.c +1 -1
@@ -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,
arch/ia64/kernel/process.c +2 -2
@@ -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 ();
arch/m68k/kernel/process.c +1 -1
@@ -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" );
arch/mips/kernel/process.c +1 -1
@@ -39,7 +39,7 @@init_idle ();while (1 ) { -while (!current->need_resched) +while (!need_yield ())if (cpu_wait) (*cpu_wait)();schedule ();
arch/mips/math-emu/cp1emu.c +1 -2
@@ -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);
arch/mips64/kernel/process.c +1 -1
@@ -35,7 +35,7 @@init_idle (); current->nice =20 ;while (1 ) { -while (!current->need_resched) +while (!need_yield ())if (wait_available) __asm__("wait" );schedule ();
arch/mips64/math-emu/cp1emu.c +1 -2
@@ -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);
arch/parisc/kernel/process.c +1 -1
@@ -73,7 +73,7 @@ current->nice =20 ;while (1 ) { -while (!current->need_resched) { +while (!need_yield ()) { }schedule ();check_pgt_cache ();
arch/ppc/kernel/idle.c +6 -8
@@ -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 );
arch/s390/kernel/process.c +1 -1
@@ -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 ;
arch/s390x/kernel/process.c +1 -1
@@ -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 ;
arch/sh/kernel/process.c +2 -2
@@ -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 (); asmvolatile ("sleep" : : :"memory" );__cli ();
arch/sparc/kernel/process.c +1 -1
@@ -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 (); }
arch/sparc64/kernel/process.c +2 -2
@@ -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 ();
drivers/char/lp.c +1 -1
@@ -367,7 +367,7 @@ = lp_negotiate (port, lp_table[minor].best_mode); - }else if (current->need_resched) + }else if (need_yield ())schedule ();if (count) {
drivers/char/mem.c +1 -2
@@ -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);
drivers/char/mwave/3780i.c +2 -4
@@ -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,
drivers/char/ppdev.c +2 -6
@@ -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);
drivers/char/random.c +1 -1
@@ -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 ;
drivers/char/tty_io.c +1 -2
@@ -712,8 +712,7 @@ ret = -ERESTARTSYS ;if (signal_pending (current))break ; -if (current->need_resched) -schedule (); +yield_point (); } }if (written) {
drivers/i2c/i2c-algo-bit.c +2 -3
@@ -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
drivers/i2c/i2c-algo-ite.c +1 -1
@@ -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(); */
drivers/md/md.c +1 -2
@@ -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 ;
drivers/media/radio/radio-sf16fmi.c +2 -4
@@ -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;
drivers/media/video/c-qcam.c +3 -6
@@ -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) {
drivers/media/video/cpia.c +3 -6
@@ -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 )
drivers/media/video/cpia_pp.c +1 -1
@@ -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 ) {
drivers/media/video/saa5249.c +1 -5
@@ -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 */
drivers/mtd/chips/amd_flash.c +2 -2
@@ -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 );
drivers/mtd/devices/doc2000.c +1 -1
@@ -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 ); }
drivers/parport/ieee1284.c +1 -1
@@ -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 );
drivers/parport/ieee1284_ops.c +1 -1
@@ -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:
drivers/parport/parport_pc.c +6 -9
@@ -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 (); }
drivers/sound/via82cxxx_audio.c +2 -2
@@ -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);
fs/jbd/commit.c +3 -5
@@ -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
fs/jffs2/background.c +1 -2
@@ -127,8 +127,7 @@schedule (); } -if (current->need_resched) -schedule (); +yield_point ();/* Put_super will send a SIGKILL and then wait on the sem. */
fs/jffs2/erase.c +1 -2
@@ -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);
fs/jffs2/nodemgmt.c +1 -2
@@ -101,8 +101,7 @@if (ret)return ret; -if (current->need_resched) -schedule (); +yield_point ();if (signal_pending (current))return -EINTR ;
fs/namei.c +1 -1
@@ -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 (); }
fs/reiserfs/inode.c +1 -2
@@ -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 ) {
include/asm-arm/arch-arc/system.h +1 -1
@@ -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)
include/asm-arm/arch-cl7500/system.h +1 -1
@@ -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 ); }
include/asm-arm/arch-ebsa110/system.h +3 -3
@@ -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 */ }
include/asm-arm/arch-ebsa285/system.h +2 -2
@@ -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 ); }
include/asm-arm/arch-nexuspci/system.h +1 -1
@@ -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 ); }
include/asm-arm/arch-rpc/system.h +2 -2
@@ -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 ); }
include/asm-arm/arch-sa1100/system.h +1 -1
@@ -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); }
include/asm-arm/arch-tbox/system.h +2 -2
@@ -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 ); }
include/linux/mtd/cfi.h +1 -1
@@ -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 ;
include/linux/sched.h +12 -0
@@ -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
kernel/printk.c +1 -1
@@ -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 (); }
kernel/sched.c +1 -1
@@ -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 ; }
kernel/softirq.c +1 -2
@@ -387,8 +387,7 @@while (softirq_pending (cpu)) {do_softirq (); -if (current->need_resched) -schedule (); +yield_point (); }__set_current_state (TASK_INTERRUPTIBLE );
mm/filemap.c +2 -2
@@ -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 (); }
mm/swapfile.c +1 -1
@@ -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 (); }
mm/vmscan.c +3 -4
@@ -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 )) {
net/sunrpc/sched.c +1 -1
@@ -721,7 +721,7 @@__rpc_execute (task); -if (++count >=200 || current->need_resched) { +if (++count >=200 ||need_yield ()) { count =0 ;schedule (); }
Call me picky but I like the name cond_resched() ;-)
Signature · 4 lines
Jeff Garzik | Alternate titles for LOTR:
Building 1024 | Fast Times at Uruk-Hai
MandrakeSoft | The Took, the Elf, His Daughter and Her Lover
| Samwise Gamgee: International Hobbit of MysteryQuoted 1 line · On Tue, 15 Jan 2002 04:29:54 -0500 Jeff Garzik <[email protected]> wrote:
Call me picky but I like the name
cond_resched();-)
... And I prefer maybe_schedule().
Cheers,
Rusty.
Signature · 1 line
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Quoted 6 lines · Rusty Russell
Quoted 1 line · On Tue, 15 Jan 2002 04:29:54 -0500 Jeff Garzik <[email protected]> wrote:
Call me picky but I like the name
cond_resched();-)... And I prefer
maybe_schedule().
I made everybody unhappy by changing the names of _both_ "cond_yield()" and "need_yield()". So there.
My tree calls them "cond_resched()" and "need_resched()" respectively.
Nyaah, nyaah, nyaah.
Linus "management skill: saying 'Nyaah' really load" Torvalds
In message <[email protected]> you write:
Quoted 5 lines · Rusty Russell
Quoted 1 line
... And I prefer
maybe_schedule().My tree calls them "
cond_resched()" and "need_resched()" respectively.
Bastard! Then please apply (thanks to Andrew Morton):
drivers/block/ll_rw_blk.c +1 -0
@@ -996,6 +996,7 @@if (++rl->count >= batch_requests &&waitqueue_active (&rl->wait))wake_up (&rl->wait); } +cond_resched (); }/*
fs/buffer.c +11 -2
@@ -250,12 +250,19 @@struct buffer_head * next;int nr; - next = lru_list[index]; nr = nr_buffers_type[index]; +repeat: + next = lru_list[index];while (next && --nr >=0 ) {struct buffer_head *bh = next; next = bh->b_next_free; +if (dev ==NODEV &&need_resched ()) { +spin_unlock (&lru_list_lock); +cond_resched (); +spin_lock (&lru_list_lock); + goto repeat; + }if (!buffer_locked (bh)) {if (refile)__refile_buffer (bh);
@@ -1180,8 +1187,10 @@struct buffer_head * bh =__getblk (bdev, block, size);touch_buffer (bh); -if (buffer_uptodate (bh)) +if (buffer_uptodate (bh)) { +cond_resched ();return bh; + }ll_rw_block (READ ,1 , &bh);wait_on_buffer (bh);if (buffer_uptodate (bh))
fs/dcache.c +1 -0
@@ -84,6 +84,7 @@iput (inode); }else spin_unlock (&dcache_lock); +cond_resched (); }/*
fs/jbd/commit.c +10 -0
@@ -212,6 +212,16 @@__journal_remove_journal_head (bh);refile_buffer (bh);__brelse (bh); +if (need_resched ()) { +if (commit_transaction->t_sync_datalist) + commit_transaction->t_sync_datalist = + next_jh; +if (bufs) +break ; +spin_unlock (&journal_datalist_lock); +cond_resched (); + goto write_out_data; + } } }if (bufs ==ARRAY_SIZE (wbuf)) {
fs/proc/array.c +2 -0
@@ -419,6 +419,8 @@pte_t page = *pte;struct page *ptpage; +cond_resched (); + address +=PAGE_SIZE ; pte++;if (pte_none (page))
fs/proc/generic.c +3 -1
@@ -98,7 +98,9 @@ retval = n;break ; } - + +cond_resched (); +/* This is a hack to allow mangling of file pos independent * of actual bytes read. Simply place the data at page, * return the bytes, and set `start' to the desired offset
mm/filemap.c +6 -0
@@ -603,6 +603,7 @@UnlockPage (page);page_cache_release (page); +cond_resched ();spin_lock (&pagecache_lock); }spin_unlock (&pagecache_lock);
@@ -1386,6 +1387,9 @@ offset &= ~PAGE_CACHE_MASK ;page_cache_release (page); + +cond_resched (); +if (ret == nr && desc->count)continue ;break ;
@@ -3019,6 +3023,8 @@SetPageReferenced (page);UnlockPage (page);page_cache_release (page); + +cond_resched ();if (status <0 )break ;
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.