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

Commit 244d49e3 authored by Thomas Gleixner's avatar Thomas Gleixner
Browse files

posix-cpu-timers: Move state tracking to struct posix_cputimers



Put it where it belongs and clean up the ifdeffery in fork completely.

Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20190821192922.743229404@linutronix.de
parent 8991afe2
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -77,15 +77,23 @@ struct posix_cputimer_base {
/**
 * posix_cputimers - Container for posix CPU timer related data
 * @bases:		Base container for posix CPU clocks
 * @timers_active:	Timers are queued.
 * @expiry_active:	Timer expiry is active. Used for
 *			process wide timers to avoid multiple
 *			task trying to handle expiry concurrently
 *
 * Used in task_struct and signal_struct
 */
struct posix_cputimers {
	struct posix_cputimer_base	bases[CPUCLOCK_MAX];
	unsigned int			timers_active;
	unsigned int			expiry_active;
};

static inline void posix_cputimers_init(struct posix_cputimers *pct)
{
	pct->timers_active = 0;
	pct->expiry_active = 0;
	pct->bases[0].nextevt = U64_MAX;
	pct->bases[1].nextevt = U64_MAX;
	pct->bases[2].nextevt = U64_MAX;
+6 −3
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ void thread_group_sample_cputime(struct task_struct *tsk, u64 *samples);
 */

/**
 * get_running_cputimer - return &tsk->signal->cputimer if cputimer is running
 * get_running_cputimer - return &tsk->signal->cputimer if cputimers are active
 *
 * @tsk:	Pointer to target task.
 */
@@ -80,8 +80,11 @@ struct thread_group_cputimer *get_running_cputimer(struct task_struct *tsk)
{
	struct thread_group_cputimer *cputimer = &tsk->signal->cputimer;

	/* Check if cputimer isn't running. This is accessed without locking. */
	if (!READ_ONCE(cputimer->running))
	/*
	 * Check whether posix CPU timers are active. If not the thread
	 * group accounting is not active either. Lockless check.
	 */
	if (!READ_ONCE(tsk->signal->posix_cputimers.timers_active))
		return NULL;

	/*
+0 −6
Original line number Diff line number Diff line
@@ -57,18 +57,12 @@ struct task_cputime_atomic {
/**
 * struct thread_group_cputimer - thread group interval timer counts
 * @cputime_atomic:	atomic thread group interval timers.
 * @running:		true when there are timers running and
 *			@cputime_atomic receives updates.
 * @checking_timer:	true when a thread in the group is in the
 *			process of checking for thread group 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;
	bool running;
	bool checking_timer;
};

struct multiprocess_signals {
+0 −2
Original line number Diff line number Diff line
@@ -30,8 +30,6 @@ static struct signal_struct init_signals = {
	.posix_timers = LIST_HEAD_INIT(init_signals.posix_timers),
	.cputimer	= {
		.cputime_atomic	= INIT_CPUTIME_ATOMIC,
		.running	= false,
		.checking_timer = false,
	},
#endif
	INIT_CPU_TIMERS(init_signals)
+0 −6
Original line number Diff line number Diff line
@@ -1517,7 +1517,6 @@ void __cleanup_sighand(struct sighand_struct *sighand)
	}
}

#ifdef CONFIG_POSIX_TIMERS
/*
 * Initialize POSIX timer handling for a thread group.
 */
@@ -1528,12 +1527,7 @@ static void posix_cpu_timers_init_group(struct signal_struct *sig)

	cpu_limit = READ_ONCE(sig->rlim[RLIMIT_CPU].rlim_cur);
	posix_cputimers_group_init(pct, cpu_limit);
	if (cpu_limit != RLIM_INFINITY)
		sig->cputimer.running = true;
}
#else
static inline void posix_cpu_timers_init_group(struct signal_struct *sig) { }
#endif

static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
{
Loading