You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
[PATCH] Cleanup patch for process freezing
1. Establish a simple API for process freezing defined in linux/include/sched.h: frozen(process) Check for frozen process freezing(process) Check if a process is being frozen freeze(process) Tell a process to freeze (go to refrigerator) thaw_process(process) Restart process frozen_process(process) Process is frozen now 2. Remove all references to PF_FREEZE and PF_FROZEN from all kernel sources except sched.h 3. Fix numerous locations where try_to_freeze is manually done by a driver 4. Remove the argument that is no longer necessary from two function calls. 5. Some whitespace cleanup 6. Clear potential race in refrigerator (provides an open window of PF_FREEZE cleared before setting PF_FROZEN, recalc_sigpending does not check PF_FROZEN). This patch does not address the problem of freeze_processes() violating the rule that a task may only modify its own flags by setting PF_FREEZE. This is not clean in an SMP environment. freeze(process) is therefore not SMP safe! Signed-off-by: Christoph Lameter <christoph@lameter.com> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
committed by
Linus Torvalds
parent
b3e112bcc1
commit
3e1d1d28d9
@@ -12,8 +12,7 @@ refrigerator. Code to do this looks like this:
|
|||||||
do {
|
do {
|
||||||
hub_events();
|
hub_events();
|
||||||
wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list));
|
wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list));
|
||||||
if (current->flags & PF_FREEZE)
|
try_to_freeze();
|
||||||
refrigerator(PF_FREEZE);
|
|
||||||
} while (!signal_pending(current));
|
} while (!signal_pending(current));
|
||||||
|
|
||||||
from drivers/usb/core/hub.c::hub_thread()
|
from drivers/usb/core/hub.c::hub_thread()
|
||||||
|
|||||||
@@ -164,8 +164,7 @@ place where the thread is safe to be frozen (no kernel semaphores
|
|||||||
should be held at that point and it must be safe to sleep there), and
|
should be held at that point and it must be safe to sleep there), and
|
||||||
add:
|
add:
|
||||||
|
|
||||||
if (current->flags & PF_FREEZE)
|
try_to_freeze();
|
||||||
refrigerator(PF_FREEZE);
|
|
||||||
|
|
||||||
If the thread is needed for writing the image to storage, you should
|
If the thread is needed for writing the image to storage, you should
|
||||||
instead set the PF_NOFREEZE process flag when creating the thread.
|
instead set the PF_NOFREEZE process flag when creating the thread.
|
||||||
|
|||||||
@@ -536,10 +536,8 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
|
|||||||
if (!user_mode(regs))
|
if (!user_mode(regs))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (current->flags & PF_FREEZE) {
|
if (try_to_freeze())
|
||||||
refrigerator(0);
|
|
||||||
goto no_signal;
|
goto no_signal;
|
||||||
}
|
|
||||||
|
|
||||||
if (!oldset)
|
if (!oldset)
|
||||||
oldset = ¤t->blocked;
|
oldset = ¤t->blocked;
|
||||||
|
|||||||
@@ -517,10 +517,8 @@ asmlinkage int do_signal(struct pt_regs *regs, sigset_t *oldset)
|
|||||||
if ((regs->ccr & 0x10))
|
if ((regs->ccr & 0x10))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (current->flags & PF_FREEZE) {
|
if (try_to_freeze())
|
||||||
refrigerator(0);
|
|
||||||
goto no_signal;
|
goto no_signal;
|
||||||
}
|
|
||||||
|
|
||||||
current->thread.esp0 = (unsigned long) regs;
|
current->thread.esp0 = (unsigned long) regs;
|
||||||
|
|
||||||
|
|||||||
@@ -573,7 +573,7 @@ static int balanced_irq(void *unused)
|
|||||||
for ( ; ; ) {
|
for ( ; ; ) {
|
||||||
set_current_state(TASK_INTERRUPTIBLE);
|
set_current_state(TASK_INTERRUPTIBLE);
|
||||||
time_remaining = schedule_timeout(time_remaining);
|
time_remaining = schedule_timeout(time_remaining);
|
||||||
try_to_freeze(PF_FREEZE);
|
try_to_freeze();
|
||||||
if (time_after(jiffies,
|
if (time_after(jiffies,
|
||||||
prev_balance_time+balanced_irq_interval)) {
|
prev_balance_time+balanced_irq_interval)) {
|
||||||
do_irq_balance();
|
do_irq_balance();
|
||||||
|
|||||||
@@ -608,10 +608,8 @@ int fastcall do_signal(struct pt_regs *regs, sigset_t *oldset)
|
|||||||
if (!user_mode(regs))
|
if (!user_mode(regs))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (current->flags & PF_FREEZE) {
|
if (try_to_freeze)
|
||||||
refrigerator(0);
|
|
||||||
goto no_signal;
|
goto no_signal;
|
||||||
}
|
|
||||||
|
|
||||||
if (!oldset)
|
if (!oldset)
|
||||||
oldset = ¤t->blocked;
|
oldset = ¤t->blocked;
|
||||||
|
|||||||
@@ -371,10 +371,8 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
|
|||||||
if (!user_mode(regs))
|
if (!user_mode(regs))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (current->flags & PF_FREEZE) {
|
if (try_to_freeze())
|
||||||
refrigerator(0);
|
|
||||||
goto no_signal;
|
goto no_signal;
|
||||||
}
|
|
||||||
|
|
||||||
if (!oldset)
|
if (!oldset)
|
||||||
oldset = ¤t->blocked;
|
oldset = ¤t->blocked;
|
||||||
|
|||||||
@@ -705,8 +705,7 @@ int do_signal(sigset_t *oldset, struct pt_regs *regs)
|
|||||||
unsigned long frame, newsp;
|
unsigned long frame, newsp;
|
||||||
int signr, ret;
|
int signr, ret;
|
||||||
|
|
||||||
if (current->flags & PF_FREEZE) {
|
if (try_to_freeze()) {
|
||||||
refrigerator(PF_FREEZE);
|
|
||||||
signr = 0;
|
signr = 0;
|
||||||
if (!signal_pending(current))
|
if (!signal_pending(current))
|
||||||
goto no_signal;
|
goto no_signal;
|
||||||
|
|||||||
@@ -425,7 +425,7 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
|
|||||||
if (!user_mode(regs))
|
if (!user_mode(regs))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (try_to_freeze(0))
|
if (try_to_freeze())
|
||||||
goto no_signal;
|
goto no_signal;
|
||||||
|
|
||||||
if (!oldset)
|
if (!oldset)
|
||||||
|
|||||||
@@ -1251,8 +1251,7 @@ static int kcdrwd(void *foobar)
|
|||||||
VPRINTK("kcdrwd: wake up\n");
|
VPRINTK("kcdrwd: wake up\n");
|
||||||
|
|
||||||
/* make swsusp happy with our thread */
|
/* make swsusp happy with our thread */
|
||||||
if (current->flags & PF_FREEZE)
|
try_to_freeze();
|
||||||
refrigerator(PF_FREEZE);
|
|
||||||
|
|
||||||
list_for_each_entry(pkt, &pd->cdrw.pkt_active_list, list) {
|
list_for_each_entry(pkt, &pd->cdrw.pkt_active_list, list) {
|
||||||
if (!pkt->sleep_time)
|
if (!pkt->sleep_time)
|
||||||
|
|||||||
@@ -1041,10 +1041,8 @@ static int hpsbpkt_thread(void *__hi)
|
|||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (down_interruptible(&khpsbpkt_sig)) {
|
if (down_interruptible(&khpsbpkt_sig)) {
|
||||||
if (current->flags & PF_FREEZE) {
|
if (try_to_freeze())
|
||||||
refrigerator(0);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
printk("khpsbpkt: received unexpected signal?!\n" );
|
printk("khpsbpkt: received unexpected signal?!\n" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1510,7 +1510,7 @@ static int nodemgr_host_thread(void *__hi)
|
|||||||
|
|
||||||
if (down_interruptible(&hi->reset_sem) ||
|
if (down_interruptible(&hi->reset_sem) ||
|
||||||
down_interruptible(&nodemgr_serialize)) {
|
down_interruptible(&nodemgr_serialize)) {
|
||||||
if (try_to_freeze(PF_FREEZE))
|
if (try_to_freeze())
|
||||||
continue;
|
continue;
|
||||||
printk("NodeMgr: received unexpected signal?!\n" );
|
printk("NodeMgr: received unexpected signal?!\n" );
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -439,7 +439,7 @@ static int gameport_thread(void *nothing)
|
|||||||
do {
|
do {
|
||||||
gameport_handle_events();
|
gameport_handle_events();
|
||||||
wait_event_interruptible(gameport_wait, !list_empty(&gameport_event_list));
|
wait_event_interruptible(gameport_wait, !list_empty(&gameport_event_list));
|
||||||
try_to_freeze(PF_FREEZE);
|
try_to_freeze();
|
||||||
} while (!signal_pending(current));
|
} while (!signal_pending(current));
|
||||||
|
|
||||||
printk(KERN_DEBUG "gameport: kgameportd exiting\n");
|
printk(KERN_DEBUG "gameport: kgameportd exiting\n");
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ static int serio_thread(void *nothing)
|
|||||||
do {
|
do {
|
||||||
serio_handle_events();
|
serio_handle_events();
|
||||||
wait_event_interruptible(serio_wait, !list_empty(&serio_event_list));
|
wait_event_interruptible(serio_wait, !list_empty(&serio_event_list));
|
||||||
try_to_freeze(PF_FREEZE);
|
try_to_freeze();
|
||||||
} while (!signal_pending(current));
|
} while (!signal_pending(current));
|
||||||
|
|
||||||
printk(KERN_DEBUG "serio: kseriod exiting\n");
|
printk(KERN_DEBUG "serio: kseriod exiting\n");
|
||||||
|
|||||||
@@ -328,9 +328,7 @@ static int monitor_task(void *arg)
|
|||||||
struct thermostat* th = arg;
|
struct thermostat* th = arg;
|
||||||
|
|
||||||
while(!kthread_should_stop()) {
|
while(!kthread_should_stop()) {
|
||||||
if (current->flags & PF_FREEZE)
|
try_to_freeze();
|
||||||
refrigerator(PF_FREEZE);
|
|
||||||
|
|
||||||
msleep_interruptible(2000);
|
msleep_interruptible(2000);
|
||||||
|
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
|
|||||||
+1
-2
@@ -2976,8 +2976,7 @@ static int md_thread(void * arg)
|
|||||||
wait_event_interruptible_timeout(thread->wqueue,
|
wait_event_interruptible_timeout(thread->wqueue,
|
||||||
test_bit(THREAD_WAKEUP, &thread->flags),
|
test_bit(THREAD_WAKEUP, &thread->flags),
|
||||||
thread->timeout);
|
thread->timeout);
|
||||||
if (current->flags & PF_FREEZE)
|
try_to_freeze();
|
||||||
refrigerator(PF_FREEZE);
|
|
||||||
|
|
||||||
clear_bit(THREAD_WAKEUP, &thread->flags);
|
clear_bit(THREAD_WAKEUP, &thread->flags);
|
||||||
|
|
||||||
|
|||||||
@@ -391,8 +391,7 @@ static int dvb_frontend_thread(void *data)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current->flags & PF_FREEZE)
|
try_to_freeze();
|
||||||
refrigerator(PF_FREEZE);
|
|
||||||
|
|
||||||
if (down_interruptible(&fepriv->sem))
|
if (down_interruptible(&fepriv->sem))
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -750,8 +750,7 @@ static int msp34xx_sleep(struct msp3400c *msp, int timeout)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (current->flags & PF_FREEZE)
|
try_to_freeze();
|
||||||
refrigerator(PF_FREEZE);
|
|
||||||
remove_wait_queue(&msp->wq, &wait);
|
remove_wait_queue(&msp->wq, &wait);
|
||||||
return msp->restart;
|
return msp->restart;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,8 +62,7 @@ static int videobuf_dvb_thread(void *data)
|
|||||||
break;
|
break;
|
||||||
if (kthread_should_stop())
|
if (kthread_should_stop())
|
||||||
break;
|
break;
|
||||||
if (current->flags & PF_FREEZE)
|
try_to_freeze();
|
||||||
refrigerator(PF_FREEZE);
|
|
||||||
|
|
||||||
/* feed buffer data to demux */
|
/* feed buffer data to demux */
|
||||||
if (buf->state == STATE_DONE)
|
if (buf->state == STATE_DONE)
|
||||||
|
|||||||
@@ -1606,7 +1606,7 @@ static int rtl8139_thread (void *data)
|
|||||||
do {
|
do {
|
||||||
timeout = interruptible_sleep_on_timeout (&tp->thr_wait, timeout);
|
timeout = interruptible_sleep_on_timeout (&tp->thr_wait, timeout);
|
||||||
/* make swsusp happy with our thread */
|
/* make swsusp happy with our thread */
|
||||||
try_to_freeze(PF_FREEZE);
|
try_to_freeze();
|
||||||
} while (!signal_pending (current) && (timeout > 0));
|
} while (!signal_pending (current) && (timeout > 0));
|
||||||
|
|
||||||
if (signal_pending (current)) {
|
if (signal_pending (current)) {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user