/** * mark_oom_victim - mark the given task as OOM victim * @tsk: task to mark * * Has to be called with oom_lock held and never after * oom has been disabled already. * * tsk->mm has to be non NULL and caller has to guarantee it is stable (either * under task_lock or operate on the current). */ static void mark_oom_victim(struct task_struct *tsk) { struct mm_struct *mm = tsk->mm; WARN_ON(oom_killer_disabled); /* OOM killer might race with memcg OOM */ if (test_and_set_tsk_thread_flag(tsk, TIF_MEMDIE)) return; /* oom_mm is bound to the signal struct life time. */ if (!cmpxchg(&tsk->signal->oom_mm, NULL, mm)) { mmgrab(tsk->signal->oom_mm); set_bit(MMF_OOM_VICTIM, &mm->flags); } /* * Make sure that the task is woken up from uninterruptible sleep * if it is frozen because OOM killer wouldn't be able to free * any memory and livelock. freezing_slow_path will tell the freezer * that TIF_MEMDIE tasks should be ignored. */ __thaw_task(tsk); atomic_inc(&oom_victims); trace_mark_victim(tsk->pid); }
static int ssb_prctl_set(struct task_struct *task, unsigned long ctrl) { bool update; if (ssb_mode != SPEC_STORE_BYPASS_PRCTL && ssb_mode != SPEC_STORE_BYPASS_SECCOMP) return -ENXIO; switch (ctrl) { case PR_SPEC_ENABLE: /* If speculation is force disabled, enable is not allowed */ if (task_spec_ssb_force_disable(task)) return -EPERM; task_clear_spec_ssb_disable(task); update = test_and_clear_tsk_thread_flag(task, TIF_SSBD); break; case PR_SPEC_DISABLE: task_set_spec_ssb_disable(task); update = !test_and_set_tsk_thread_flag(task, TIF_SSBD); break; case PR_SPEC_FORCE_DISABLE: task_set_spec_ssb_disable(task); task_set_spec_ssb_force_disable(task); update = !test_and_set_tsk_thread_flag(task, TIF_SSBD); break; default: return -ERANGE; } /* * If being set on non-current task, delay setting the CPU * mitigation until it is next scheduled. */ if (task == current && update) speculative_store_bypass_update_current(); return 0; }
void ocd_enable(struct task_struct *child) { u32 dc; if (child) pr_debug("ocd_enable: child=%s [%u]\n", child->comm, child->pid); else pr_debug("ocd_enable (no child)\n"); if (!child || !test_and_set_tsk_thread_flag(child, TIF_DEBUG)) { spin_lock(&ocd_lock); ocd_count++; dc = ocd_read(DC); dc |= (1 << OCD_DC_MM_BIT) | (1 << OCD_DC_DBE_BIT); ocd_write(DC, dc); spin_unlock(&ocd_lock); } }