|
@@ -39,6 +39,25 @@ int sysctl_oom_kill_allocating_task;
|
|
int sysctl_oom_dump_tasks = 1;
|
|
int sysctl_oom_dump_tasks = 1;
|
|
static DEFINE_SPINLOCK(zone_scan_lock);
|
|
static DEFINE_SPINLOCK(zone_scan_lock);
|
|
|
|
|
|
|
|
+/*
|
|
|
|
+ * compare_swap_oom_score_adj() - compare and swap current's oom_score_adj
|
|
|
|
+ * @old_val: old oom_score_adj for compare
|
|
|
|
+ * @new_val: new oom_score_adj for swap
|
|
|
|
+ *
|
|
|
|
+ * Sets the oom_score_adj value for current to @new_val iff its present value is
|
|
|
|
+ * @old_val. Usually used to reinstate a previous value to prevent racing with
|
|
|
|
+ * userspacing tuning the value in the interim.
|
|
|
|
+ */
|
|
|
|
+void compare_swap_oom_score_adj(int old_val, int new_val)
|
|
|
|
+{
|
|
|
|
+ struct sighand_struct *sighand = current->sighand;
|
|
|
|
+
|
|
|
|
+ spin_lock_irq(&sighand->siglock);
|
|
|
|
+ if (current->signal->oom_score_adj == old_val)
|
|
|
|
+ current->signal->oom_score_adj = new_val;
|
|
|
|
+ spin_unlock_irq(&sighand->siglock);
|
|
|
|
+}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* test_set_oom_score_adj() - set current's oom_score_adj and return old value
|
|
* test_set_oom_score_adj() - set current's oom_score_adj and return old value
|
|
* @new_val: new oom_score_adj value
|
|
* @new_val: new oom_score_adj value
|