Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp483565lqp; Mon, 10 Jun 2024 09:45:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUEu9tKi8vCjNIVumQYM4Bp2sfHQbENkb9Vl+hQ6RcdByUJjK9P/9eyly8sqwFY0nhfoHXSRNYRKOFyg10clWTsYJ+vtBxuwESZ6Lf5nw== X-Google-Smtp-Source: AGHT+IHcBAJ0D9MtgHeROuzzNgH6aUPf+7ULbRxtbIFdlAaqJXfBBXUk6u8RdQhp5m7QVB/Q9FY4 X-Received: by 2002:a2e:9789:0:b0:2eb:315d:b038 with SMTP id 38308e7fff4ca-2eb315db2e1mr51982641fa.42.1718037901390; Mon, 10 Jun 2024 09:45:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718037901; cv=pass; d=google.com; s=arc-20160816; b=sU+yYrecunCacFHMGOWpc7fUeRvX0PBQfD0LYDpYCSd+OfbL0SdU+JJHBK/OkOAKtk /sPCQAnEkdhbogjC6B5nFC7yJ4tVdAoznM55SZRYv6KxodhSLuIRwTiWLEd3TFcmJcxX GQ8rcWN1BxqfjgzgaWmlN2dWeEsbw8E81nK+4EEUYWeudO/WvyJdTcpOS53MyfQJKm96 QVtwlLukHTrlJaPI/sOzEvHgvel4+FlhBsBIRuUPPyGJ+O1sx2qye6/HYeBuWGzdmtkb 1Trhj7lOd7doAZWQ2pnpqoPffAElrDFA6L1drET/XHEGRouTgKa95RxPtjxzfhEVXBb+ uYbA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=date:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:subject:cc:to:from:dkim-signature :dkim-signature:message-id; bh=ExiTF3X05BrX2DL4sY3OO9bGQhEyAP9yIOBmxwKI0QM=; fh=joBs/8L+orz77ylyCy6wqNwwi35f7sYhLR+/TQjQjhI=; b=L0Kx/f8U0IxUvdYED0f3n7dBh7yiJW7K4w5eajgi8AMkEQEv1ZGD9DRVOFF3EIFFOV BZWTPv/6beZdxEIv+x8oFDNmrt9ktIODoFQ6LKLgZMtUtzvRs269OOVqrz2TOPWAZ6au +wUNCVZE9POLbbN8XNJKJXPEK8neuFavKRGADKQ4gyfDM/MXYtEao6fGiIgX0QqG7fI9 evk5Y1eYpS4UBeXgjdCBSjFf79UjqOCBlAPMhMZ+RJ6/99tqfEfWZVBEP4oekOB4Lb1s nrJMqXkNPvCeHELvW1jAjce6tyShl2EvtjM7Q4sI5ACD+yKNG1Be+dF3+UJTMyMBA0dr uSHg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=TqQyG4fz; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=HyupoIPi; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-208577-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208577-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f0b09c46dsi242218966b.1014.2024.06.10.09.45.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 09:45:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208577-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=TqQyG4fz; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=HyupoIPi; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-208577-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208577-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1BE761F21AC5 for ; Mon, 10 Jun 2024 16:45:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60E8C152780; Mon, 10 Jun 2024 16:42:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="TqQyG4fz"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="HyupoIPi" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17A821514C6 for ; Mon, 10 Jun 2024 16:42:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718037745; cv=none; b=HVdpUku+idZe79y4F+2wcxrLRqW6/mjMR0fYBXUkPJaoHv6EHoOlXNnGugsiGRHDuarLADCaphXUTdNHB2DF5ct6PXHODD07l7PFUTMCl0c/tCftkJ+YbfCgj0dcy00sPX8e7n7stPCjfgnUXD3jogHAI6fvmQqQD28S8N/pWw4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718037745; c=relaxed/simple; bh=dB7rimPTTgIr+XyZdIogR3o9dlxge5G3DTP9z9KIRro=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=LrTOeZ0rRmj2oxYJUHDkEXH2y+DrpVoKpn5l0ArPvz1eU0phUh93Cse5Lu0B+/1FVYerRql6aSBxq9kmRy+6+BrRCZZybhlvA/zXHGEaYVvqCptQKRjrInK5DS0OvuKwRPRpnFwt0bCgfcD7qoib5W26VMOm3G3qwoLcXRXtF1c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=TqQyG4fz; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=HyupoIPi; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Message-ID: <20240610164026.362850310@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1718037742; 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=ExiTF3X05BrX2DL4sY3OO9bGQhEyAP9yIOBmxwKI0QM=; b=TqQyG4fzZ92E8NvEtZfYOMEOfgQmWHK/xmg79xI2hWQc7KPapp5VmEf1zFafqmP3I908N7 XrQoBslnOauvrwpw0UZMHinKw5WqoNdAfMIffgbW9O4FwyfRhJcJykc0gKe1106QFeowTQ cGK1zOs8kW8OtLbUKU3l/ltCWjFqEPPW5pRERyoprodBwfGXwMaqr7BhV9jzjjm5FgOHzP PvagZ9Nf2cTd/Z6chFA4e+kleCbaqZTxMCt6TsoBF4Tq45RfTNz/bryXdGQgzWRVXSubkd 2X6w1zhMrSUPho9N8y3IsAwOnugr0rb3R5/OcKZ/USp4zEF5c5v8zMWrx5FcXQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1718037742; 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=ExiTF3X05BrX2DL4sY3OO9bGQhEyAP9yIOBmxwKI0QM=; b=HyupoIPi74IQnp8lEaZpEekIQCtRLNP4m0V8OrFwsyctihxqlqSqI/fhH+ZZsBI6LQnCr1 opKXBORHe0tqBZBQ== From: Thomas Gleixner To: LKML Cc: Anna-Maria Behnsen , Frederic Weisbecker , John Stultz , Peter Zijlstra , Ingo Molnar , Stephen Boyd , Eric Biederman , Oleg Nesterov Subject: [patch V3 14/51] posix-cpu-timers: Use @now instead of @val for clarity References: <20240610163452.591699700@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Mon, 10 Jun 2024 18:42:22 +0200 (CEST) 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 | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -622,7 +622,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; @@ -674,23 +674,19 @@ 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); /* Retrieve the previous expiry value if requested. */ if (old) { old->it_value = (struct timespec64){ }; if (old_expires) - __posix_cpu_timer_get(timer, old, val); + __posix_cpu_timer_get(timer, old, now); } if (unlikely(ret)) { @@ -706,7 +702,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); @@ -716,7 +712,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); @@ -736,7 +732,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