/* * This is the atomic variant of task_cputime, which can be used for * storing and updating task_cputime statistics without locking.
*/ struct task_cputime_atomic {
atomic64_t utime;
atomic64_t stime;
atomic64_t sum_exec_runtime;
};
#define INIT_CPUTIME_ATOMIC \
(struct task_cputime_atomic) { \
.utime = ATOMIC64_INIT(0), \
.stime = ATOMIC64_INIT(0), \
.sum_exec_runtime = ATOMIC64_INIT(0), \
} /** * struct thread_group_cputimer - thread group interval timer counts * @cputime_atomic: atomic thread group interval timers. * * This structure contains the version of task_cputime, above, that is * used for thread group CPU timer calculations.
*/ struct thread_group_cputimer { struct task_cputime_atomic cputime_atomic;
};
/* * NOTE! "signal_struct" does not have its own * locking, because a shared signal_struct always * implies a shared sighand_struct, so locking * sighand_struct is always a proper superset of * the locking of signal_struct.
*/ struct signal_struct {
refcount_t sigcnt;
atomic_t live; int nr_threads; int quick_threads; struct list_head thread_head;
wait_queue_head_t wait_chldexit; /* for wait4() */
/* current thread group signal load-balancing target: */ struct task_struct *curr_target;
/* shared signal handling: */ struct sigpending shared_pending;
/* For collecting multiprocess signals during fork */ struct hlist_head multiprocess;
/* thread group exit support */ int group_exit_code; /* notify group_exec_task when notify_count is less or equal to 0 */ int notify_count; struct task_struct *group_exec_task;
/* thread group stop support, overloads group_exit_code too */ int group_stop_count; unsignedint flags; /* see SIGNAL_* flags below */
struct core_state *core_state; /* coredumping support */
/* * PR_SET_CHILD_SUBREAPER marks a process, like a service * manager, to re-parent orphan (double-forking) child processes * to this process instead of 'init'. The service manager is * able to receive SIGCHLD signals and is able to investigate * the process until it calls wait(). All children of this * process will inherit a flag if they should look for a * child_subreaper process at exit.
*/ unsignedint is_child_subreaper:1; unsignedint has_child_subreaper:1;
/* ITIMER_REAL timer for the process */ struct hrtimer real_timer;
ktime_t it_real_incr;
/* * ITIMER_PROF and ITIMER_VIRTUAL timers for the process, we use * CPUCLOCK_PROF and CPUCLOCK_VIRT for indexing array as these * values are defined to 0 and 1 respectively
*/ struct cpu_itimer it[2];
/* * Thread group totals for process CPU timers. * See thread_group_cputimer(), et al, for details.
*/ struct thread_group_cputimer cputimer;
#endif /* Empty if CONFIG_POSIX_TIMERS=n */ struct posix_cputimers posix_cputimers;
/* boolean value for session group leader */ int leader;
struct tty_struct *tty; /* NULL if no tty */
#ifdef CONFIG_SCHED_AUTOGROUP struct autogroup *autogroup; #endif /* * Cumulative resource counters for dead threads in the group, * and for reaped dead child processes forked by this group. * Live threads maintain their own counters and add to these * in __exit_signal, except for the group leader.
*/
seqlock_t stats_lock;
u64 utime, stime, cutime, cstime;
u64 gtime;
u64 cgtime; struct prev_cputime prev_cputime; unsignedlong nvcsw, nivcsw, cnvcsw, cnivcsw; unsignedlong min_flt, maj_flt, cmin_flt, cmaj_flt; unsignedlong inblock, oublock, cinblock, coublock; unsignedlong maxrss, cmaxrss; struct task_io_accounting ioac;
/* * Cumulative ns of schedule CPU time fo dead threads in the * group, not including a zombie group leader, (This only differs * from jiffies_to_ns(utime + stime) if sched_clock uses something * other than jiffies.)
*/ unsignedlonglong sum_sched_runtime;
/* * We don't bother to synchronize most readers of this at all, * because there is no reader checking a limit that actually needs * to get both rlim_cur and rlim_max atomically, and either one * alone is a single word that can safely be read normally. * getrlimit/setrlimit use task_lock(current->group_leader) to * protect this instead of the siglock, because they really * have no need to disable irqs.
*/ struct rlimit rlim[RLIM_NLIMITS];
/* * Thread is the potential origin of an oom condition; kill first on * oom
*/ bool oom_flag_origin; short oom_score_adj; /* OOM kill score adjustment */ short oom_score_adj_min; /* OOM kill score adjustment min value.
* Only settable by CAP_SYS_RESOURCE. */ struct mm_struct *oom_mm; /* recorded mm when the thread group got
* killed by the oom killer */
struct mutex cred_guard_mutex; /* guard against foreign influences on * credential calculations * (notably. ptrace) * Deprecated do not use in new code. * Use exec_update_lock instead.
*/ struct rw_semaphore exec_update_lock; /* Held while task_struct is * being updated during exec, * and may have inconsistent * permissions.
*/
} __randomize_layout;
/* * Bits in flags field of signal_struct.
*/ #define SIGNAL_STOP_STOPPED 0x00000001 /* job control stop in effect */ #define SIGNAL_STOP_CONTINUED 0x00000002 /* SIGCONT since WCONTINUED reap */ #define SIGNAL_GROUP_EXIT 0x00000004 /* group exit in progress */ /* * Pending notifications to parent.
*/ #define SIGNAL_CLD_STOPPED 0x00000010 #define SIGNAL_CLD_CONTINUED 0x00000020 #define SIGNAL_CLD_MASK (SIGNAL_CLD_STOPPED|SIGNAL_CLD_CONTINUED)
#define SIGNAL_UNKILLABLE 0x00000040 /* for init: ignore fatal signals */
int force_sig_fault_to_task(int sig, int code, void __user *addr, struct task_struct *t); int force_sig_fault(int sig, int code, void __user *addr); int send_sig_fault(int sig, int code, void __user *addr, struct task_struct *t);
int force_sig_mceerr(int code, void __user *, short); int send_sig_mceerr(int code, void __user *, short, struct task_struct *);
int force_sig_bnderr(void __user *addr, void __user *lower, void __user *upper); int force_sig_pkuerr(void __user *addr, u32 pkey); int send_sig_perf(void __user *addr, u32 type, u64 sig_data);
int force_sig_ptrace_errno_trap(int errno, void __user *addr); int force_sig_fault_trapno(int sig, int code, void __user *addr, int trapno); int send_sig_fault_trapno(int sig, int code, void __user *addr, int trapno, struct task_struct *t); int force_sig_seccomp(int syscall, int reason, bool force_coredump);
/* * Returns 'true' if kick_process() is needed to force a transition from * user -> kernel to guarantee expedient run of TWA_SIGNAL based task_work.
*/ staticinlinebool __set_notify_signal(struct task_struct *task)
{ return !test_and_set_tsk_thread_flag(task, TIF_NOTIFY_SIGNAL) &&
!wake_up_state(task, TASK_INTERRUPTIBLE);
}
/* * Called to break out of interruptible wait loops, and enter the * exit_to_user_mode_loop().
*/ staticinlinevoid set_notify_signal(struct task_struct *task)
{ if (__set_notify_signal(task))
kick_process(task);
}
staticinlineint signal_pending(struct task_struct *p)
{ /* * TIF_NOTIFY_SIGNAL isn't really a signal, but it requires the same * behavior in terms of ensuring that we break out of wait loops * so that notify signal callbacks can be processed.
*/ if (unlikely(test_tsk_thread_flag(p, TIF_NOTIFY_SIGNAL))) return 1; return task_sigpending(p);
}
/* * This should only be used in fault handlers to decide whether we * should stop the current fault routine to handle the signals * instead, especially with the case where we've got interrupted with * a VM_FAULT_RETRY.
*/ staticinlinebool fault_signal_pending(vm_fault_t fault_flags, struct pt_regs *regs)
{ return unlikely((fault_flags & VM_FAULT_RETRY) &&
(fatal_signal_pending(current) ||
(user_mode(regs) && signal_pending(current))));
}
/* * Reevaluate whether the task has signals pending delivery. * Wake the task if so. * This is required every time the blocked sigset_t changes. * callers must hold sighand->siglock.
*/ externvoid recalc_sigpending(void); externvoid calculate_sigpending(void);
#ifdef TIF_RESTORE_SIGMASK /* * Legacy restore_sigmask accessors. These are inefficient on * SMP architectures because they require atomic operations.
*/
/** * set_restore_sigmask() - make sure saved_sigmask processing gets done * * This sets TIF_RESTORE_SIGMASK and ensures that the arch signal code * will run before returning to user mode, to process the flag. For * all callers, TIF_SIGPENDING is already set or it's no harm to set * it. TIF_RESTORE_SIGMASK need not be in the set of bits that the * arch code will notice on return to user mode, in case those bits * are scarce. We set TIF_SIGPENDING here to ensure that the arch * signal code always gets run when TIF_RESTORE_SIGMASK is set.
*/ staticinlinevoid set_restore_sigmask(void)
{
set_thread_flag(TIF_RESTORE_SIGMASK);
}
/* These can be the second arg to send_sig_info/send_group_sig_info. */ #define SEND_SIG_NOINFO ((struct kernel_siginfo *) 0) #define SEND_SIG_PRIV ((struct kernel_siginfo *) 1)
/* * True if we are on the alternate signal stack.
*/ staticinlineint on_sig_stack(unsignedlong sp)
{ /* * If the signal stack is SS_AUTODISARM then, by construction, we * can't be on the signal stack unless user code deliberately set * SS_AUTODISARM when we were already on it. * * This improves reliability: if user state gets corrupted such that * the stack pointer points very close to the end of the signal stack, * then this check will enable the signal to be handled anyway.
*/ if (current->sas_ss_flags & SS_AUTODISARM) return 0;
return __on_sig_stack(sp);
}
staticinlineint sas_ss_flags(unsignedlong sp)
{ if (!current->sas_ss_size) return SS_DISABLE;
/* * Without tasklist/siglock it is only rcu-safe if g can't exit/exec, * otherwise next_thread(t) will never reach g after list_del_rcu(g).
*/ #define while_each_thread(g, t) \ while ((t = next_thread(t)) != g)
/* Careful: this is a double loop, 'break' won't work as expected. */ #define for_each_process_thread(p, t) \
for_each_process(p) for_each_thread(p, t)
/* * Without tasklist or RCU lock it is not safe to dereference * the result of task_pgrp/task_session even if task == current, * we can race with another thread doing sys_setsid/sys_setpgid.
*/ staticinlinestruct pid *task_pgrp(struct task_struct *task)
{ return task->signal->pids[PIDTYPE_PGID];
}
/* * returns NULL if p is the last thread in the thread group
*/ staticinlinestruct task_struct *__next_thread(struct task_struct *p)
{ return list_next_or_null_rcu(&p->signal->thread_head,
&p->thread_node, struct task_struct,
thread_node);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.