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

Commit 121caf57 authored by Nishanth Aravamudan's avatar Nishanth Aravamudan Committed by David S. Miller
Browse files

[NET]: fix-up schedule_timeout() usage



Use schedule_timeout_{,un}interruptible() instead of
set_current_state()/schedule_timeout() to reduce kernel size.  Also use
human-time conversion functions instead of hard-coded division to avoid
rounding issues.

Signed-off-by: default avatarNishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7672d0b5
Loading
Loading
Loading
Loading
+5 −8
Original line number Original line Diff line number Diff line
@@ -1452,8 +1452,7 @@ static int proc_thread_write(struct file *file, const char __user *user_buffer,
		thread_lock();
		thread_lock();
		t->control |= T_REMDEV;
		t->control |= T_REMDEV;
		thread_unlock();
		thread_unlock();
		current->state = TASK_INTERRUPTIBLE;
		schedule_timeout_interruptible(msecs_to_jiffies(125));  /* Propagate thread->control  */
		schedule_timeout(HZ/8);  /* Propagate thread->control  */
		ret = count;
		ret = count;
                sprintf(pg_result, "OK: rem_device_all");
                sprintf(pg_result, "OK: rem_device_all");
		goto out;
		goto out;
@@ -1716,10 +1715,9 @@ static void spin(struct pktgen_dev *pkt_dev, __u64 spin_until_us)
	printk(KERN_INFO "sleeping for %d\n", (int)(spin_until_us - now));
	printk(KERN_INFO "sleeping for %d\n", (int)(spin_until_us - now));
	while (now < spin_until_us) {
	while (now < spin_until_us) {
		/* TODO: optimise sleeping behavior */
		/* TODO: optimise sleeping behavior */
		if (spin_until_us - now > (1000000/HZ)+1) {
		if (spin_until_us - now > jiffies_to_usecs(1)+1)
			current->state = TASK_INTERRUPTIBLE;
			schedule_timeout_interruptible(1);
			schedule_timeout(1);
		else if (spin_until_us - now > 100) {
		} else if (spin_until_us - now > 100) {
			do_softirq();
			do_softirq();
			if (!pkt_dev->running)
			if (!pkt_dev->running)
				return;
				return;
@@ -2449,8 +2447,7 @@ static void pktgen_run_all_threads(void)
	}
	}
	thread_unlock();
	thread_unlock();


	current->state = TASK_INTERRUPTIBLE;
	schedule_timeout_interruptible(msecs_to_jiffies(125));  /* Propagate thread->control  */
	schedule_timeout(HZ/8);  /* Propagate thread->control  */
			
			
	pktgen_wait_all_threads_run();
	pktgen_wait_all_threads_run();
}
}
+2 −4
Original line number Original line Diff line number Diff line
@@ -1103,10 +1103,8 @@ static int __init ic_dynamic(void)
#endif
#endif


		jiff = jiffies + (d->next ? CONF_INTER_TIMEOUT : timeout);
		jiff = jiffies + (d->next ? CONF_INTER_TIMEOUT : timeout);
		while (time_before(jiffies, jiff) && !ic_got_reply) {
		while (time_before(jiffies, jiff) && !ic_got_reply)
			set_current_state(TASK_UNINTERRUPTIBLE);
			schedule_timeout_uninterruptible(1);
			schedule_timeout(1);
		}
#ifdef IPCONFIG_DHCP
#ifdef IPCONFIG_DHCP
		/* DHCP isn't done until we get a DHCPACK. */
		/* DHCP isn't done until we get a DHCPACK. */
		if ((ic_got_reply & IC_BOOTP)
		if ((ic_got_reply & IC_BOOTP)
+3 −6
Original line number Original line Diff line number Diff line
@@ -567,10 +567,8 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
	self->tty = NULL;
	self->tty = NULL;


	if (self->blocked_open) {
	if (self->blocked_open) {
		if (self->close_delay) {
		if (self->close_delay)
			current->state = TASK_INTERRUPTIBLE;
			schedule_timeout_interruptible(self->close_delay);
			schedule_timeout(self->close_delay);
		}
		wake_up_interruptible(&self->open_wait);
		wake_up_interruptible(&self->open_wait);
	}
	}


@@ -863,8 +861,7 @@ static void ircomm_tty_wait_until_sent(struct tty_struct *tty, int timeout)
	spin_lock_irqsave(&self->spinlock, flags);
	spin_lock_irqsave(&self->spinlock, flags);
	while (self->tx_skb && self->tx_skb->len) {
	while (self->tx_skb && self->tx_skb->len) {
		spin_unlock_irqrestore(&self->spinlock, flags);
		spin_unlock_irqrestore(&self->spinlock, flags);
		current->state = TASK_INTERRUPTIBLE;
		schedule_timeout_interruptible(poll_time);
		schedule_timeout(poll_time);
		spin_lock_irqsave(&self->spinlock, flags);
		spin_lock_irqsave(&self->spinlock, flags);
		if (signal_pending(current))
		if (signal_pending(current))
			break;
			break;
+1 −2
Original line number Original line Diff line number Diff line
@@ -1170,8 +1170,7 @@ svc_recv(struct svc_serv *serv, struct svc_rqst *rqstp, long timeout)
	while (rqstp->rq_arghi < pages) {
	while (rqstp->rq_arghi < pages) {
		struct page *p = alloc_page(GFP_KERNEL);
		struct page *p = alloc_page(GFP_KERNEL);
		if (!p) {
		if (!p) {
			set_current_state(TASK_UNINTERRUPTIBLE);
			schedule_timeout_uninterruptible(msecs_to_jiffies(500));
			schedule_timeout(HZ/2);
			continue;
			continue;
		}
		}
		rqstp->rq_argpages[rqstp->rq_arghi++] = p;
		rqstp->rq_argpages[rqstp->rq_arghi++] = p;