linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] core: add lockless update_rlimit_cpu
@ 2009-09-02  9:45 Jiri Slaby
  2009-09-02  9:45 ` [PATCH 2/2] core: allow setrlimit to non-current tasks Jiri Slaby
  0 siblings, 1 reply; 22+ messages in thread
From: Jiri Slaby @ 2009-09-02  9:45 UTC (permalink / raw)
  To: oleg; +Cc: akpm, mingo, linux-kernel, Jiri Slaby

Oleg Nesterov wrote:
> But I dislike the fact the patch uses tasklist_lock. Can't
> lock_task_sighand() work for you? (of course, in this case
> update_rlimit_cpu() should be updated too).

Yeah, I think so. I didn't know about that, sorry.

Something like these two?
--

Rename update_rlimit_cpu to __update_rlimit_cpu and create
update_rlimit_cpu wrapper with sighand lock.

The former is to be used by users who already hold the lock.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>
---
 include/linux/posix-timers.h |    1 +
 kernel/posix-cpu-timers.c    |   14 +++++++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index 3e23844..d0bac29 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -117,6 +117,7 @@ void set_process_cpu_timer(struct task_struct *task, unsigned int clock_idx,
 
 long clock_nanosleep_restart(struct restart_block *restart_block);
 
+void __update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new);
 void update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new);
 
 #endif
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index a61c625..56eb1d5 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -12,17 +12,21 @@
 /*
  * Called after updating RLIMIT_CPU to set timer expiration if necessary.
  */
-void update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new)
+void __update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new)
 {
 	cputime_t cputime = secs_to_cputime(rlim_new);
 	struct signal_struct *const sig = task->signal;
 
 	if (cputime_eq(sig->it[CPUCLOCK_PROF].expires, cputime_zero) ||
-	    cputime_gt(sig->it[CPUCLOCK_PROF].expires, cputime)) {
-		spin_lock_irq(&task->sighand->siglock);
+	    cputime_gt(sig->it[CPUCLOCK_PROF].expires, cputime))
 		set_process_cpu_timer(task, CPUCLOCK_PROF, &cputime, NULL);
-		spin_unlock_irq(&task->sighand->siglock);
-	}
+}
+
+void update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new)
+{
+	spin_lock_irq(&task->sighand->siglock);
+	__update_rlimit_cpu(task, rlim_new);
+	spin_unlock_irq(&task->sighand->siglock);
 }
 
 static int check_clock(const clockid_t which_clock)
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2009-10-12 15:19 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-02  9:45 [PATCH 1/2] core: add lockless update_rlimit_cpu Jiri Slaby
2009-09-02  9:45 ` [PATCH 2/2] core: allow setrlimit to non-current tasks Jiri Slaby
2009-09-02  9:47   ` Jiri Slaby
2009-09-02 13:50   ` Oleg Nesterov
2009-09-02 18:44     ` Jiri Slaby
2009-09-02 21:51       ` Oleg Nesterov
2009-09-03 13:47         ` Jiri Slaby
2009-09-03 13:52           ` [PATCH] " Jiri Slaby
2009-09-03 17:41             ` Oleg Nesterov
2009-09-03 20:08               ` [PATCH v2 1/8] SECURITY: selinux, fix update_rlimit_cpu parameter Jiri Slaby
2009-09-03 20:08               ` [PATCH v2 2/8] SECURITY: add task_struct to setrlimit Jiri Slaby
2009-09-03 20:08               ` [PATCH v2 3/8] core: add task_struct to update_rlimit_cpu Jiri Slaby
2009-09-03 20:08               ` [PATCH v2 4/8] sys_setrlimit: make sure ->rlim_max never grows Jiri Slaby
2009-09-03 20:08               ` [PATCH v2 5/8] core: split sys_setrlimit Jiri Slaby
2009-09-03 20:08               ` [PATCH v2 6/8] core: allow setrlimit to non-current tasks Jiri Slaby
2009-09-03 20:08               ` [PATCH v2 7/8] core: optimize setrlimit for current task Jiri Slaby
2009-09-03 20:08               ` [PATCH v2 8/8] FS: proc, make limits writable Jiri Slaby
2009-09-04 14:26                 ` Oleg Nesterov
2009-10-08 20:55                   ` Jiri Slaby
2009-10-12 15:13                     ` Oleg Nesterov
2009-09-03 17:20           ` [PATCH 0/1] sys_setrlimit: make sure ->rlim_max never grows Oleg Nesterov
2009-09-03 17:21           ` [PATCH 1/1] " Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).