Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1b3cba8e authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'sched-fixes-for-linus' of...

Merge branch 'sched-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'sched-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  sched: 64-bit: fix arithmetics overflow
  sched: fair group: fix overflow(was: fix divide by zero)
  sched: fix TASK_WAKEKILL vs SIGKILL race
parents 14a73f54 7a232e03
Loading
Loading
Loading
Loading
+13 −0
Original line number Original line Diff line number Diff line
@@ -2026,6 +2026,19 @@ static inline int fatal_signal_pending(struct task_struct *p)
	return signal_pending(p) && __fatal_signal_pending(p);
	return signal_pending(p) && __fatal_signal_pending(p);
}
}


static inline int signal_pending_state(long state, struct task_struct *p)
{
	if (!(state & (TASK_INTERRUPTIBLE | TASK_WAKEKILL)))
		return 0;
	if (!signal_pending(p))
		return 0;

	if (state & (__TASK_STOPPED | __TASK_TRACED))
		return 0;

	return (state & TASK_INTERRUPTIBLE) || __fatal_signal_pending(p);
}

static inline int need_resched(void)
static inline int need_resched(void)
{
{
	return unlikely(test_thread_flag(TIF_NEED_RESCHED));
	return unlikely(test_thread_flag(TIF_NEED_RESCHED));
+14 −8
Original line number Original line Diff line number Diff line
@@ -312,12 +312,15 @@ static DEFINE_SPINLOCK(task_group_lock);
#endif
#endif


/*
/*
 * A weight of 0, 1 or ULONG_MAX can cause arithmetics problems.
 * A weight of 0 or 1 can cause arithmetics problems.
 * A weight of a cfs_rq is the sum of weights of which entities
 * are queued on this cfs_rq, so a weight of a entity should not be
 * too large, so as the shares value of a task group.
 * (The default weight is 1024 - so there's no practical
 * (The default weight is 1024 - so there's no practical
 *  limitation from this.)
 *  limitation from this.)
 */
 */
#define MIN_SHARES	2
#define MIN_SHARES	2
#define MAX_SHARES	(ULONG_MAX - 1)
#define MAX_SHARES	(1UL << 18)


static int init_task_group_load = INIT_TASK_GROUP_LOAD;
static int init_task_group_load = INIT_TASK_GROUP_LOAD;
#endif
#endif
@@ -1337,8 +1340,13 @@ calc_delta_mine(unsigned long delta_exec, unsigned long weight,
{
{
	u64 tmp;
	u64 tmp;


	if (!lw->inv_weight)
	if (!lw->inv_weight) {
		lw->inv_weight = 1 + (WMULT_CONST-lw->weight/2)/(lw->weight+1);
		if (BITS_PER_LONG > 32 && unlikely(lw->weight >= WMULT_CONST))
			lw->inv_weight = 1;
		else
			lw->inv_weight = 1 + (WMULT_CONST-lw->weight/2)
				/ (lw->weight+1);
	}


	tmp = (u64)delta_exec * weight;
	tmp = (u64)delta_exec * weight;
	/*
	/*
@@ -4159,12 +4167,10 @@ asmlinkage void __sched schedule(void)
	clear_tsk_need_resched(prev);
	clear_tsk_need_resched(prev);


	if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
	if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
		if (unlikely((prev->state & TASK_INTERRUPTIBLE) &&
		if (unlikely(signal_pending_state(prev->state, prev)))
				signal_pending(prev))) {
			prev->state = TASK_RUNNING;
			prev->state = TASK_RUNNING;
		} else {
		else
			deactivate_task(rq, prev, 1);
			deactivate_task(rq, prev, 1);
		}
		switch_count = &prev->nvcsw;
		switch_count = &prev->nvcsw;
	}
	}