Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp626464lqb; Wed, 17 Apr 2024 06:41:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX6pEWIvSA+bEwCzX+udG/86VqPhtNssFpXGLR6hIgDR9kza57iJJlbif88IqRV2m9IwSZEhTF1qTPTpkh7ppBktbSGHWi+9PXx5tZtwg== X-Google-Smtp-Source: AGHT+IGW+0ju2X265TAns22pVoGRY1xgzegKbFo8jugQIRLlIt5FRI0vE6vuGqngzsH231yrTvsp X-Received: by 2002:a05:6870:7012:b0:22e:e675:69d3 with SMTP id u18-20020a056870701200b0022ee67569d3mr18520477oae.26.1713361310115; Wed, 17 Apr 2024 06:41:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713361310; cv=pass; d=google.com; s=arc-20160816; b=bZ0+Ho8+6Dha9YMq58tec3UlRVDUI5Hkp2JsuYWrTfAj8/KQsh6ZZoHeiHuweFkpDw phId+e5VSvPEAEt2WYRO0EiGjWF2Vqo7e7Za19DI14KyjHxam1tAEZ/+HFpUTPoJxz8g zLEZEj1dwWjLHcws4ewTuY9+69bZn1AAgMx1VXxhFaAZPIDYWgC/pXe3QbEDEjJZ23TT y4kIVIu53q/PrkvShMOg4lYCENbWCzGwW3c4Drj+D6rW+1IhZAoS1jQKqcQT8DU0zZld F0/XcRQA/P1vHM1Z4HrylMvTj60IWf3y6A0AUmR96Q9gYtkU8JfE9kZGhxsUcYKrYwlU u05w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=Eu9I8bD1ga5XJP8oacpJnpvCewJOm/t6+qEJfST3VTU=; fh=MxOqrKe8Fax3kxE77rA0inxVaQwZCyEyqDk4Qwcbk14=; b=CpjFz/bYte40j3FbkcuV6kPL8juC8noPeAJ+nTaHF/y7FrBRhglEI6Aosf7geTIgF9 gVw1ErzZ6RReTUzN0AzT1RZHw82a71O5xM7xKzJxtVukEyN87ggSNsVEZS1ksRROyAvt CybbvH8OT7X6o4OgXbfqFIeQe1WmqmK4ygsTmxeKoQt5KTpEsdV8kRwsKZQ08e+QOW44 +tqgiJN6AQRAjMs7fdBFwAFcQX00wszhpI46bhynWLC+Qr3X1DX2oef/gqsEmUPYUWWN WK0EBRO4E/sHShepiDj/pHMJJyCdfEn9BY1ZiueT3GQy6K7C//lFQ8ODQHxwltJ7Yvy2 lSmA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=DTuPyB01; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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-148607-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148607-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j11-20020a63550b000000b005dcc8a4590esi11440891pgb.680.2024.04.17.06.41.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 06:41:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-148607-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=DTuPyB01; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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-148607-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148607-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6959528276C for ; Wed, 17 Apr 2024 13:41:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7425D13FD9A; Wed, 17 Apr 2024 13:40:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="DTuPyB01"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="AYde4Zra" 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 1082B63A for ; Wed, 17 Apr 2024 13:40:44 +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=1713361246; cv=none; b=RnbNGDUBZnpND+StdyOuINlvntp0IrXJxyztRUntxmp42ip8A3YEldy3rQ0o16hwHgin6fcJwOO7trK+5SgoKqTKeddMH59OSekCkcLMLPkj2HfqG6YvTcW7NCiCFlwkGN8WftnyZ8YHIDWpSMFttW6Q95HcLO9fdgZSXLNKU2s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713361246; c=relaxed/simple; bh=CwT5+A+AAo9zDEcsy8FPvHCxrkbTomDQL9lgkxv8/Cs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=lR0B4nnWuI/yW6afqLpE9Ax61KUnlbwcpjsY7iCw747oNMneoh9Yes7qvJdiiH5G+LArn5AJomKr6PbDrJORI4e4c+JdcgoGXutzEaraHUk7RsbRjRIisoFC9XNry9VXbJTFQsOVFoPnrEaCaqWSOE78n1ljQBvZkhuiUXolWNU= 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=DTuPyB01; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=AYde4Zra; 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 From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1713361237; 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: in-reply-to:in-reply-to:references:references; bh=Eu9I8bD1ga5XJP8oacpJnpvCewJOm/t6+qEJfST3VTU=; b=DTuPyB01c1OA7vKv0lwQXr3cZnRdSiMDL21JZSgXDmyKUGFsp/yGgvdoPSGGyUWCQC3QYw EpDdoAsW+D8wOEmgzxRJyxE3+fTkspZQA3ZmO5aMVlS7Tv0uAIkidrCIChj6bpjetxy4aW Gd6DzHKr9QEw9MG8/LCukwY5cAVYA0wYH/blqGVXy4v/WAQrudiDZEzDZPF/hHz5PBmpa0 wp7P+l6q23odQu5NdHIoQEqQE0yWvi47uCGSW2ydMAsR3QSJztNZBhhOUAwg0HJXua4UaY kCyHtfH+lM3IxNAAm0eKIMGWN3kK2mU+D6F+QxCiE/4+A0ykox9K9dtyQHj00A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1713361237; 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: in-reply-to:in-reply-to:references:references; bh=Eu9I8bD1ga5XJP8oacpJnpvCewJOm/t6+qEJfST3VTU=; b=AYde4Zralt5QbNG2e9IISOCBoivZy35aZOD4osZB1pFlh/e8zV7nAsyaXnoWSqT/rORcoP /4avCy74h5r7Y+AA== To: Thomas Gleixner , LKML Cc: Frederic Weisbecker , John Stultz , Peter Zijlstra , Ingo Molnar , Stephen Boyd , Eric Biederman , Oleg Nesterov Subject: Re: [patch V2 31/50] posix-timers: Add proper state tracking In-Reply-To: <20240410165552.895516106@linutronix.de> References: <20240410164558.316665885@linutronix.de> <20240410165552.895516106@linutronix.de> Date: Wed, 17 Apr 2024 15:40:36 +0200 Message-ID: <8734rk5cq3.fsf@somnus> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Thomas Gleixner writes: > Right now the state tracking is done by two struct members: > > - it_active: > A boolean which tracks armed/disarmed state > > - it_signal_seq: > A sequence counter which is used to invalidate settings > and prevent rearming > > Replace it_active with it_status and keep properly track about the states > in one place. > > This allows to reuse it_signal_seq to track reprogramming, disarm and > delete operations in order to drop signals which are related to the state > previous of those operations. > > Signed-off-by: Thomas Gleixner [...] > --- a/kernel/time/posix-cpu-timers.c > +++ b/kernel/time/posix-cpu-timers.c > @@ -453,7 +453,6 @@ static void disarm_timer(struct k_itimer > struct cpu_timer *ctmr = &timer->it.cpu; > struct posix_cputimer_base *base; > > - timer->it_active = 0; > if (!cpu_timer_dequeue(ctmr)) > return; > > @@ -494,11 +493,12 @@ static int posix_cpu_timer_del(struct k_ > */ > WARN_ON_ONCE(ctmr->head || timerqueue_node_queued(&ctmr->node)); > } else { > - if (timer->it.cpu.firing) > + if (timer->it.cpu.firing) { > ret = TIMER_RETRY; > - else > + } else { > disarm_timer(timer, p); > - > + timer->it_status = POSIX_TIMER_DISARMED; > + } > unlock_task_sighand(p, &flags); > } Why do you move the update of the it_status here and do not reuse the place where you added the it_active in patch 21 "posix-cpu-timers: Make k_itimer::it_active consistent"? Then the update of the state would still be next to cpu_timer_dequeue(). [...] > @@ -647,10 +650,10 @@ void common_timer_get(struct k_itimer *t > /* interval timer ? */ > if (iv) { > cur_setting->it_interval = ktime_to_timespec64(iv); > - } else if (!timr->it_active) { > + } else if (timr->it_status == POSIX_TIMER_DISARMED) { > /* > * SIGEV_NONE oneshot timers are never queued and therefore > - * timr->it_active is always false. The check below > + * timr->it_status is always DISARMED. The check below s/DISARMED/POSIX_TIMER_DISARMED/ This change would help when using grep. > * vs. remaining time will handle this case. > * > * For all other timers there is nothing to update here, so