Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp485442lqp; Mon, 10 Jun 2024 09:48:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUeDYtf0KQa5jNz7QvU/5zbgaPeKpeI/AkIgInUPEZN6W8kWrNDfH68iUalh80hXf6A8tnw0bht1oTKvk8q+u/O/AxooUsL5A1kostT4g== X-Google-Smtp-Source: AGHT+IEoBqUNxgXXZnNQ9T4bt2t0EQ8JZ5vyahz/GAFok70g8HjWMfFyYs2ANyOnrS0/HtkXGj/R X-Received: by 2002:a05:6a00:2e05:b0:6e7:20a7:9fc0 with SMTP id d2e1a72fcca58-7040c75c139mr10518235b3a.34.1718038087929; Mon, 10 Jun 2024 09:48:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718038087; cv=pass; d=google.com; s=arc-20160816; b=nxG65D5jlXSSLXWdL0H5CrVA2wvaJX3ROwWrlLCqg+qf+KW8Yj51KcxRpmYDfJv97r ANeE7rvL0JNQu9kRpXjJUHOX0QPDyS6z+u3TD8Bb3DkEfOrv4sgJMBrsn6naU/ZaYOzZ 2PqiYQzDMCugs9SZ4T5ts9DVZckFCY1seS58jAyPUpExYSBHTVxjX62/M11g+5y5WWZn J9zZnu5iysxkJwoZ152HtcgGIVOuNjLY9FKN0r0qLSXw/B7ca8VXGSqQLUphljcYKM6s uuIsqk3dSWthidxrKi0C8dUztvdsmdrX6yjxIZ7ATMbHiBtOUVPO2AfUJPFyrNQSEA82 VSoQ== 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=uSjFneRht2ixPq2dOvLaSspY3kohFRB8UKUX6K60b2g=; fh=joBs/8L+orz77ylyCy6wqNwwi35f7sYhLR+/TQjQjhI=; b=hjz4vmtxI4GcG+c814cA9y/gOvBvWBQaBAj9aNZ9k4H3foge50yfiNd2e34ZYnW/rl TmLAZWLDsKoTj+iZNfGNZ+J9GGgA2pRn3LzLLZuPbe6AImMOVEQTtK2Zz9VyjyUO+hh+ SGkgGFLJeVzVK7MPoPmMBpmEey5ePBdgxp/yW68bxuKOmxfZ4dK5EdS01Gt6oEZ+O4qX /r8EDzgmSEtXP9u/HTpG3wN3l6zbpeoND1J0TUD7sjZ5Y11oEYcXWMCE28CojTfx6W6K z/i/RvGzK64CD9FjF5+zxCs51VNif0ASeKAEVPGY65aaBHpPO+X9sqm4Z5TnkGcorYxr iFHw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=IIlphI4D; 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-208587-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208587-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 41be03b00d2f7-6de2af07799si4776097a12.889.2024.06.10.09.48.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 09:48:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208587-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=IIlphI4D; 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-208587-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208587-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 B577F2851AA for ; Mon, 10 Jun 2024 16:47:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C93F15532C; Mon, 10 Jun 2024 16:42:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="IIlphI4D"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="4VIlzY69" 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 6C250155340 for ; Mon, 10 Jun 2024 16:42:35 +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=1718037758; cv=none; b=lRIgCeFeb1JAsqKLtCkJDYNo7dnvUc6UHK04vkw2ckcSDf/0DT/tltP8edNloqpa1JKREQ1IItZ0Gy1gpY9IZG8Gfjn8UPfbwoEW4jpWufe5y8aTICxG7ilOeYAerslR7choTZblLuI1IboVMpItH+dL2a9RsQgOb/kFB9eGi1c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718037758; c=relaxed/simple; bh=ur+O419OtXBNtUIZuacqd+BURpp8/MYytOmiM6ylieg=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=olbS/Jn9ZmQQhIvpSgkvZg9HmbRT8zKB571FsYk1JZVF4xGa2GWwUWAcK7fKNHKaD0emT9bsA6wZgYQ2K3UK698mKV+mF6NJPlMBVlsNOoRkkdBQ9vxGGJ1zfq6hOUzk0qns5NvAs+UquDTP0bTe/MzzNAmO8EBlVrM/odMZDlg= 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=IIlphI4D; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=4VIlzY69; 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.867722692@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1718037752; 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=uSjFneRht2ixPq2dOvLaSspY3kohFRB8UKUX6K60b2g=; b=IIlphI4DxXo76Kiv1YYbaSFV6tFfDDQl3uEarQkXuuPW9elSA5qNR8Tk91E9zUKeuQkGWG +CB7i/1a/QK5TRqkbf8NORCHyhn7/h65demDoE+ZTYU+/V8PBOpa7EfSNx04BarTUdWCMh 9FfXaRYaPMvg4hfcS3fJcu+d/XqKtyEUa0TooJ1MBNJM++wRry4H3mUek00ufuKSL03CE+ XK4bGp4pQp3FYO99Xc6KcvM4Mre4zyx0T48CyowT4f9Lhzu2PAFrAkbTSfNFQWdOHKRQvB F1fMd0LLmXchGBG6253zwfXqHHBDTadGlHQmpSHBXxOuznDLw6ZukmK1vGar1w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1718037752; 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=uSjFneRht2ixPq2dOvLaSspY3kohFRB8UKUX6K60b2g=; b=4VIlzY69qSPCMQ+KPst1EN9isAxCf76erVBfmxSdOShcJHy6bV8RfHbMBh+j9b42wxCkmb HPSR34lSK89OcUAw== 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 22/51] posix-timers: Consolidate signal queueing 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:32 +0200 (CEST) Rename posix_timer_event() to posix_timer_queue_signal() as this is what the function is about. Consolidate the requeue pending and deactivation updates into that function as there is no point in doing this in all incarnations of posix timers. Signed-off-by: Thomas Gleixner Reviewed-by: Frederic Weisbecker --- kernel/time/alarmtimer.c | 7 +------ kernel/time/posix-cpu-timers.c | 4 ++-- kernel/time/posix-timers.c | 21 +++++++++++---------- kernel/time/posix-timers.h | 2 +- 4 files changed, 15 insertions(+), 19 deletions(-) --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -574,15 +574,10 @@ static enum alarmtimer_restart alarm_han it.alarm.alarmtimer); enum alarmtimer_restart result = ALARMTIMER_NORESTART; unsigned long flags; - int si_private = 0; spin_lock_irqsave(&ptr->it_lock, flags); - ptr->it_active = 0; - if (ptr->it_interval) - si_private = ++ptr->it_requeue_pending; - - if (posix_timer_event(ptr, si_private) && ptr->it_interval) { + if (posix_timer_queue_signal(ptr) && ptr->it_interval) { /* * Handle ignored signals and rearm the timer. This will go * away once we handle ignored signals proper. Ensure that --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -598,9 +598,9 @@ static void cpu_timer_fire(struct k_itim /* * One-shot timer. Clear it as soon as it's fired. */ - posix_timer_event(timer, 0); + posix_timer_queue_signal(timer); cpu_timer_setexpires(ctmr, 0); - } else if (posix_timer_event(timer, ++timer->it_requeue_pending)) { + } else if (posix_timer_queue_signal(timer)) { /* * The signal did not get queued because the signal * was ignored, so we won't get any callback to --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -277,10 +277,17 @@ void posixtimer_rearm(struct kernel_sigi unlock_timer(timr, flags); } -int posix_timer_event(struct k_itimer *timr, int si_private) +int posix_timer_queue_signal(struct k_itimer *timr) { + int ret, si_private = 0; enum pid_type type; - int ret; + + lockdep_assert_held(&timr->it_lock); + + timr->it_active = 0; + if (timr->it_interval) + si_private = ++timr->it_requeue_pending; + /* * FIXME: if ->sigq is queued we can race with * dequeue_signal()->posixtimer_rearm(). @@ -309,19 +316,13 @@ int posix_timer_event(struct k_itimer *t */ static enum hrtimer_restart posix_timer_fn(struct hrtimer *timer) { + struct k_itimer *timr = container_of(timer, struct k_itimer, it.real.timer); enum hrtimer_restart ret = HRTIMER_NORESTART; - struct k_itimer *timr; unsigned long flags; - int si_private = 0; - timr = container_of(timer, struct k_itimer, it.real.timer); spin_lock_irqsave(&timr->it_lock, flags); - timr->it_active = 0; - if (timr->it_interval != 0) - si_private = ++timr->it_requeue_pending; - - if (posix_timer_event(timr, si_private)) { + if (posix_timer_queue_signal(timr)) { /* * The signal was not queued due to SIG_IGN. As a * consequence the timer is not going to be rearmed from --- a/kernel/time/posix-timers.h +++ b/kernel/time/posix-timers.h @@ -36,7 +36,7 @@ extern const struct k_clock clock_proces extern const struct k_clock clock_thread; extern const struct k_clock alarm_clock; -int posix_timer_event(struct k_itimer *timr, int si_private); +int posix_timer_queue_signal(struct k_itimer *timr); void common_timer_get(struct k_itimer *timr, struct itimerspec64 *cur_setting); int common_timer_set(struct k_itimer *timr, int flags,