From patchwork Tue Jun 6 14:37:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 103909 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3464567vqr; Tue, 6 Jun 2023 08:08:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5C1oIsJ3Q2Wau2v4eI6f2smLK5frCEXxTXcZn3N0Nd8zkYTihuPgcMtao3a+eRD77e3Lu2 X-Received: by 2002:a17:90b:4f8a:b0:258:ebb3:932 with SMTP id qe10-20020a17090b4f8a00b00258ebb30932mr1113645pjb.3.1686064135555; Tue, 06 Jun 2023 08:08:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686064135; cv=none; d=google.com; s=arc-20160816; b=ILC716FdJikFfZwaF/jOV5eJ4osroUPWH1MY/s01K/aF7o0vIqRHkXLXUfrjTTPNSJ gq+jJhh79MMKeOoSRIzcLSABEqHzSJdJiNGTfHg2yy2+c0ou1IsVaPh1skQwrCczVxqJ 14NeBgC07zFSgyzmUSXo+Cc6W/S48irXH497sVRGvKjUA9k4cUPxDDqGz21QRJJBKaqn IlJCaHHvGS5z74/cSO7JSas7kK0Ns3JiG6PJxOH7Aqdcd4jzST4XVD/evSG1QofKVftV eZ8Ph9ODPbDLkDjmJv53fQNhDu0pyteOhW/2hhTw6SBKgCrmBjrO9Qaj3hwBt8AxH/0o AMRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=HZelD7evOzJCYoBqQ1DtkrmmziVEl2j+krjTDCi41Fw=; b=TssqaOYm+Kis4d28pGADg9as6gXXZFmafZm296vtv2tRHpoNyazC85/p41IPx08CQu Xi+4fKAd5gBx5tB6uXu3EyfA+gZ7JjeTwpn5b7arIZ7jlctMELLTrsRwsY5KJqeLjcT9 KSKbWbP3CD1PVmyv00XIKnKX+pDYUXI3QGmQmOtkv5ZIRuCFfjkje7I1GgGDrOuBCkNx 3YqsK3dcUXsi5Qg4tihLYpi8YAM9v8rN2x3km3pkHqwa9rIZilEOpIFr6CYZM28/aRHl RUYovkDqztgx19dn1iqgqdNLlCXSgDFIQr4w//YNN0D4YCDkP+ZF/nJQflw3RAamjB+Q MRtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=eKWFjcJL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=DZ+CbV6p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l69-20020a638848000000b0054288b91d66si7315184pgd.635.2023.06.06.08.08.42; Tue, 06 Jun 2023 08:08:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=eKWFjcJL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=DZ+CbV6p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238146AbjFFOiI (ORCPT + 99 others); Tue, 6 Jun 2023 10:38:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238053AbjFFOhw (ORCPT ); Tue, 6 Jun 2023 10:37:52 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 815E7170B for ; Tue, 6 Jun 2023 07:37:36 -0700 (PDT) Message-ID: <20230606142031.591764431@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686062255; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=HZelD7evOzJCYoBqQ1DtkrmmziVEl2j+krjTDCi41Fw=; b=eKWFjcJLrzMr3pZrkCaPux8kc0/F5ATRMLRIkAmIXE6vAW2dLhmRu1FlnipAK8ZqAY87yN OKdVizAKcJwW+gDt6j3meD7VOb5suNceXo19xEpUev4iofYTJRl26w0Xy4alTZM/CxVXfe u5Jn1bIM2B7BbNYM9CmWdtcD7q+H7+Eh+kVl3u+Rl0NR55gR6TKNZ+Wfa38jIBGrSAX+qT SUFbn8l+kwkxvZMmCk1gb4P/lmmbv8D/ltbIfN/lrH0YwzcTdZsbdw/QYws73GyNWn9gJ0 2jXicaTUDGO28/nNj+QYy82r/Znje7VcTuELo1Q0ucGg/iEcnlgY+4yPrAurdw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686062255; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=HZelD7evOzJCYoBqQ1DtkrmmziVEl2j+krjTDCi41Fw=; b=DZ+CbV6pqD6kTZqg47gK9orPuBvbFpmsqiJfvD93glKabXigqESgkTneY7J5E6nbMULLEW 9J1HkuJTyR6CM1BQ== From: Thomas Gleixner To: LKML Cc: Frederic Weisbecker , Anna-Maria Behnsen , John Stultz , Peter Zijlstra , Ingo Molnar , Stephen Boyd , Eric Biederman , Oleg Nesterov Subject: [patch 10/45] posix-cpu-timers: Use @now instead of @val for clarity References: <20230606132949.068951363@linutronix.de> MIME-Version: 1.0 Date: Tue, 6 Jun 2023 16:37:34 +0200 (CEST) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767966387048154007?= X-GMAIL-MSGID: =?utf-8?q?1767966387048154007?= posix_cpu_timer_set() uses @val as variable for the current time. That's confusing at best. Use @now as anywhere else and rewrite the confusing comment about clock sampling. No functional change. Signed-off-by: Thomas Gleixner Reviewed-by: Frederic Weisbecker --- kernel/time/posix-cpu-timers.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -620,7 +620,7 @@ static int posix_cpu_timer_set(struct k_ { bool sigev_none = timer->it_sigev_notify == SIGEV_NONE; clockid_t clkid = CPUCLOCK_WHICH(timer->it_clock); - u64 old_expires, new_expires, old_incr, val; + u64 old_expires, new_expires, old_incr, now; struct cpu_timer *ctmr = &timer->it.cpu; struct sighand_struct *sighand; struct task_struct *p; @@ -672,17 +672,13 @@ static int posix_cpu_timer_set(struct k_ } /* - * We need to sample the current value to convert the new - * value from to relative and absolute, and to convert the - * old value from absolute to relative. To set a process - * timer, we need a sample to balance the thread expiry - * times (in arm_timer). With an absolute time, we must - * check if it's already passed. In short, we need a sample. + * Sample the current clock for saving the previous setting + * and for rearming the timer. */ if (CPUCLOCK_PERTHREAD(timer->it_clock)) - val = cpu_clock_sample(clkid, p); + now = cpu_clock_sample(clkid, p); else - val = cpu_clock_sample_group(clkid, p, !sigev_none); + now = cpu_clock_sample_group(clkid, p, !sigev_none); if (old) { if (old_expires == 0) { @@ -696,10 +692,10 @@ static int posix_cpu_timer_set(struct k_ * though we are swallowing that pending * notification here to install the new setting. */ - u64 exp = bump_cpu_timer(timer, val); + u64 exp = bump_cpu_timer(timer, now); - if (val < exp) { - old_expires = exp - val; + if (now < exp) { + old_expires = exp - now; old->it_value = ns_to_timespec64(old_expires); } else { old->it_value.tv_nsec = 1; @@ -721,7 +717,7 @@ static int posix_cpu_timer_set(struct k_ /* Convert relative expiry time to absolute */ if (new_expires && !(timer_flags & TIMER_ABSTIME)) - new_expires += val; + new_expires += now; /* Set the new expiry time (might be 0) */ cpu_timer_setexpires(ctmr, new_expires); @@ -731,7 +727,7 @@ static int posix_cpu_timer_set(struct k_ * not yet expired and the timer requires signal delivery. * SIGEV_NONE timers are never armed. */ - if (!sigev_none && new_expires && val < new_expires) + if (!sigev_none && new_expires && now < new_expires) arm_timer(timer, p); unlock_task_sighand(p, &flags); @@ -751,7 +747,7 @@ static int posix_cpu_timer_set(struct k_ timer->it_overrun_last = 0; timer->it_overrun = -1; - if (!sigev_none && val >= new_expires) { + if (!sigev_none && now >= new_expires) { if (new_expires != 0) { /* * The designated time already passed, so we notify