From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C54B1C48BDF for ; Tue, 22 Jun 2021 23:42:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A91B761374 for ; Tue, 22 Jun 2021 23:42:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230064AbhFVXoe (ORCPT ); Tue, 22 Jun 2021 19:44:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:52868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230004AbhFVXoa (ORCPT ); Tue, 22 Jun 2021 19:44:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 05D4761358; Tue, 22 Jun 2021 23:42:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624405334; bh=x14DBQuHi8zrg6SqxN0JvwP+Xd4ClaKj2rXfH3FJyZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dlli9HAzgWkyRhHDYsH6p1rjeJXv4B4ELwGsYXsyJ3yu9p4PyfmeCDyZ9GoB684Rq mrnIfNx4dtGpcxRcWkVpiMz2IweyLMcESck1cgHx1EHBkdV1VSzUSxxQ+2nKpGRIeW l1K2OisdWVMFUswZ0+qOzy2t5iTJKVhyE/Pv0dqVdpMpoa0ZMCUoB714/e13HUusbR ywKLfUfgv7OEnmTJ3SPl8/P/ciZnxaiYLPghjXaVCUmaDVEgxhyw+QDkfCfiNBE4QT WiZ95KtKTbB+FYMxUm7ea7Ny6cZ+NrONzCf453WC1G/ivg20RAigbisuxIEA+dJwxv dPWR0L07iBKqA== From: Frederic Weisbecker To: Thomas Gleixner , Peter Zijlstra Cc: LKML , Frederic Weisbecker , "Eric W . Biederman" , Oleg Nesterov , Ingo Molnar Subject: [PATCH 6/7] posix-cpu-timers: Consolidate timer base accessor Date: Wed, 23 Jun 2021 01:41:54 +0200 Message-Id: <20210622234155.119685-7-frederic@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210622234155.119685-1-frederic@kernel.org> References: <20210622234155.119685-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remove the ad-hoc timer base accessors and provide a consolidated one. Signed-off-by: Frederic Weisbecker Cc: Peter Zijlstra (Intel) Cc: Oleg Nesterov Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Eric W. Biederman --- kernel/time/posix-cpu-timers.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c index 1ac36e6ca6d6..acc6843d4b31 100644 --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -407,6 +407,17 @@ static int posix_cpu_timer_create(struct k_itimer *new_timer) return 0; } +static struct posix_cputimer_base *timer_base(struct k_itimer *timer, + struct task_struct *tsk) +{ + int clkidx = CPUCLOCK_WHICH(timer->it_clock); + + if (CPUCLOCK_PERTHREAD(timer->it_clock)) + return tsk->posix_cputimers.bases + clkidx; + else + return tsk->signal->posix_cputimers.bases + clkidx; +} + /* * Dequeue the timer and reset the base if it was its earliest expiration. * It makes sure the next tick recalculates the base next expiration so we @@ -421,18 +432,11 @@ static void disarm_timer(struct k_itimer *timer, struct task_struct *p) { struct cpu_timer *ctmr = &timer->it.cpu; struct posix_cputimer_base *base; - int clkidx; if (!cpu_timer_dequeue(ctmr)) return; - clkidx = CPUCLOCK_WHICH(timer->it_clock); - - if (CPUCLOCK_PERTHREAD(timer->it_clock)) - base = p->posix_cputimers.bases + clkidx; - else - base = p->signal->posix_cputimers.bases + clkidx; - + base = timer_base(timer, p); if (cpu_timer_getexpires(ctmr) == base->nextevt) base->nextevt = 0; } @@ -531,15 +535,9 @@ void posix_cpu_timers_exit_group(struct task_struct *tsk) */ static void arm_timer(struct k_itimer *timer, struct task_struct *p) { - int clkidx = CPUCLOCK_WHICH(timer->it_clock); + struct posix_cputimer_base *base = timer_base(timer, p); struct cpu_timer *ctmr = &timer->it.cpu; u64 newexp = cpu_timer_getexpires(ctmr); - struct posix_cputimer_base *base; - - if (CPUCLOCK_PERTHREAD(timer->it_clock)) - base = p->posix_cputimers.bases + clkidx; - else - base = p->signal->posix_cputimers.bases + clkidx; if (!cpu_timer_enqueue(&base->tqhead, ctmr)) return; -- 2.25.1