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

Commit ec9e16ba authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds
Browse files

[PATCH] sys_setrlimit() cleanup



- Whitespace cleanups

- Make that expression comprehensible.

There's a potential logic change here: we do the "is it_prof_expires equal to
zero" test after converting it to seconds, rather than doing the comparison
between raw cputime_t's.

But given that it's in units of seconds anyway, that shouldn't change
anything.

Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Ulrich Weigand <uweigand@de.ibm.com>
Cc: Cliff Wickman <cpw@sgi.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent de62a97e
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
@@ -1630,6 +1630,7 @@ asmlinkage long sys_old_getrlimit(unsigned int resource, struct rlimit __user *r
asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
{
	struct rlimit new_rlim, *old_rlim;
	unsigned long it_prof_secs;
	int retval;

	if (resource >= RLIM_NLIMITS)
@@ -1653,19 +1654,22 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
	*old_rlim = new_rlim;
	task_unlock(current->group_leader);

	if (resource == RLIMIT_CPU && new_rlim.rlim_cur != RLIM_INFINITY &&
	    (cputime_eq(current->signal->it_prof_expires, cputime_zero) ||
	     new_rlim.rlim_cur <= cputime_to_secs(
		     current->signal->it_prof_expires))) {
	if (resource != RLIMIT_CPU)
		goto out;
	if (new_rlim.rlim_cur == RLIM_INFINITY)
		goto out;

	it_prof_secs = cputime_to_secs(current->signal->it_prof_expires);
	if (it_prof_secs == 0 || new_rlim.rlim_cur <= it_prof_secs) {
		cputime_t cputime = secs_to_cputime(new_rlim.rlim_cur);

		read_lock(&tasklist_lock);
		spin_lock_irq(&current->sighand->siglock);
		set_process_cpu_timer(current, CPUCLOCK_PROF,
				      &cputime, NULL);
		set_process_cpu_timer(current, CPUCLOCK_PROF, &cputime, NULL);
		spin_unlock_irq(&current->sighand->siglock);
		read_unlock(&tasklist_lock);
	}

out:
	return 0;
}