Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5155366pxj; Tue, 22 Jun 2021 16:44:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBw638lRCKr+NCUoww0DCzFbSIBDqYV3l8A50mgy20QSG/0nE1uSdQEQPfKjxQGexZW0k3 X-Received: by 2002:a05:6602:14cd:: with SMTP id b13mr4901341iow.193.1624405478170; Tue, 22 Jun 2021 16:44:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624405478; cv=none; d=google.com; s=arc-20160816; b=Oqxi3H6VMa7bukZPEm1i9hMsI+ox9CKvG8vHAwrssmsBmObbwtIDlBDYEUbpRUcKrb vq7lUfIObfJ6Ei0gF0JxxskGl/l5s8QuRsiNP9VjHgeZoreqjDhxJngjkRgxqf4v7wIu LT987B4v/b90ezWrYX418VnjKEstM+n+kgyndd4NEPf16IVhvLwU0kt2vuxF5HeK3LBw XCGw71487tyxXOIn37dYs9iPGTf0phJ3XXo+wlSuyH/NwpktZR5RiksCwA6ztZgAf/zS ZfI+cLZAvIeIbD5hXU0i16OFUm0vI2EeP0PJDRjV2QvhzIBg5bddQPId9v3s6M1W27sk uvIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=c/7D2v+nRgLR7VWixe20ZsnX+xH+fXvtNH+YQVUf44I=; b=RBI3yR4cbtQ4JSr4ASkTWsKYsteoc47/WivyklptTd2t4qPFVLy6zMP2n3ywmv+0vN c6InNFKkw/yThnYjpesvNQHlvaIyh4gygXdMWvILhVPNDlhFP4TXmINTIqRE41IPRODk UIDxzUMZ9PfhwVM25/9EkTuHiL8gkMNoftmhMCuhoYfFT/xNEY1e+U/CEo4zVWdFmsUy RCfjtfuKlkwEZ6Osm8zb+fjlmHjCveoCt5WOBXNpYBFj2/znlU0CUT9qcpRKeKKu7q/v WRfyVXjjPTCrnyE7tnEE876xnKuE0vkiXIQr0/lTtOfepkUFzIyBJ999aL/RSh+I1oMI RfOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dlli9HAz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j18si916161jak.97.2021.06.22.16.44.26; Tue, 22 Jun 2021 16:44:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dlli9HAz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230061AbhFVXoe (ORCPT + 99 others); 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