From patchwork Tue Jun 6 14:37:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 103910 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3464999vqr; Tue, 6 Jun 2023 08:09:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5J0JhPvfzwJWDuS6L9pYyogpJmFVW0JlBQf9HwDF2YV6eZUMyQDf7EWEjoRGYHqhW8JN1i X-Received: by 2002:a05:620a:4592:b0:75d:520b:cdb8 with SMTP id bp18-20020a05620a459200b0075d520bcdb8mr3247120qkb.35.1686064162258; Tue, 06 Jun 2023 08:09:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686064162; cv=none; d=google.com; s=arc-20160816; b=v0WudlKL3x61LuWi0MMZ8sepwRt5GWL4byo+tdV0uQb/8O39icb/EyLW0mhpR3MJAb X1tOk4I3JplTPDpo6oRZRTczZb+7c2TYtXQDETMhcTuFEnylB7SBFzGqD1GHr8fWHMyN gzHIcGMewA2iliadsKUYa/RF9JFfQwVQHTqSeLUW8qRxnwWHUPe8VMQydsV2WBxp9dGw TLMTDbcdoXXr1/Fop8RRIGKokEJV7t0Ad/qNXX3NHl+XSrxFnxu868rYZTNrlu0VU2+M o2riUmzsqoIB2Y7UMlQJ52Y2qdDaqEkwpMTCvpVM9aOOJxIaG6/OXArCtMS6N6mco7SC Z/9g== 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=ob/W6MhzxScgyFPIMc+gvNg8o5xjqBQZWBN/IorB7bE=; b=wTIBC2PweFbkAxkVPqQ9Qdu4wuFIAgwhnJ8hXLTUM3ELl9EoEES75idJHtYF2WnzMk 3zPnXtkHcwLpmpy+gSdu+n405cXv4XPa76eB8qrX3pWJFVjsm5AM/9FQ7nfVv50pCOra 43d774ktP/RsWZ6NPH8q2Tf75mDSBqWY9eLsD5DPDogJVKcgNrdJ69YY37PInal1CG/a VDGNX/5++QF8gxBV4u/lbKE3BUr9lC3OetG0l3qrEUYrKkwKhgtxllNz3gZoka002zB9 HuNbkQXU074ku458gK1RpGF7ohaWDtCPxGeuQcAeiZrKrS43AUf/kjYYUutwiHK3huUr sOWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=SCvoCkSp; dkim=neutral (no key) header.i=@linutronix.de; 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 x20-20020ae9e914000000b0075b05e65a32si4030539qkf.528.2023.06.06.08.09.08; Tue, 06 Jun 2023 08:09:22 -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=SCvoCkSp; dkim=neutral (no key) header.i=@linutronix.de; 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 S238196AbjFFOiT (ORCPT + 99 others); Tue, 6 Jun 2023 10:38:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238012AbjFFOh6 (ORCPT ); Tue, 6 Jun 2023 10:37:58 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EE6F10E0 for ; Tue, 6 Jun 2023 07:37:41 -0700 (PDT) Message-ID: <20230606142031.761271959@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686062259; 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=ob/W6MhzxScgyFPIMc+gvNg8o5xjqBQZWBN/IorB7bE=; b=SCvoCkSp2EBNPlg9q940g+JrZP6pzFOgz7FFTWpU46jD5cHmKxKnhMZjnbZ9xoPZCpn3ae FVI578SMgJamC3rLpuuE0d9oufWTkLhmu/h29m2mbczYj9XIo0jczpnqU4XebflDkC2Fdl xI7TfXR/VSOru+FfjXi95UcYj6t8ucuEJeBkHeGzzET9MmOCCDx9JdYA7BDNvIE1ufK3gL hZU043m7L2kxkfuozb1a5r3cYXeS0+IorFh837i9kxsGH85T+cx/k6J/lQxkF5kkaE8McZ T36BXvfzeE6X7FZpYYioGrJE1f7S/Ffhxf5c98hWVriw05GhCegVxf2GeNks9w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686062259; 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=ob/W6MhzxScgyFPIMc+gvNg8o5xjqBQZWBN/IorB7bE=; b=nQFBQ5ePLWCt0uAyyP09UUBBGlfIp/c+ObKLOPQeUWXRW/gOnELQ77dt6uEmoAQmjmauIu NfATje6SDz2RZGDQ== 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 13/45] posix-cpu-timers: Replace old expiry retrieval in posix_cpu_timer_set() References: <20230606132949.068951363@linutronix.de> MIME-Version: 1.0 Date: Tue, 6 Jun 2023 16:37:39 +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?1767966414945009492?= X-GMAIL-MSGID: =?utf-8?q?1767966414945009492?= Reuse the split out __posix_cpu_timer_get() function which does already the right thing. Signed-off-by: Thomas Gleixner Reviewed-by: Frederic Weisbecker --- kernel/time/posix-cpu-timers.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -609,6 +609,8 @@ static void cpu_timer_fire(struct k_itim } } +static void __posix_cpu_timer_get(struct k_itimer *timer, struct itimerspec64 *itp, u64 now); + /* * Guts of sys_timer_settime for CPU timers. * This is called with the timer locked and interrupts disabled. @@ -680,29 +682,9 @@ static int posix_cpu_timer_set(struct k_ else now = cpu_clock_sample_group(clkid, p, !sigev_none); - if (old) { - if (old_expires == 0) { - old->it_value.tv_sec = 0; - old->it_value.tv_nsec = 0; - } else { - /* - * Update the timer in case it has overrun already. - * If it has, we'll report it as having overrun and - * with the next reloaded timer already ticking, - * though we are swallowing that pending - * notification here to install the new setting. - */ - u64 exp = bump_cpu_timer(timer, now); - - if (now < exp) { - old_expires = exp - now; - old->it_value = ns_to_timespec64(old_expires); - } else { - old->it_value.tv_nsec = 1; - old->it_value.tv_sec = 0; - } - } - } + /* Retrieve the previous expiry value if requested. */ + if (old && old_expires) + __posix_cpu_timer_get(timer, old, now); /* Retry if the timer expiry is running concurrently */ if (unlikely(ret)) {