From nobody Mon Nov 25 09:47:37 2024 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 E784318C92A for ; Mon, 28 Oct 2024 07:30:19 +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=1730100622; cv=none; b=UcbYjlJ3q3V3YIZmghHjvhI0z+VwU78wcsjNyjdIBYSU5CoTYq2KPCZBf8hH6vrEJuZORY+YdjlQHvxP7TD1GNUJMmkw0Y+Mn2HPaP2aHCeGxUIqtMQWa0U3WFNfJ65LgbcF7INiERmtSoGTgi3PDx+zmBFtdVU3ehYME2vWXfc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100622; c=relaxed/simple; bh=BxtJjqOoQ38YyK+lSWhG/MIQ8Pd0KmsgfVxMerM5fXY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BKZ6EwCr7CrNUvHKbv4yBXH7rd7/rOgJC4ypW93r5B3ate5nTrYLulUe1ziy896XYwcegXYW7VUx5hHvXWmcXyvIzLecJmk6ULovW4XeDcscQMRswFxDp1nPFSiFD2wSQUO+SFzdbHxo1NqMKX1a+o0/wnMfEVEBEXxNX4OsrMQ= 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=bLVMBYPI; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=7ujLKY+U; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="bLVMBYPI"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="7ujLKY+U" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100618; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cEw6yd607c9j0hRNFj3/4bOHsEEeSWbFpAtoxc/umr4=; b=bLVMBYPIwc5Qdjpkzb0ohJjhGO8jFhbuAqMUduFYvHGW2cX8KU/7tQ+xpOUMe0fbmY+UXk bkEOzREohzHBRCc6bxb40YSjjTtCHYg2quq/HCRAfKeBbLaMAHplghat8bAvTjfDg6OxkE 3Ut8/KiLf1s+qxajsOmkKN5SVcNZU2Ssn4dWQbVr57UCvm00mnX71Jeqlkzm912BNYXokd ad2Vdw8Ml9+qekYySTOiWk/3mPY/PFurud8qnFpOyh1/TfE7zIfX6dsETeg/igldJiItU/ kb8J9PhbL2TifJxroOws8zNtDZUlltRgBlAYqHD+m5sfeMgl3LEPtxgG8pWpBQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100618; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cEw6yd607c9j0hRNFj3/4bOHsEEeSWbFpAtoxc/umr4=; b=7ujLKY+Uj33W/gkVC7/WEkziBDQQnVqsopUwDShZh8uaa8ou8wbnN4VcFsBbcYgqfR8PYa o/38ujrJAstKX2Bg== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao Subject: [PATCH 01/21] hrtimers: Add missing hrtimer_init event trace points Date: Mon, 28 Oct 2024 08:29:20 +0100 Message-Id: <6320995cb955d3ec1d8b8cbc935303f91218bb4a.1729864615.git.namcao@linutronix.de> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is the "hrtimer_init" trace event when hrtimer gets initialized. This event should also be triggered in hrtimer_init_on_stack() and hrtimer_init_sleeper_on_stack(), which is not the case if CONFIG_DEBUG_OBJECTS_TIMERS=3Dy. Make sure the "hrtimer_init" trace event is triggered properly by introducing debug_init_on_stack() which is analogous to debug_init() and call this function in hrtimer_init_on_stack() and hrtimer_init_sleeper_on_stack(). These two functions now each have a single implementation regardless of CONFIG_DEBUG_OBJECTS_TIMERS, similar to hrtimer_init() and hrtimer_init_sleeper(). Signed-off-by: Nam Cao --- include/linux/hrtimer.h | 17 +---------- kernel/time/hrtimer.c | 66 +++++++++++++++++++++++++++-------------- 2 files changed, 45 insertions(+), 38 deletions(-) diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index aa1e65ccb615..814d489cb7a2 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -230,30 +230,15 @@ extern void hrtimer_init(struct hrtimer *timer, clock= id_t which_clock, enum hrtimer_mode mode); extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, clockid_t clo= ck_id, enum hrtimer_mode mode); - -#ifdef CONFIG_DEBUG_OBJECTS_TIMERS extern void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t which_c= lock, enum hrtimer_mode mode); extern void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl, clockid_t clock_id, enum hrtimer_mode mode); =20 +#ifdef CONFIG_DEBUG_OBJECTS_TIMERS extern void destroy_hrtimer_on_stack(struct hrtimer *timer); #else -static inline void hrtimer_init_on_stack(struct hrtimer *timer, - clockid_t which_clock, - enum hrtimer_mode mode) -{ - hrtimer_init(timer, which_clock, mode); -} - -static inline void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *s= l, - clockid_t clock_id, - enum hrtimer_mode mode) -{ - hrtimer_init_sleeper(sl, clock_id, mode); -} - static inline void destroy_hrtimer_on_stack(struct hrtimer *timer) { } #endif =20 diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 04f7d8a392c3..533769777ba4 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -417,6 +417,11 @@ static inline void debug_hrtimer_init(struct hrtimer *= timer) debug_object_init(timer, &hrtimer_debug_descr); } =20 +static inline void debug_hrtimer_init_on_stack(struct hrtimer *timer) +{ + debug_object_init_on_stack(timer, &hrtimer_debug_descr); +} + static inline void debug_hrtimer_activate(struct hrtimer *timer, enum hrtimer_mode mode) { @@ -428,28 +433,6 @@ static inline void debug_hrtimer_deactivate(struct hrt= imer *timer) debug_object_deactivate(timer, &hrtimer_debug_descr); } =20 -static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id, - enum hrtimer_mode mode); - -void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t clock_id, - enum hrtimer_mode mode) -{ - debug_object_init_on_stack(timer, &hrtimer_debug_descr); - __hrtimer_init(timer, clock_id, mode); -} -EXPORT_SYMBOL_GPL(hrtimer_init_on_stack); - -static void __hrtimer_init_sleeper(struct hrtimer_sleeper *sl, - clockid_t clock_id, enum hrtimer_mode mode); - -void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl, - clockid_t clock_id, enum hrtimer_mode mode) -{ - debug_object_init_on_stack(&sl->timer, &hrtimer_debug_descr); - __hrtimer_init_sleeper(sl, clock_id, mode); -} -EXPORT_SYMBOL_GPL(hrtimer_init_sleeper_on_stack); - void destroy_hrtimer_on_stack(struct hrtimer *timer) { debug_object_free(timer, &hrtimer_debug_descr); @@ -459,6 +442,7 @@ EXPORT_SYMBOL_GPL(destroy_hrtimer_on_stack); #else =20 static inline void debug_hrtimer_init(struct hrtimer *timer) { } +static inline void debug_hrtimer_init_on_stack(struct hrtimer *timer) { } static inline void debug_hrtimer_activate(struct hrtimer *timer, enum hrtimer_mode mode) { } static inline void debug_hrtimer_deactivate(struct hrtimer *timer) { } @@ -472,6 +456,13 @@ debug_init(struct hrtimer *timer, clockid_t clockid, trace_hrtimer_init(timer, clockid, mode); } =20 +static inline void debug_init_on_stack(struct hrtimer *timer, clockid_t cl= ockid, + enum hrtimer_mode mode) +{ + debug_hrtimer_init_on_stack(timer); + trace_hrtimer_init(timer, clockid, mode); +} + static inline void debug_activate(struct hrtimer *timer, enum hrtimer_mode mode) { @@ -1600,6 +1591,23 @@ void hrtimer_init(struct hrtimer *timer, clockid_t c= lock_id, } EXPORT_SYMBOL_GPL(hrtimer_init); =20 +/** + * hrtimer_init_on_stack - initialize a timer in stack memory + * @timer: The timer to be initialized + * @clock_id: The clock to be used + * @mode: The timer mode + * + * Similar to hrtimer_init(), except that this one must be used if struct = hrtimer is in stack + * memory. + */ +void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t clock_id, + enum hrtimer_mode mode) +{ + debug_init_on_stack(timer, clock_id, mode); + __hrtimer_init(timer, clock_id, mode); +} +EXPORT_SYMBOL_GPL(hrtimer_init_on_stack); + /* * A timer is active, when it is enqueued into the rbtree or the * callback function is running or it's in the state of being migrated @@ -2001,6 +2009,20 @@ void hrtimer_init_sleeper(struct hrtimer_sleeper *sl= , clockid_t clock_id, } EXPORT_SYMBOL_GPL(hrtimer_init_sleeper); =20 +/** + * hrtimer_init_sleeper_on_stack - initialize a sleeper in stack memory + * @sl: sleeper to be initialized + * @clock_id: the clock to be used + * @mode: timer mode abs/rel + */ +void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl, + clockid_t clock_id, enum hrtimer_mode mode) +{ + debug_init_on_stack(&sl->timer, clock_id, mode); + __hrtimer_init_sleeper(sl, clock_id, mode); +} +EXPORT_SYMBOL_GPL(hrtimer_init_sleeper_on_stack); + int nanosleep_copyout(struct restart_block *restart, struct timespec64 *ts) { switch(restart->nanosleep.type) { --=20 2.39.5 From nobody Mon Nov 25 09:47:37 2024 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 670BE15EFA1 for ; Mon, 28 Oct 2024 07:30:22 +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=1730100624; cv=none; b=qoJRslXPdfAYo3UkGUWq5VKVQVB25Zut4U9HD9Ufi0DDGd0pIOwYRjpU1kJBQ4W5lciVqwUEgGkCxtG6YXP1sXVNv/CUeA9sP3x+JuZ8e/qp6gw5lPQCOdPvi5JSgNZbdN2WiV7mXmng4WsvtfD+oeSHx6RM+I1ld1xaR09ea94= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100624; c=relaxed/simple; bh=w6b5i/T1VVaux01TmW7MupzzMAE/YhWZ7cFM/9JFuJw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bRduHbw85ukyhYySytebQR+UaYcpwx24U2hnyYZw00HYKN+C+XrbpL80gajnB5jnpkhPmdHrMhXo8n1KXE/Rwr40H53QHIYlPvM3d3KsB2wCbYKlL8YB8kYXIpOJnnADEhsmks0A9BtLTuNRzELSBGtxWsqfbmccAkCiyr6Od7E= 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=lBT+R3TA; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=KfvDvQNc; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="lBT+R3TA"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="KfvDvQNc" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100620; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nZ/l/c6ufR94MIa+BdGeKTbIPK6yIIjnD9cOoHksrCA=; b=lBT+R3TA+OP024ytCfdyoLsZM+s8SyLaj683d6z1KzOxOLDVpQt3RcwEssOQ6HcXNFjymK z0Yg0auRXIPocUkHObKRO0gqsrk48LD8DjYw2MsFX6KZvEog2nUurn6Jo5egyteQfTDmOZ WQZ7rkyhvsVZl2+nsbNDfV0euuwunKoa3nYK9q+OINvs9K88lSaTgHW/OjQySy6OviPZdV uXqTFs4/1TmHNardWtLzhcgxnSMHGMr9aNAUmqlsLLAFvUUvkOmtB5ZCBYsXhVX+rGZR7k axEnRvOmZAgBHbKIg5KXZVhgWE/seNQxDGYkRAR5JYUsRPQhtJBDPWX/V7JaNg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100620; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nZ/l/c6ufR94MIa+BdGeKTbIPK6yIIjnD9cOoHksrCA=; b=KfvDvQNcsZc43Rs3BUNLWq2DboVx7NpfOCaJQjFH/EH+ETYIVuzdJcb3id5GQVsNeSVtK3 e9Czm5aY8+2GV1CQ== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao Subject: [PATCH 02/21] hrtimers: Remove unused hrtimer_init_sleeper() Date: Mon, 28 Oct 2024 08:29:21 +0100 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" hrtimer_init_sleeper() is not used. Delete it. Signed-off-by: Nam Cao --- include/linux/hrtimer.h | 2 -- kernel/time/hrtimer.c | 17 +---------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 814d489cb7a2..5aa9d57528c4 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -228,8 +228,6 @@ static inline void hrtimer_cancel_wait_running(struct h= rtimer *timer) /* Initialize timers: */ extern void hrtimer_init(struct hrtimer *timer, clockid_t which_clock, enum hrtimer_mode mode); -extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, clockid_t clo= ck_id, - enum hrtimer_mode mode); extern void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t which_c= lock, enum hrtimer_mode mode); extern void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl, diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 533769777ba4..4b0507cf38ea 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1952,7 +1952,7 @@ void hrtimer_sleeper_start_expires(struct hrtimer_sle= eper *sl, * Make the enqueue delivery mode check work on RT. If the sleeper * was initialized for hard interrupt delivery, force the mode bit. * This is a special case for hrtimer_sleepers because - * hrtimer_init_sleeper() determines the delivery mode on RT so the + * __hrtimer_init_sleeper() determines the delivery mode on RT so the * fiddling with this decision is avoided at the call sites. */ if (IS_ENABLED(CONFIG_PREEMPT_RT) && sl->timer.is_hard) @@ -1994,21 +1994,6 @@ static void __hrtimer_init_sleeper(struct hrtimer_sl= eeper *sl, sl->task =3D current; } =20 -/** - * hrtimer_init_sleeper - initialize sleeper to the given clock - * @sl: sleeper to be initialized - * @clock_id: the clock to be used - * @mode: timer mode abs/rel - */ -void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, clockid_t clock_id, - enum hrtimer_mode mode) -{ - debug_init(&sl->timer, clock_id, mode); - __hrtimer_init_sleeper(sl, clock_id, mode); - -} -EXPORT_SYMBOL_GPL(hrtimer_init_sleeper); - /** * hrtimer_init_sleeper_on_stack - initialize a sleeper in stack memory * @sl: sleeper to be initialized --=20 2.39.5 From nobody Mon Nov 25 09:47:37 2024 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 165274685 for ; Mon, 28 Oct 2024 07:30:26 +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=1730100630; cv=none; b=XztWzZmn6kg7EgDWOiAL8LgY29efyDpLQ1mNu9zpPuzE7g1IEWNh9wDvNyFaB4Y2LNe27FBw3Leu+ewZQsm7QxuuKr8JKwMuurzXfQFU1qP5ZxWcETmgR3E/1EhhE/2V78fm5qlcg7V7Id9JMxU+N+SEn8OJ6ApcleUUlUDlu30= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100630; c=relaxed/simple; bh=PZOucdBLQqrkKuLaBZ6zkJh9J1MgdoenZFjgICY3dMY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=f8Y99KllKnDRCqDo1MD+nI2zZqkcApG8f6mYn5pntGPKUMrWQUfNJM3/suaENm/PUwhmsd6w0c4hXhbeMZeyUi7zOdjOfDelWJaJino1EQsg2jBbACDZsKY6SrXFlXV4myMjwZaE1Hymcalr1Q+RmehZawEuq+brLsLnHSOA1+M= 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=eAcDo18b; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=231qBAJ2; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="eAcDo18b"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="231qBAJ2" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100625; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iHc6xPHj2No6fqNb8FT1S9lZSL5Bwgzd8FWABxlmHlo=; b=eAcDo18bXC/3JADcI4wVqY8CNS6sJOwLGgDvis0ougRoal8KczlEr+g0NkHXCVrCe5jE3d TABNtobBpoSLzrgX5xK0KZd0mvX4ZFnJv/t4x3smSx1hvneJVb8U4mnVKhFRIDHYoFIthP /PtlS+ybdzfmHx6H9GvTvsOHa3FqIY6RQC7tc8X7Fwv2Dtytedd1pW/wTvChUjpsyC705s bBXEBiHkJ+9l6OjLY+xF9l0di9JoMDL/GsjhW+LWBziIaRveSFOhQrCoKx42YMTp3G7LY3 Qe1ZOa6Am5M9GkaZcffhHo2NOilOdKyG0l34W9UdJR+P0jFiw1JiERXBKl6y5w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100625; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iHc6xPHj2No6fqNb8FT1S9lZSL5Bwgzd8FWABxlmHlo=; b=231qBAJ2LX2NNrNtqc12A9Nenn6kAw4ux6vN3d1Ugu4IlOD9INPGj7vY1PCQlEtA7mGN6P jb6+052NAsJQTEDg== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao , Jani Nikula Subject: [PATCH 03/21] drm/i915/request: Remove unnecessary abuse of hrtimer::function Date: Mon, 28 Oct 2024 08:29:22 +0100 Message-Id: <3326c75307768230c0382f9a458a0389ce0d112f.1729864615.git.namcao@linutronix.de> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When a request is created, the hrtimer is not initialized and only its 'function' field is set to NULL. The hrtimer is only initialized when the request is enqueued. The point of setting 'function' to NULL is that, it can be used to check whether hrtimer_try_to_cancel() should be called while retiring the request. This "trick" is unnecessary, because hrtimer_try_to_cancel() already does its own check whether the timer is armed. If the timer is not armed, hrtimer_try_to_cancel() returns 0. Remove the abuse of hrtimer::function and fully initialize the timer when the request is created. Then, hrtimer_try_to_cancel() can be called without touching the 'function' field. Because hrtimer_try_to_cancel() returns 0 if the timer is not armed, the logic to check whether to call i915_request_put() remains equivalent. Signed-off-by: Nam Cao --- Cc: Jani Nikula --- drivers/gpu/drm/i915/i915_request.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i91= 5_request.c index 519e096c607c..8f62cfa23fb7 100644 --- a/drivers/gpu/drm/i915/i915_request.c +++ b/drivers/gpu/drm/i915/i915_request.c @@ -273,11 +273,6 @@ i915_request_active_engine(struct i915_request *rq, return ret; } =20 -static void __rq_init_watchdog(struct i915_request *rq) -{ - rq->watchdog.timer.function =3D NULL; -} - static enum hrtimer_restart __rq_watchdog_expired(struct hrtimer *hrtimer) { struct i915_request *rq =3D @@ -294,6 +289,14 @@ static enum hrtimer_restart __rq_watchdog_expired(stru= ct hrtimer *hrtimer) return HRTIMER_NORESTART; } =20 +static void __rq_init_watchdog(struct i915_request *rq) +{ + struct i915_request_watchdog *wdg =3D &rq->watchdog; + + hrtimer_init(&wdg->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + wdg->timer.function =3D __rq_watchdog_expired; +} + static void __rq_arm_watchdog(struct i915_request *rq) { struct i915_request_watchdog *wdg =3D &rq->watchdog; @@ -304,8 +307,6 @@ static void __rq_arm_watchdog(struct i915_request *rq) =20 i915_request_get(rq); =20 - hrtimer_init(&wdg->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - wdg->timer.function =3D __rq_watchdog_expired; hrtimer_start_range_ns(&wdg->timer, ns_to_ktime(ce->watchdog.timeout_us * NSEC_PER_USEC), @@ -317,7 +318,7 @@ static void __rq_cancel_watchdog(struct i915_request *r= q) { struct i915_request_watchdog *wdg =3D &rq->watchdog; =20 - if (wdg->timer.function && hrtimer_try_to_cancel(&wdg->timer) > 0) + if (hrtimer_try_to_cancel(&wdg->timer) > 0) i915_request_put(rq); } =20 --=20 2.39.5 From nobody Mon Nov 25 09:47:37 2024 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 5A52F191F79; Mon, 28 Oct 2024 07:30:30 +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=1730100632; cv=none; b=mpA6im63l9HgEnJBpJPPD8I/6gJ8pJmghSJgED0BEOd48NECMDmuf1tQtPTjU+QPNUbGr3VPbgSRCLhrvtf1g8D4VyrMcui/ReVdFqbCC4JUuy3OJY35ZH0G2nUQ/y5At4oPzr21NmDxpNVCUza1sqdiVWMja3WRlpTPgt6n5Wo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100632; c=relaxed/simple; bh=MxYhjBjf/tvzWtOpWKpyyouzFad91PQW0/nSkr7Pexk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=T1EqeXFtL9Tv25m4pqluuZ1f4fdFsHQtF99pKGI/9Tgc/Nd9C4SdoKZFyG1JOGmDzkCx1AqhNf3taAR8icxQ8MBknLRR+DbMcT8269/yLmiIEMK52eGHkNoBpLNF6Wu6iEyJZLcOyuR9h+1x6t5PVJNmqrPjdKfEVQC+NQn7ZMQ= 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=Boi1Zg9U; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=oCPdjNXn; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Boi1Zg9U"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="oCPdjNXn" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100628; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7y7RWelbheRVtoq3d6yz9NK/DqZz1bs7H+wrQ4ILfpg=; b=Boi1Zg9UPsIBQ0baY5dSSoJ9HKobMMBSJKP3iAFcGDSn19CBv5rPcRoSV6m5feerUFoXbL bvayPi7EGctkW8iNAXKZOS9ZRAnqJVfQPXL/3Kyn1pTKbHu5mfUG4/XASpBBI8CTUbKnLu v5gCJY+JusyPE5ZFK4nwahRONEt804X3N34SCTs9EZwk5b82lncFe1FNiMoRBs966Ye42S 1e10+hczqITjisQS5AUzf33Vs+9QDoEHW4IVgqotqsVfk0jTRezvsH0U47ZvTdbsIlcOjV W5Ntzir0XClUR3UXoHWEX9NbF8KaKmgUKtcZjWZi4yBUB0o4cpTLOwUIv8wvQg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100628; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7y7RWelbheRVtoq3d6yz9NK/DqZz1bs7H+wrQ4ILfpg=; b=oCPdjNXn0ywzUwH4Xy1PuGBoOGiGNvKV7k37NYNpiuOo3iNllFN3pyyGcEBgg1w5YDfR6C at10mMx7FCz1bsBg== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao , Sean Christopherson , Paolo Bonzini , x86@kernel.org, kvm@vger.kernel.org Subject: [PATCH 04/21] KVM: x86/xen: Initialize hrtimer in kvm_xen_init_vcpu() Date: Mon, 28 Oct 2024 08:29:23 +0100 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The hrtimer is initialized in the KVM_XEN_VCPU_SET_ATTR ioctl. That caused problem in the past, because the hrtimer can be initialized multiple times, which was fixed by commit af735db31285 ("KVM: x86/xen: Initialize Xen timer only once"). This commit avoids initializing the timer multiple times by checking the field 'function' of struct hrtimer to determine if it has already been initialized. Instead of "abusing" the 'function' field, move the hrtimer initialization into kvm_xen_init_vcpu() so that it will only be initialized once. Signed-off-by: Nam Cao Acked-by: Sean Christopherson --- Cc: Sean Christopherson Cc: Paolo Bonzini Cc: x86@kernel.org Cc: kvm@vger.kernel.org --- arch/x86/kvm/xen.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c index 622fe24da910..c386fbe6b58d 100644 --- a/arch/x86/kvm/xen.c +++ b/arch/x86/kvm/xen.c @@ -1070,9 +1070,6 @@ int kvm_xen_vcpu_set_attr(struct kvm_vcpu *vcpu, stru= ct kvm_xen_vcpu_attr *data) break; } =20 - if (!vcpu->arch.xen.timer.function) - kvm_xen_init_timer(vcpu); - /* Stop the timer (if it's running) before changing the vector */ kvm_xen_stop_timer(vcpu); vcpu->arch.xen.timer_virq =3D data->u.timer.port; @@ -2235,6 +2232,7 @@ void kvm_xen_init_vcpu(struct kvm_vcpu *vcpu) vcpu->arch.xen.poll_evtchn =3D 0; =20 timer_setup(&vcpu->arch.xen.poll_timer, cancel_evtchn_poll, 0); + kvm_xen_init_timer(vcpu); =20 kvm_gpc_init(&vcpu->arch.xen.runstate_cache, vcpu->kvm); kvm_gpc_init(&vcpu->arch.xen.runstate2_cache, vcpu->kvm); --=20 2.39.5 From nobody Mon Nov 25 09:47:37 2024 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 B0E75191F85 for ; Mon, 28 Oct 2024 07:30:30 +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=1730100632; cv=none; b=AnVIHuQ3AD9NmyTOQVHrlFvkH8w75mmE85twOypSa/4z+v62i2GztyjLXtivRcYDMqXRXK/4yRqTwvRJrFzuHVN1uARFhu0yHvalGV3eNVu9hY3VxxFnvfsNZ/l2U2DEZPq1anfLR9gs1kYPAXr5lJQA1u4yGSr3Ls5e23V3RsQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100632; c=relaxed/simple; bh=rPQoYBuvRBPxXxqFYU4bdWqAsBewz/w4trzATbcPrjs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sM3YafgLk5b/6P5SDEmPq09X8nekAUkpwZDgN2otv4t2kOXkQPVdFlmetak8Jt2czxCWveS0GTK/TmIYnb5e80e9aOlZamZzFL4poaVTkVlu5LkC8BUrUzDb/L+uNO6+QIYAVGGmql7xMvmaV/Fn0CN6ccAd5qkDnie3STsSMzk= 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=MamlcB/q; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=0oBArcpf; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="MamlcB/q"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="0oBArcpf" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100629; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZHu/npypZeEz0R4NmSfWBAjA0w4EAi3CAQjNRRB7z94=; b=MamlcB/qDAXFjbOauft1QrKu+2nkd37sQA5djwbcMLqFjgsHvm/QH7u154lgcmp3yv3z2c LaDgMYUR/o7kxvBYCrLV0WvkD59k7RtBUJ0TkI3Mew448U6XhTNezIwMDJiaIQXI74LzG2 FC0gDM95FlEq0SI9SVKFqDj0mo1aJI9tcye9sykWreF7al8FRjQxL3QMmsDxoX8rGyA2QR iIhCV3UZcV5Owf/oPxMhA2EjkXN7rU+gyBKFRVEKhKwEGejuRGpL3fMixudnEoLfRhppOr unfuTKMINDn5X/uAiRghbqTgg1oc1eU6fqIePl/gqMZxptKzBWzYMrNHLl6hzQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100629; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZHu/npypZeEz0R4NmSfWBAjA0w4EAi3CAQjNRRB7z94=; b=0oBArcpfshtV+9LVfFhxbneYZdve1GjkPYUbe/PbTWgRRNzGRv9iMa5WDbtuYUGj1ZM9/C 4SO4+CenRYQvl6Cw== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao , Oliver Hartkopp , Jakub Kicinski Subject: [PATCH 05/21] can: bcm: Don't initialized an unused hrtimer Date: Mon, 28 Oct 2024 08:29:24 +0100 Message-Id: <4e7dc11aa9ffb116678574889cda35b3cd5b7385.1729864615.git.namcao@linutronix.de> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The hrtimer "thrtimer" is not used for TX. But this timer is initialized regardless. Remove the hrtimer_init() for the unused hrtimer and change bcm_remove_op() to make sure hrtimer_cancel() is not called with the uninitialized hrtimer. Signed-off-by: Nam Cao --- Cc: Oliver Hartkopp Cc: Jakub Kicinski --- net/can/bcm.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/net/can/bcm.c b/net/can/bcm.c index 217049fa496e..792528f7bce2 100644 --- a/net/can/bcm.c +++ b/net/can/bcm.c @@ -780,10 +780,11 @@ static void bcm_free_op_rcu(struct rcu_head *rcu_head) kfree(op); } =20 -static void bcm_remove_op(struct bcm_op *op) +static void bcm_remove_op(struct bcm_op *op, bool is_tx) { hrtimer_cancel(&op->timer); - hrtimer_cancel(&op->thrtimer); + if (!is_tx) + hrtimer_cancel(&op->thrtimer); =20 call_rcu(&op->rcu, bcm_free_op_rcu); } @@ -844,7 +845,7 @@ static int bcm_delete_rx_op(struct list_head *ops, stru= ct bcm_msg_head *mh, bcm_rx_handler, op); =20 list_del(&op->list); - bcm_remove_op(op); + bcm_remove_op(op, false); return 1; /* done */ } } @@ -864,7 +865,7 @@ static int bcm_delete_tx_op(struct list_head *ops, stru= ct bcm_msg_head *mh, if ((op->can_id =3D=3D mh->can_id) && (op->ifindex =3D=3D ifindex) && (op->flags & CAN_FD_FRAME) =3D=3D (mh->flags & CAN_FD_FRAME)) { list_del(&op->list); - bcm_remove_op(op); + bcm_remove_op(op, true); return 1; /* done */ } } @@ -1015,10 +1016,6 @@ static int bcm_tx_setup(struct bcm_msg_head *msg_hea= d, struct msghdr *msg, HRTIMER_MODE_REL_SOFT); op->timer.function =3D bcm_tx_timeout_handler; =20 - /* currently unused in tx_ops */ - hrtimer_init(&op->thrtimer, CLOCK_MONOTONIC, - HRTIMER_MODE_REL_SOFT); - /* add this bcm_op to the list of the tx_ops */ list_add(&op->list, &bo->tx_ops); =20 @@ -1277,7 +1274,7 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head= , struct msghdr *msg, if (err) { /* this bcm rx op is broken -> remove it */ list_del(&op->list); - bcm_remove_op(op); + bcm_remove_op(op, false); return err; } } @@ -1581,7 +1578,7 @@ static int bcm_release(struct socket *sock) #endif /* CONFIG_PROC_FS */ =20 list_for_each_entry_safe(op, next, &bo->tx_ops, list) - bcm_remove_op(op); + bcm_remove_op(op, true); =20 list_for_each_entry_safe(op, next, &bo->rx_ops, list) { /* @@ -1613,7 +1610,7 @@ static int bcm_release(struct socket *sock) synchronize_rcu(); =20 list_for_each_entry_safe(op, next, &bo->rx_ops, list) - bcm_remove_op(op); + bcm_remove_op(op, false); =20 /* remove device reference */ if (bo->bound) { --=20 2.39.5 From nobody Mon Nov 25 09:47:37 2024 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 E9329191F87; Mon, 28 Oct 2024 07:30:30 +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=1730100632; cv=none; b=NtWHjZdMu9+UrVRIeViVF205RYoFCdOywOEMJOgPvj6q6xsGI1pJ9tCOJn1OAW4s3DDqunDXqFDeRNuetzHYpBz/RHBvsggO96I8yXkK9vyYz3X2C8dUwllQ0z90WMvqeNqHLET/F7Jsd37flwjomlXSaTkYQQ/PdoM0wJR9uzg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100632; c=relaxed/simple; bh=gEj8hfRJixPu09d6XltWWSgaMWrrX/5Jug2d4qHrurE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jSnOeGo3bXilJtswZ7WnB8JPD8sZegUhhvXvSozm4uHEF9tY+aZaJl98B3DrYfiSyGpgNEHMlNftScZ0fKNtT47sbU5gAJJ/vqxdCxhT1YeEMzqAiLck5PZmXcMKlTlHl2fkSZgwTAfv6aYpTgtp0Yr0ecCIZtEup4Zl7yzAsHM= 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=ER4Cq0y/; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=r8PIDNUt; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ER4Cq0y/"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="r8PIDNUt" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100629; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ifpNs9cq3xZGK6onfKtgO1rlAC0KnSk/1Gk7YaYxPlc=; b=ER4Cq0y/of1ZLoZGKTw84WlastfotZEgHV6FOMqrgU8qNhjjcVkb9GqJBl0Cw9t1UJNTet 1OSqD+0whpCn+OWgxShRlxDKkGCO4UUtMiYM9vEcnAHkw4D9V+TVe+tMEnEFx+33O7BdUJ j+D33yBQW8XaezLrrv0nhpxYU4Rqe/28SYRTb8blSrTIWew5RqhG01/c1xptTEtkReV1b0 LAJuLubmZhWUWOm7cnLSUmT7WxM0Eg9oe07nCbh0HM+1ZzuzrQ1aHeCgKjjxyCJ2eS0fCY IL5u7hBl74tySDukQvucpzn9GAgxkhg4y7HCnq2+b1VFg5YXAcDaN/TkZEMaaQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100629; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ifpNs9cq3xZGK6onfKtgO1rlAC0KnSk/1Gk7YaYxPlc=; b=r8PIDNUt3md+Th6EFcTFkq2ttEqf6uJAmRYA9mg1UIXC2L2q4qrLguuBqagc61t1Viwda1 xar03ytlja3g3cCA== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao , Kalle Valo , linux-wireless@vger.kernel.org Subject: [PATCH 06/21] wifi: rt2x00: Remove redundant hrtimer_init() Date: Mon, 28 Oct 2024 08:29:25 +0100 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" rt2x00usb_probe() executes a hrtimer_init() for txstatus_timer. Afterwards, rt2x00lib_probe_dev() is called which also initializes this txstatus_timer with the same settings. Remove the redundant hrtimer_init() call in rt2x00usb_probe(). Signed-off-by: Nam Cao --- Cc: Kalle Valo Cc: linux-wireless@vger.kernel.org --- drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c b/drivers/net/w= ireless/ralink/rt2x00/rt2x00usb.c index 8fd22c69855f..a6d50149e0c3 100644 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c @@ -823,8 +823,6 @@ int rt2x00usb_probe(struct usb_interface *usb_intf, =20 INIT_WORK(&rt2x00dev->rxdone_work, rt2x00usb_work_rxdone); INIT_WORK(&rt2x00dev->txdone_work, rt2x00usb_work_txdone); - hrtimer_init(&rt2x00dev->txstatus_timer, CLOCK_MONOTONIC, - HRTIMER_MODE_REL); =20 retval =3D rt2x00usb_alloc_reg(rt2x00dev); if (retval) --=20 2.39.5 From nobody Mon Nov 25 09:47:37 2024 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 AE81615EFA1 for ; Mon, 28 Oct 2024 07:30:31 +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=1730100633; cv=none; b=mJW6OEGsJKHZ47NabMqeJp380rFP4I9R4eodjvfgN621UhhHRMDi9lpZD3vAJk72aGC3FwVNCGIIEZNdnHZIZvTd7wJDWdAqALcnYCZfcRS77y2nR4JL+Xz/Lbl8VVYqodiuJYC69uJq4ecfw7/yezkKv0zQ9aKJ63WG6FuFou4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100633; c=relaxed/simple; bh=Y4sc8uvLB5tZSTIwkWXcFtWHyLAOZiC1u0cSBzzPJHE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hEoHW/Cn2Dm+8+9uIg5nRSr0LVdsfkM9jCb4mlL+k7dVL//51rJnyb1Kpql29aG7jA9nGoY1ILoiIiHjgj8bYeSF49kMdSdSjpZVZzEtfgabSaeommJlqxAclevN/eJSHTQ8a9buanTY4YM+QWQa3BsPWORqDZxi6jkGc7WuZz4= 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=ZA4agdT/; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=+XidrmnK; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ZA4agdT/"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="+XidrmnK" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100629; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FpvILPcEEZYBzJpW+S8htdJ1Ku71+tSghbMeHdyKSws=; b=ZA4agdT/GIAzq8UKYB5VjZb9I6K6woN0B+3qmFhppakmSs69MG+1sTKk/N+h2GafdVgEgA GTgCK72j52aX7Y6wNspe2owiwraEg0bLYUCFz3Su0MxM7YYCoiSNAVYh6q0DuNrxDaEEGs lI1kWPqLw27zLS/V8v0K7YkYJBsCXRpMwEFaEi1/wknjEJWz02GORz1iY5jrv40Ogole+o Och0+KKk2Sp8aEvcN4nXowe6Fs4p84lAaJok6Ys/Qw1Sz85xNaxIJys4M+HhgAwPEadNJi qEgws0jCvVemWNjz5CwIwFZY1xlmjVWBh4zF7nz+TgxKvekCcwcDVHvo1OwxAw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100629; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FpvILPcEEZYBzJpW+S8htdJ1Ku71+tSghbMeHdyKSws=; b=+XidrmnKHrcvjg9TUbV+TDgKU1Gr4p4Uaf32vLOBE0P3Lovkjxym5heX9b6Jphy18LK9YE W0gPI/uulUwA+/Cw== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao , Jens Axboe Subject: [PATCH 07/21] io_uring: Remove redundant hrtimer's callback function setup Date: Mon, 28 Oct 2024 08:29:26 +0100 Message-Id: <61a7783e6359b77338f6b2e87c1f19de4b3508de.1729864615.git.namcao@linutronix.de> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The IORING_OP_TIMEOUT command uses hrtimer underneath. The timer's callback function is setup in io_timeout(), and then the callback function is setup again when the timer is rearmed. Since the callback function is the same for both cases, the latter setup is redundant, therefore remove it. Signed-off-by: Nam Cao --- Cc: Jens Axboe --- io_uring/timeout.c | 1 - 1 file changed, 1 deletion(-) diff --git a/io_uring/timeout.c b/io_uring/timeout.c index 9973876d91b0..2ffe5e1dc68a 100644 --- a/io_uring/timeout.c +++ b/io_uring/timeout.c @@ -76,7 +76,6 @@ static void io_timeout_complete(struct io_kiocb *req, str= uct io_tw_state *ts) /* re-arm timer */ spin_lock_irq(&ctx->timeout_lock); list_add(&timeout->list, ctx->timeout_list.prev); - data->timer.function =3D io_timeout_fn; hrtimer_start(&data->timer, timespec64_to_ktime(data->ts), data->mode); spin_unlock_irq(&ctx->timeout_lock); return; --=20 2.39.5 From nobody Mon Nov 25 09:47:37 2024 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 F0C58191F91 for ; Mon, 28 Oct 2024 07:30:31 +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=1730100634; cv=none; b=hAw/scY6eveQmOVnTHZUHMeu9lovUhnSjbaow2cB5iJ7rj+jxRaanfA+NYhOrZbN+cQ2s1tamQi5xMkXC0gk9ENNs7NtzroRS/zPEFdG9Neih2HUeQeWQEeBmrHElPMW1Q1rVhRLlIdiqocDqLs1TaB/fWGcli30Jcc1I7VaXSg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100634; c=relaxed/simple; bh=Hj3C6EZ8cwxl6BeA5KWcnO9yDSQ7xz0TVN71quWr8uE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n7JQJIMFkYQZRi6CNWWuni/A93RqxL5r7Cki+tj5GOSMAxrEa/yk4d5/87Ch9QLT0fyzsZU+Fcju+a9SnTU+9DOVOVvCEIkm7h2Wah5iD0AZpbFSz9AznHYB3aSEyAalA88ibSocZL/WDzw8rVNrYUWiXb2agR2+1EGlUaSphWg= 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=BcBTeNw1; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=7z9s6Zxr; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="BcBTeNw1"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="7z9s6Zxr" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100630; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N3cxdO1hcAE4AUoe+zcWrRKQNPwx3jps5mImQ9N2A+0=; b=BcBTeNw1KY2OLf1xEQ1ThpTDYu7NefFRpWh2S7SyxixqNtPA5gko6lp0z+3bB1NuS0fObn N2/DXxpkDavx8Sf1zjD6RMYcLBmK/yIhvVzVn+VAyI4HoqjoQdABm2PHA5PSSfGuk1oGDb 3zC5fT5eXjIixt8hGtLcoG3zc8mbyp0B8o2gEg6nMzqyKywWKR7EmNyVx0rbmSbEan1WIG FLLrrAxEcvoWHG4QKhLuSt23kw8TBxuCOO6IoLp95/N/B46hBH4EZHCblIsVCjhwa6N8Tm igAevF/ZgGk0nm9lKJ0z/MdFtsXOlgNr8rAq2VHOTJlflszXcoq2EKJrfRk/yw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100630; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N3cxdO1hcAE4AUoe+zcWrRKQNPwx3jps5mImQ9N2A+0=; b=7z9s6ZxrvfoRX7xh952MQAHFoO/xERI/UAEEKr+JmmwhKHRwwPMom/b5lCcyxHe7IYELzn 66a5UirBkNLKZ1Bw== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao Subject: [PATCH 08/21] hrtimers: Introduce hrtimer_setup() to replace hrtimer_init() Date: Mon, 28 Oct 2024 08:29:27 +0100 Message-Id: <2159c09badceec667d800005ac98824105ba8dc6.1729864615.git.namcao@linutronix.de> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To initialize hrtimer, hrtimer_init() needs to be called and also struct hrtimer::function must be set. Introduce hrtimer_setup() which does both of these things, so that users of hrtimer can be simplified. The new function also does sanity check on the callback function pointer from user. If the function pointer is invalid, initialize 'function' with a dummy callback, so that the kernel doesn't blow up later on. hrtimer_init() will be removed as soon as all of its users have been converted to the new function. Signed-off-by: Nam Cao --- include/linux/hrtimer.h | 2 ++ kernel/time/hrtimer.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 5aa9d57528c4..bcc0715c59a8 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -228,6 +228,8 @@ static inline void hrtimer_cancel_wait_running(struct h= rtimer *timer) /* Initialize timers: */ extern void hrtimer_init(struct hrtimer *timer, clockid_t which_clock, enum hrtimer_mode mode); +extern void hrtimer_setup(struct hrtimer *timer, enum hrtimer_restart (*fu= nction)(struct hrtimer *), + clockid_t clock_id, enum hrtimer_mode mode); extern void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t which_c= lock, enum hrtimer_mode mode); extern void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl, diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 4b0507cf38ea..a5ef67edcda9 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1535,6 +1535,11 @@ static inline int hrtimer_clockid_to_base(clockid_t = clock_id) return HRTIMER_BASE_MONOTONIC; } =20 +static enum hrtimer_restart hrtimer_dummy_timeout(struct hrtimer *unused) +{ + return HRTIMER_NORESTART; +} + static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id, enum hrtimer_mode mode) { @@ -1571,6 +1576,18 @@ static void __hrtimer_init(struct hrtimer *timer, cl= ockid_t clock_id, timerqueue_init(&timer->node); } =20 +static void __hrtimer_setup(struct hrtimer *timer, + enum hrtimer_restart (*function)(struct hrtimer *), + clockid_t clock_id, enum hrtimer_mode mode) +{ + __hrtimer_init(timer, clock_id, mode); + + if (WARN_ON_ONCE(!function)) + timer->function =3D hrtimer_dummy_timeout; + else + timer->function =3D function; +} + /** * hrtimer_init - initialize a timer to the given clock * @timer: the timer to be initialized @@ -1591,6 +1608,27 @@ void hrtimer_init(struct hrtimer *timer, clockid_t c= lock_id, } EXPORT_SYMBOL_GPL(hrtimer_init); =20 +/** + * hrtimer_setup - initialize a timer to the given clock + * @timer: the timer to be initialized + * @function: the callback function + * @clock_id: the clock to be used + * @mode: The modes which are relevant for initialization: + * HRTIMER_MODE_ABS, HRTIMER_MODE_REL, HRTIMER_MODE_ABS_SOFT, + * HRTIMER_MODE_REL_SOFT + * + * The PINNED variants of the above can be handed in, + * but the PINNED bit is ignored as pinning happens + * when the hrtimer is started + */ +void hrtimer_setup(struct hrtimer *timer, enum hrtimer_restart (*function)= (struct hrtimer *), + clockid_t clock_id, enum hrtimer_mode mode) +{ + debug_init(timer, clock_id, mode); + __hrtimer_setup(timer, function, clock_id, mode); +} +EXPORT_SYMBOL_GPL(hrtimer_setup); + /** * hrtimer_init_on_stack - initialize a timer in stack memory * @timer: The timer to be initialized --=20 2.39.5 From nobody Mon Nov 25 09:47:37 2024 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 52174191F9C for ; Mon, 28 Oct 2024 07:30:32 +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=1730100634; cv=none; b=H+jN9jNDJN4vb9D9FoDJGT12PIYUV5SV7XhAKtOdTGt73nH0le/1wjsOgqG3BYiPQvF4fHzBjyreIylA+rzCKhje12R7/gYs7OkRUvcUZeuLpvC15K10ZDFajOEtTFPD1+U7MEVYHgMJR/JM9b5yhxMigWT2z2TnAkKQLv1PGps= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100634; c=relaxed/simple; bh=/TiV3JZyyoDCuhZwy3q7qmd+NClcP5OpUDNnTdfw/FQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Nx0yQnNd4YLEzr2fTjfEjr236olq4vA3znHusmNEtmuQpjWFEaiH4q7lbJ/yrWRu7WdDDutKlpUX+HGk/oy8/5nKsc8+8ZQRSBXPOUSJUIvFeVDO5TWMtfjBYf9GLneKLdC3ANcVeAtfAJDUaKUxSpX77Qz60H3IaqUZFcAyzFc= 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=Ketm5QGj; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=8NQyUa0l; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Ketm5QGj"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="8NQyUa0l" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100630; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C0XVO90iLQ7PE7PoHD7NMl5oQGpGsAUbSQs5v9r9boQ=; b=Ketm5QGjD10DDXZX/BACxxPNHvKwPglzdn3L6ds75Ki7ZDbEfujHtVIlySXg+vn36MMc+7 qu53k6bZVyx0fMrMv6oCKiSqCQ67G6ric1udyi1HuvPwo9NoGSaHcXIYbqDERfrRwp5+FX te7y7JY0nyGHyM8tY1LNQ4+1hQIy2z+KLS+J0sBW50RaKTzHhaiLnRBt2I/rIF30rhFgSN pLrwXnyEG/NuWaqV4V314DRkRMSmX//ITTXawGQFb7FJz4/Ackxmhh3tjxu0LibMzZKVpF /6h+YwbOV3EhUx8SRqKeuCznkYYayT6D3RxKWlqyBgYFluHZei9xDMC2+OV1Jw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100630; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C0XVO90iLQ7PE7PoHD7NMl5oQGpGsAUbSQs5v9r9boQ=; b=8NQyUa0lGolXaPje5Zv5PuTAERG/5LjcVtBJu9vVLC+y438xoSuqXu4+c8wpt92C8w9iCJ mUgRPA4Bwg/4jyCg== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao Subject: [PATCH 09/21] hrtimers: Introduce hrtimer_setup_on_stack() Date: Mon, 28 Oct 2024 08:29:28 +0100 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To initialize hrtimer on stack, hrtimer_init_on_stack() needs to be called and also struct hrtimer::function must be set. Introduce hrtimer_setup_on_stack() which does both of these things, so that users of hrtimer can be simplified. This function also does sanity check on the callback function pointer. If the callback function pointer is invalid, set 'function' to a dummy callback function, so that the kernel does not blow up later on. hrtimer_init_on_stack() will be removed as soon as all of its users have been converted to the new function. Signed-off-by: Nam Cao --- include/linux/hrtimer.h | 3 +++ kernel/time/hrtimer.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index bcc0715c59a8..2da513f8d66a 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -232,6 +232,9 @@ extern void hrtimer_setup(struct hrtimer *timer, enum h= rtimer_restart (*function clockid_t clock_id, enum hrtimer_mode mode); extern void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t which_c= lock, enum hrtimer_mode mode); +extern void hrtimer_setup_on_stack(struct hrtimer *timer, + enum hrtimer_restart (*function)(struct hrtimer *), + clockid_t clock_id, enum hrtimer_mode mode); extern void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl, clockid_t clock_id, enum hrtimer_mode mode); diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index a5ef67edcda9..daee4e27f839 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1646,6 +1646,25 @@ void hrtimer_init_on_stack(struct hrtimer *timer, cl= ockid_t clock_id, } EXPORT_SYMBOL_GPL(hrtimer_init_on_stack); =20 +/** + * hrtimer_setup_on_stack - initialize a timer on stack memory + * @timer: The timer to be initialized + * @function: the callback function + * @clock_id: The clock to be used + * @mode: The timer mode + * + * Similar to hrtimer_setup(), except that this one must be used if struct= hrtimer is in stack + * memory. + */ +void hrtimer_setup_on_stack(struct hrtimer *timer, + enum hrtimer_restart (*function)(struct hrtimer *), + clockid_t clock_id, enum hrtimer_mode mode) +{ + debug_init_on_stack(timer, clock_id, mode); + __hrtimer_setup(timer, function, clock_id, mode); +} +EXPORT_SYMBOL_GPL(hrtimer_setup_on_stack); + /* * A timer is active, when it is enqueued into the rbtree or the * callback function is running or it's in the state of being migrated --=20 2.39.5 From nobody Mon Nov 25 09:47:37 2024 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 A8EE94685 for ; Mon, 28 Oct 2024 07:30:33 +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=1730100635; cv=none; b=qCb7OkQioHWIPAsuNw4D0xzVCHXcgzAG5t30XTtat62+mxShNnIpq6ADsf1OrH4Vd/22wqXAP8O9kJ48UztuHQKq0hrGiIEDidIssog/Ws29yMQ5VoWJQO4aYwrRz+nO1iCanbcnJ6+qrsstR33i/IOUWHoVAbi4s0opMgboIlY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100635; c=relaxed/simple; bh=m95rj/Pg7jxnHdOd2G91tOu5rlRz/g+shSHe+A0RntA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NDgsEkzBRu4dEWsC0pUbD0FfgyzYlWWjXZfwqGluwuJvb8J4cpsRtdGXk9xUIKBdygQPrTSZz3adiGyvBL3ahDRonfW0C1r88/xu5LtNFQ/wXZyFYyJnqt8EmD5XnoiyzF8GCZgO0sy9qj7ojzhb71eUmK/mtAa+lpXbb0iCP4M= 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=CrNm3WSv; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=0oBJUaiF; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="CrNm3WSv"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="0oBJUaiF" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100631; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nItAbF4ba+O/4+a1zT7+rDPb5gC8aLbVN70IhsEWi5o=; b=CrNm3WSvd/eXu96nMLarF3jc/5M6TRPlAdCMyJc6Gv40XtHR7pg2Kqiw00fkaRRJY4ebXQ 5UwOQJdOf45IWV01hw7ObZqDG21tjvv/CrZiXhxT2JENijW1LfUFhklu13vh8VeNdp6d/r Oy/OF4SE0XigbvfeevCntWgtuL405aEz7hDyOD5r/2xjLEj6MNeYQeEcaNmZOtqxZy6o9N y6neix1MsdNXiknlAEkp95o+TozADJfDv6nKrq2gf0xgpyT9o+mRXEX521gpTmf5fzJ+33 ARCLajaOELT7FzUe6k78Gd3jq52nCh3cytF1X3oShXjtqttAABhSoZz2kmSu9g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100631; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nItAbF4ba+O/4+a1zT7+rDPb5gC8aLbVN70IhsEWi5o=; b=0oBJUaiFQQiKU3UoUcH8Jh1kDJalFcN+5fErzKyoN0PD17CC/Sdxy7ZCSzt2Gy8MQBEfFO FLlgKVPfeUwK9gAg== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao Subject: [PATCH 10/21] hrtimers: Introduce hrtimer_setup_sleeper_on_stack() Date: Mon, 28 Oct 2024 08:29:29 +0100 Message-Id: <77c7c39cc8ae350c14a2116f8b827f71c41bcacb.1729864615.git.namcao@linutronix.de> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" hrtimer_setup() and hrtimer_setup_on_stack() have been introduced to replace hrtimer_init() and hrtimer_init_on_stack(). To keep the names consistent, also introduce hrtimer_setup_sleeper_on_stack(). The old name hrtimer_init_sleeper_on_stack() will be removed as soon as all of its users have been updated. Signed-off-by: Nam Cao --- include/linux/hrtimer.h | 2 ++ kernel/time/hrtimer.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 2da513f8d66a..48872a2b4071 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -238,6 +238,8 @@ extern void hrtimer_setup_on_stack(struct hrtimer *time= r, extern void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl, clockid_t clock_id, enum hrtimer_mode mode); +extern void hrtimer_setup_sleeper_on_stack(struct hrtimer_sleeper *sl, clo= ckid_t clock_id, + enum hrtimer_mode mode); =20 #ifdef CONFIG_DEBUG_OBJECTS_TIMERS extern void destroy_hrtimer_on_stack(struct hrtimer *timer); diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index daee4e27f839..1d1f5c03673c 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -2065,6 +2065,20 @@ void hrtimer_init_sleeper_on_stack(struct hrtimer_sl= eeper *sl, } EXPORT_SYMBOL_GPL(hrtimer_init_sleeper_on_stack); =20 +/** + * hrtimer_setup_sleeper_on_stack - initialize a sleeper in stack memory + * @sl: sleeper to be initialized + * @clock_id: the clock to be used + * @mode: timer mode abs/rel + */ +void hrtimer_setup_sleeper_on_stack(struct hrtimer_sleeper *sl, + clockid_t clock_id, enum hrtimer_mode mode) +{ + debug_init_on_stack(&sl->timer, clock_id, mode); + __hrtimer_init_sleeper(sl, clock_id, mode); +} +EXPORT_SYMBOL_GPL(hrtimer_setup_sleeper_on_stack); + int nanosleep_copyout(struct restart_block *restart, struct timespec64 *ts) { switch(restart->nanosleep.type) { --=20 2.39.5 From nobody Mon Nov 25 09:47:37 2024 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 EC66E192B60 for ; Mon, 28 Oct 2024 07:30:33 +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=1730100636; cv=none; b=CjoEb5u3/R8Wyek01P0bwugJeLsr1MGIDnndZr/yWTDqZRfBo8lQW7kEQCuuXRButRKZ1LJtexnYyP7T1JAFqcie7KTfMX1oonFnztlF6cDofT8MHchObk+kl1+Qm2eIw0nU4Ud4ErWwy0LCm7bvlftPiIhaUSIAJGhOvdmBy70= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100636; c=relaxed/simple; bh=VGdxVDo6ASMFPWX2sDzqlW/Dhjo5IawnrhXDtIMp0EM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Nu04brvp9yw+j+uoANDfU5c267P9qXdZjrkq4pZ2qZkwqwidYlZfNtqf8Klkc+7/F0Pqkoqbwee2Xs3bbMlS4eAcRvUrmY8Pm/Qa/nJgJ0lMDTj3rmClmAdjCC6zTh4hMemtSL/cPDAKhslWXmpWcwa6cLtY4BaZFwvunTLQNTM= 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=JZIOfWJF; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ci6+6RmJ; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="JZIOfWJF"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ci6+6RmJ" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100631; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Bm8biOfFQ9hw4SGs0WskkwgwYHgdOlauZhBLT/M7a4M=; b=JZIOfWJFS4E0h0v8VW2jG5J+VU7Ojobm85Zphc6WXDVrlGCciFwd4DJvSw1uIPJj5xh9zp 8dBgM1q0Kzl6Udm4TQjovHIEAJMAA1gjs6DJEaVF9T9MmNJHYUf0ixncGzSbiixhOC7eVH 1Eb/B6Vmwfgb/pIccO+EM5BOfqxG8V6EZ1yLvIIhUfEzaQXampImcmkPhg8Z5sGBqWZiqR bAMgpxHw7z0KeT9bJjIlZSSEJI9vwk/NLQvVf3QSTQFtqF3OkCouYR/xAEaDIuwhFxGwKc Wk+d+fa3i/6mNJu1cvq0EasqkQXUO+5egExAgkwHWfwRyX+feCQyeFH4+D7GJw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100631; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Bm8biOfFQ9hw4SGs0WskkwgwYHgdOlauZhBLT/M7a4M=; b=ci6+6RmJi67ARkwzGYNsBwMSpf9DYNYWxyoURVuBGXlwIQGcS/0CSWMg38WYmH1mw1sRON 8RITC3xAzgXPi8DQ== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao Subject: [PATCH 11/21] hrtimers: Introduce hrtimer_update_function() Date: Mon, 28 Oct 2024 08:29:30 +0100 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Some users of hrtimer need to change the callback function after the initial setup, and they touch the 'function' field of struct hrtimer directly. However, directly changing the 'function' field is not safe under all circumstances. It's only safe when the hrtimer is not enqueued. Introduce hrtimer_update_function() helper function, which also performs runtime checks whether it is safe (i.e. the timer is not enqueued). The field 'function' of struct hrtimer will be changed to private in the future. Signed-off-by: Nam Cao --- include/linux/hrtimer.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 48872a2b4071..6e026730e803 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -327,6 +327,28 @@ static inline int hrtimer_callback_running(struct hrti= mer *timer) return timer->base->running =3D=3D timer; } =20 +/** + * hrtimer_update_function - Update the timer's callback function + * @timer: Timer to update + * @function: New callback function + * + * Only safe to call if the timer is not enqueued. Can be called in the ca= llback function if the + * timer is not enqueued at the same time (see the comments above HRTIMER_= STATE_ENQUEUED). + */ +static inline void hrtimer_update_function(struct hrtimer *timer, + enum hrtimer_restart (*function)(struct hrtimer *)) +{ + guard(raw_spinlock_irqsave)(&timer->base->cpu_base->lock); + + if (WARN_ON_ONCE(hrtimer_is_queued(timer))) + return; + + if (WARN_ON_ONCE(!function)) + return; + + timer->function =3D function; +} + /* Forward a hrtimer so it expires after now: */ extern u64 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval); --=20 2.39.5 From nobody Mon Nov 25 09:47:37 2024 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 88710192B7A for ; Mon, 28 Oct 2024 07:30:34 +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=1730100636; cv=none; b=ooRyYjw/TV6KDYECI0a6DU9wA2dm7fv2V0hemgsHZcX4HREpkUDDcZVpW3N5i3Sunx22e539u6z7NxdAu/gN2vzQfPsYfnckQikOZL9bQ/bTGyD6/pL4wBM+P1+TaFDrBMJUz62NvaUgJFpp1L4pfdu/wFJbNoMwgZyC5VmMKlg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100636; c=relaxed/simple; bh=71b5zUUJ/UGx5uVYhEk5oBVg4LyLSar6M9kLrnKWKcI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=q3cFh7bRPvMIg65hlF51WOESuiMzcP+v+O65biC0hiD+LGXVNmCbdpJcoa/CkqSbWeEt/i14MdCaTEx9yO2GwbQJK0e5neEb8z4za2cgsigerLod/pQ2mMmRo+QOKVJ15mzpsVuzVj5eVMHEnIMUD77rB83XLgtyv06pP1vVQo8= 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=BxPIdR2y; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=/Pix/2IZ; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="BxPIdR2y"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="/Pix/2IZ" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100631; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bQ891FWRaeZntw5HFf5qoaiNenDTaKPknthYCbWCOSA=; b=BxPIdR2yTzlvpkfPdHE8QdI45SrMcVIxBMm+n7E9P5kexXHrw00lLccTyaj1IIH83SRt0l tcaI1EoeqSjGDBDMZ/AdF6w4HEEI60UZy05BB609A62oRNIA7Ydrbzx7S/OeuLZeuKS0Rk 5+IEnOQPq3PV1GQHQ+SW3wH63mb1rRT5GTD2vqI29SruSWiSRC3z8Tx7u3clEC+wnQqGvz 6temfRihbBuNakhVGjU7xjhqFsUUUvtDPYwa8ARIr8kt9maE8izCJqqQkErImYL0n1huM5 vFexEC1HBXtGvQt4bd/Pb6yFmHljX2dyRCXwhKfWmO2gLoPKKLfWy7wITggX8w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100631; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bQ891FWRaeZntw5HFf5qoaiNenDTaKPknthYCbWCOSA=; b=/Pix/2IZU8PlJuERNfUAmg0fjEyWbLvtQ+CSqYGl6eMPmVhEw59NaWP0izkSJ9eJfoxUDl aUKJqm/ZiXNepaCg== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao , Christian Brauner Subject: [PATCH 12/21] fs/aio: Switch to use hrtimer_setup_sleeper_on_stack() Date: Mon, 28 Oct 2024 08:29:31 +0100 Message-Id: <7748a432845a9748d3e8d790a5d08b8bbe3b4af3.1729864615.git.namcao@linutronix.de> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is a newly introduced function hrtimer_setup_sleeper_on_stack() which will replace hrtimer_init_sleeper_on_stack(). This function is the same as the old hrtimer_init_sleeper_on_stack(), but it was introduced to keep the names consistent with other changes with hrtimer. Switch to use the new function. Patch was created by using Coccinelle. Signed-off-by: Nam Cao --- Cc: Christian Brauner --- fs/aio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/aio.c b/fs/aio.c index e8920178b50f..a5d331f29943 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1335,7 +1335,7 @@ static long read_events(struct kioctx *ctx, long min_= nr, long nr, if (until =3D=3D 0 || ret < 0 || ret >=3D min_nr) return ret; =20 - hrtimer_init_sleeper_on_stack(&t, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + hrtimer_setup_sleeper_on_stack(&t, CLOCK_MONOTONIC, HRTIMER_MODE_REL); if (until !=3D KTIME_MAX) { hrtimer_set_expires_range_ns(&t.timer, until, current->timer_slack_ns); hrtimer_sleeper_start_expires(&t, HRTIMER_MODE_REL); --=20 2.39.5 From nobody Mon Nov 25 09:47:37 2024 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 39679192B81 for ; Mon, 28 Oct 2024 07:30:34 +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=1730100636; cv=none; b=ABcvyWDyvhYOsFDXIhrV3CFj2gd33ohwxu1RjcgTDNZqJ97HfMXPlW8KAWy6I9tH8ChrBZEIg1xQyPGySDn20UAq9Zu6jRx3SJMSCNXOumkihtOCWTCg8HtcuW08WE7nMlxNkd7aUGJf50+ZTAmMByud1fc9P+gOpzmMNKebIKw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100636; c=relaxed/simple; bh=K2U0twQP+MNfkVfGVWqYOHHr4dbqMXiii56EKtn0bNU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TZS6M1CklOBD5njASJE6bYAxqZLxtImsS8vTD43JAZlJxwnzlWQ1fyqZ1+OWI7uhQMPXUxNQzs7ljDOsZ0WaLS49pfBzyDxm8jCjAq6/Roa0uYulE0OgeL/qX60CfxNXgtmzvYg/DspJkMMXexoYPShV9bXGpFIr6hwiSY9HxcE= 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=jVUDfg00; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=coJ4NMyD; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="jVUDfg00"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="coJ4NMyD" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100632; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D4JYGaFdslzTFMLcylYq2m2bbzwGTzv81asbS4XQJYw=; b=jVUDfg00xyCvq9fVWO9yWLXDg/Yp9RdvVgbOplWjCdZk2fhgDyjA6aT+nz2WpU6EybiwOF becvprC0JO9nZEEcXa+2kGqrbv4ZspVn9QiherVnhOEUDPkYnFqyX0301gV7PCT449BUAa Kwg+F/o/DY/iRy5FPGPTU4qN/EMK6JLdkvsSCj4nu7WO1OyPByYNyVL/vlzTOZ42uEOlXV zxsEjzN2yQ7Q81BIW9uSUXaLj68Ep7K8/STGGuN5A2um+8jjAQP5v5yQ3vFTmRUgCQj4mn eddId3e0VULQ+EPu58eeo/h8iyLcic0tZidd28cm/pDRi3NnR4F4Afbrva49PA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100632; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D4JYGaFdslzTFMLcylYq2m2bbzwGTzv81asbS4XQJYw=; b=coJ4NMyD3DJkNADte7yvfA97ArpkNrZRmX7+GOLkxBXHcV/LyLy73auHSGkrWCvsxI9YpQ xZCyk+8W4tdL09Bg== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao , Peter Zijlstra Subject: [PATCH 13/21] futex: Switch to use hrtimer_setup_sleeper_on_stack() Date: Mon, 28 Oct 2024 08:29:32 +0100 Message-Id: <3a9eb9d88c4b184f5a588ccdb74bf61023279840.1729864615.git.namcao@linutronix.de> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is a newly introduced hrtimer_setup_sleeper_on_stack() which will replace hrtimer_init_sleeper_on_stack(). Switch to use this new function. This function is the same as the old hrtimer_init_sleeper_on_stack(), but it was introduced to keep the names consistent with other changes with hrtimer. Patch was created by using Coccinelle. Signed-off-by: Nam Cao --- Cc: Peter Zijlstra --- kernel/futex/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/futex/core.c b/kernel/futex/core.c index 136768ae2637..fb7214c7a36f 100644 --- a/kernel/futex/core.c +++ b/kernel/futex/core.c @@ -140,9 +140,9 @@ futex_setup_timer(ktime_t *time, struct hrtimer_sleeper= *timeout, if (!time) return NULL; =20 - hrtimer_init_sleeper_on_stack(timeout, (flags & FLAGS_CLOCKRT) ? - CLOCK_REALTIME : CLOCK_MONOTONIC, - HRTIMER_MODE_ABS); + hrtimer_setup_sleeper_on_stack(timeout, + (flags & FLAGS_CLOCKRT) ? CLOCK_REALTIME : CLOCK_MONOTONIC, + HRTIMER_MODE_ABS); /* * If range_ns is 0, calling hrtimer_set_expires_range_ns() is * effectively the same as calling hrtimer_set_expires(). --=20 2.39.5 From nobody Mon Nov 25 09:47:37 2024 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 3F4FE192B86 for ; Mon, 28 Oct 2024 07:30:34 +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=1730100636; cv=none; b=QPl06MoxLy6AjoJmBimovBJtzQG548K1G1bcO7Hll3unyzMwbkh1oOlrt08SaHFkxGWvwxrDiNFiZxNwJ2EYS6VTW47oDQaA6orBPZqd/bnn7Y0HDj7BPUjrsaxPqCYdTio5PYLfg4aj8ZOF7qFmSzBxwlX+QXBKgJf6pnUKR9U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100636; c=relaxed/simple; bh=W8sSGd3DOu4dlaaIRbN4pNaB/WXYoZyugu3aIyeSMas=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LUT2gN4OwRqqPh8q0Z1PoJCzYLkLa3fkU4HC+donrEtlBAlChe3xfOAtRQIrv7Dk419aE85YwbvQ6b2x+moYSnEyWR9eqFYA8OEaE9PUGJ4oVjAjUDjHPSd2jpMiLJExPpcoh/fhvHESbiqjclTRuPlRbwg5E20eAJ1E37W3pNs= 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=H3WYO9J7; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Y/VaS/zF; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="H3WYO9J7"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Y/VaS/zF" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100632; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NppdOpxaoe2zPIqJ6mIEaou+D+Y+s1PgCXxaH7Okx+Y=; b=H3WYO9J7r+mmJOFeLBpxElk6evq4e4e3ilpPtTHYgmpw+4wJnLROsVEVkultpC9j3j3Sb0 FUp7kfWrazQa1zvSGMr+Lgo8d26syMOt7t1PjsfjcATEMRDHrcPC/b82sj/RJoMFOnmXyk TnIurDyThShXxxbzJK9vZD6Z7wOl2b1ymYUJkgJHMxgauu0sb5cu6M/uIgEFDU+39JO42B IjI2D5gxzNIFDhGrNBnqux9lQIHUrJB8GC0eLhDAnAixQ7Ol+47u68vpnE5uRreeIE4b9O Eh3urWcnZEtPM6YwT5ro6mkxuc6JU/Y9F2fGs0dho+lzN7OZ6j/Jw9uZ+f81hg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100632; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NppdOpxaoe2zPIqJ6mIEaou+D+Y+s1PgCXxaH7Okx+Y=; b=Y/VaS/zFUvIANDBwxw6fmH5Z15xuhQUdGoRB3Ogv25nhychWNHh6Y2nP8F0Wsh/vDOVS5w mcbnrOPh1GPP4yBA== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao , Jakub Kicinski Subject: [PATCH 14/21] net: pktgen: Switch to use hrtimer_setup_sleeper_on_stack() Date: Mon, 28 Oct 2024 08:29:33 +0100 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is a newly introduced function hrtimer_setup_sleeper_on_stack() which will replace hrtimer_init_sleeper_on_stack(). This function is the same as the old hrtimer_init_sleeper_on_stack(), but it was introduced to keep the names consistent with other changes with hrtimer. Switch to use the new function. Patch was created by using Coccinelle. Signed-off-by: Nam Cao --- Cc: Jakub Kicinski --- net/core/pktgen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 34f68ef74b8f..7e23cacbe66e 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -2285,7 +2285,7 @@ static void spin(struct pktgen_dev *pkt_dev, ktime_t = spin_until) s64 remaining; struct hrtimer_sleeper t; =20 - hrtimer_init_sleeper_on_stack(&t, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); + hrtimer_setup_sleeper_on_stack(&t, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); hrtimer_set_expires(&t.timer, spin_until); =20 remaining =3D ktime_to_ns(hrtimer_expires_remaining(&t.timer)); --=20 2.39.5 From nobody Mon Nov 25 09:47:37 2024 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 8877F192B9D for ; Mon, 28 Oct 2024 07:30:34 +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=1730100637; cv=none; b=WDAdzPbnXO9tmSlYcHXg76ksYekUDQ27VdnfU9jSQiwmlb0ACn4XuXCfwqBGwFyruT4Anb7nap7LuYXrV1pafL73uZfyiugHx9KKE9v7jAl1HvzDLDFzwyDLwNsfJTbF0ONZK4cdjNamY0KOMNotSMMtB+MqDqgtnjVXvz1c71U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100637; c=relaxed/simple; bh=p1WNHHJsh//H3R31M4mEAZn/dExjkNeMnZF2QHlbd0s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=g1cEUeTfQ6T+cEqqbDggEYLE8Xwpd9195bioYnZ0UuhFCq2MF6LhtScf7lfD455C8467Tt48vJzHSH4rqe1kzNW0eCP0V0gs2Tfkeq4E9oBFMn4wwPodgbd1KMenIrjF6v807PCzbIiqRqoVEUm6f65AqW45ixOiELXDvQeSFiA= 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=BDLVCkuW; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=3fetGmtI; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="BDLVCkuW"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="3fetGmtI" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100632; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+Kc2BZUC1ebPDEVIRiKKvNYv3u35tkYwpWsAZQDECc0=; b=BDLVCkuWXi66KLg8gA20FhuUkuvW0/+MimT+ESeZ0qEIfNpwO1cBSilOuA0902JiLQa8xd +I1FEHwmAcbb28YMis78gUs/Su4UDRojowDOcbGuZQTSuYL8NtnBqkpGH3rALURoVfqO/D yXjCBDc+g5YFZLxzXpCJnK5pLzZwf41MpO0D2F8V76T5blDg2F0HkTeRCwi0R4BuusdSup qNFF8VQs6kTkBgW/FIq655oqqXv5SsPq4RuCBWuOJVe/XrqgE/PxJVPPRyrNrQuf7aqBEn PGOnI3XMcpAlHUrUwwtk2+XlriXj0uRNXqpkBr7GTIeBC14XaM2EdeQFevNK1g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100632; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+Kc2BZUC1ebPDEVIRiKKvNYv3u35tkYwpWsAZQDECc0=; b=3fetGmtIPSb/5FB9Qpv8MT6Li6TNJdacDtiGS3V8Hx9Dtg8rXxst4HMZdLK1WqcC6Q+4EW jmWUl/oPUmgLP1AQ== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao Subject: [PATCH 15/21] timers: Switch to use hrtimer_setup_sleeper_on_stack() Date: Mon, 28 Oct 2024 08:29:34 +0100 Message-Id: <868b994e1f724ef48c44f9e06d5968a3fc5e3f71.1729864615.git.namcao@linutronix.de> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is a newly introduced function hrtimer_setup_sleeper_on_stack() which will replace hrtimer_init_sleeper_on_stack(). This function is the same as the old hrtimer_init_sleeper_on_stack(), but it was introduced to keep the names consistent with other changes with hrtimer. Switch to use the new function. Patch was created by using Coccinelle. Signed-off-by: Nam Cao --- kernel/time/hrtimer.c | 5 ++--- kernel/time/sleep_timeout.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 1d1f5c03673c..69430467a17d 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -2138,8 +2138,7 @@ static long __sched hrtimer_nanosleep_restart(struct = restart_block *restart) struct hrtimer_sleeper t; int ret; =20 - hrtimer_init_sleeper_on_stack(&t, restart->nanosleep.clockid, - HRTIMER_MODE_ABS); + hrtimer_setup_sleeper_on_stack(&t, restart->nanosleep.clockid, HRTIMER_MO= DE_ABS); hrtimer_set_expires_tv64(&t.timer, restart->nanosleep.expires); ret =3D do_nanosleep(&t, HRTIMER_MODE_ABS); destroy_hrtimer_on_stack(&t.timer); @@ -2153,7 +2152,7 @@ long hrtimer_nanosleep(ktime_t rqtp, const enum hrtim= er_mode mode, struct hrtimer_sleeper t; int ret =3D 0; =20 - hrtimer_init_sleeper_on_stack(&t, clockid, mode); + hrtimer_setup_sleeper_on_stack(&t, clockid, mode); hrtimer_set_expires_range_ns(&t.timer, rqtp, current->timer_slack_ns); ret =3D do_nanosleep(&t, mode); if (ret !=3D -ERESTART_RESTARTBLOCK) diff --git a/kernel/time/sleep_timeout.c b/kernel/time/sleep_timeout.c index 3054e5232d20..dfe939f6e4ec 100644 --- a/kernel/time/sleep_timeout.c +++ b/kernel/time/sleep_timeout.c @@ -208,7 +208,7 @@ int __sched schedule_hrtimeout_range_clock(ktime_t *exp= ires, u64 delta, return -EINTR; } =20 - hrtimer_init_sleeper_on_stack(&t, clock_id, mode); + hrtimer_setup_sleeper_on_stack(&t, clock_id, mode); hrtimer_set_expires_range_ns(&t.timer, *expires, delta); hrtimer_sleeper_start_expires(&t, mode); =20 --=20 2.39.5 From nobody Mon Nov 25 09:47:37 2024 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 D80CB1B373B for ; Mon, 28 Oct 2024 07:30: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=1730100638; cv=none; b=Kv7+F2HQyXt0isbhTWb8NktkpaEljNGZo8Nk6QFj9fOLb1wrX4Cgb7PhX1R+ZTU6xxaW1CSTa6lpxAdGiwNa+InBMK+DwuIF0olAA5xQSeGVkovvgZPbbktLSRo02Mz5JjDhsEBk6H3+rjceuznk2girB7wR1sLFPAf9utuWcAM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100638; c=relaxed/simple; bh=89P76W4dxG4vwr80/xFiizISI31t+pXL1ooPfIFUkgs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KeXN4KV69N9YT7NPyS7s5IbBdpQ7MnW5uqNKWYCc3A5jvbaoaE7XqtA0C67tPsquY3DRB5f0wQJQuPsGF5gOHuOc1+YskERU30ensmcEVk4mjoeTiRCKbWNQdB5aO/Zkt9NH3L7H9dBAfOBfVaT1XFZb5BCKwhUQnCRPepOGQdE= 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=frSveYTY; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=/WNFafgu; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="frSveYTY"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="/WNFafgu" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100633; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mv28Ug65bgMJCZtlcqqT11iFuRa7ViPaVxpmJ5oe1ns=; b=frSveYTY9YNQqY10O3Skq3c5piX4zHsVAMIVDkCh0wMXtIKg4ELHSwnCykURj95FJvT4PB ydxsws4pq6ugylZJxewWT7roGeA5YlyqY6qLeXlq8wFEpwIuBJdaTuf2GmU+ZKV/uL2Ecr nYba3IuJZWdGUGxsevbLZFaXZIQHFHXy0vC1L+1zZHGjRsMFtrutW2iWeM2GcfaI2gqhtZ NYx+GINzllYhZxQx7pb49q1FldCYVMGUHCX8eUBiAIsz/lcJK+dcSN5DHarm2U090NTw5j oogBKW9cE00IlicWVPHMi0Cr4htCvHiKcbunJnAngK7RUhoPi5FnE9sAsEXQyA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100633; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mv28Ug65bgMJCZtlcqqT11iFuRa7ViPaVxpmJ5oe1ns=; b=/WNFafguuzWcU95r8fS6ZuK4GQbeAC92nhOmzO3HaVQER5HQWrTeTD+bVweZfgeR55rmgE 4gxPa3uI3akhGXCg== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao , Peter Zijlstra Subject: [PATCH 16/21] wait: Switch to use hrtimer_setup_sleeper_on_stack() Date: Mon, 28 Oct 2024 08:29:35 +0100 Message-Id: <31f243f57c7c67222edd266cff133419483404f6.1729864615.git.namcao@linutronix.de> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is a newly introduced function hrtimer_setup_sleeper_on_stack() which will replace hrtimer_init_sleeper_on_stack(). This function is the same as the old hrtimer_init_sleeper_on_stack(), but it was introduced to keep the names consistent with other changes with hrtimer. Switch to use the new function. Signed-off-by: Nam Cao --- Cc: Peter Zijlstra --- include/linux/wait.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/wait.h b/include/linux/wait.h index 8aa3372f21a0..643b7c7bf376 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h @@ -541,8 +541,8 @@ do { \ int __ret =3D 0; \ struct hrtimer_sleeper __t; \ \ - hrtimer_init_sleeper_on_stack(&__t, CLOCK_MONOTONIC, \ - HRTIMER_MODE_REL); \ + hrtimer_setup_sleeper_on_stack(&__t, CLOCK_MONOTONIC, \ + HRTIMER_MODE_REL); \ if ((timeout) !=3D KTIME_MAX) { \ hrtimer_set_expires_range_ns(&__t.timer, timeout, \ current->timer_slack_ns); \ --=20 2.39.5 From nobody Mon Nov 25 09:47:37 2024 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 CBBAF1CC898 for ; Mon, 28 Oct 2024 07:30:36 +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=1730100639; cv=none; b=IyGjScka+KLynBu9Y3SvChbipEbPA7J/Y4c20gl59byjiPoNZi0v+R5aYAltMaq5VLtohwHAKuoZfKTI8DVd1gWqSbE96HPbRJyW7L0Tbug7vf1hrCB4QqE69gSG1Y/KRU6mTWsA9RHkeyDiHJ9IqkdNR3ZjIktIEAgfIDrhp5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100639; c=relaxed/simple; bh=vawBPjVjhC0BJHmpKjEoR5oITpYLJoZAJKw1eVRUNq4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QBD5O5KcPlc9M0++AdAxw2hacRjsVWqwdlKjaGHV93Br/IJ2i+Sz4wDKHxiUAwO+BZtOPPgF6Ek9FXVxC0r7/xdMhbGdaHhTtVyJPsDugBdyChZ6Hg3gxI8mnVv2LearWEwtySiCIUz1DfLNG8HGf9zlezm3O/8tZ7qgnjN9L1Q= 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=BTAZh58o; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=NFMJLsXa; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="BTAZh58o"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="NFMJLsXa" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100634; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JirWdjsOsU2DPbQ75KQaxuXB0VuPgzxLe9NrnZll6S8=; b=BTAZh58oxeELGCFgaW9sQpUjPwJNE1QfW2x60jp4/gbIMx9bznd1NdF5Ui97hyVJHIcwlk LLz1fleUu7qtOy8CIf9ND6+dtB3+MpFuW+hR77+sj/1AMOjvf0F+/bNRasVk4WrCoyGUqo VRMfexN2hkTFrkUc3Qc73CrvFSE+hcaeM8tdTfL3h3bHTmBhTuf2Ff7A0DcbdyStwHG1N1 6OaD83Uui5ur9Ikzv1AJYBSGViPDkPF/8xZHczIPlSJzHuWnIs63yu1MDxpYJo5Vqlwu+5 8WpQACCc5vKS5eL7H1b9DDTUXilJsOnN5OlvePBO7X2/e32eQwOHEF4Pkql/vA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100634; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JirWdjsOsU2DPbQ75KQaxuXB0VuPgzxLe9NrnZll6S8=; b=NFMJLsXaouzTwhFdYyemXZjbqIXPEcd/BeeDGYe1cL57j3ENzuhS/9mGaq+qz//l9xk2gJ qHa80fEZE001wSCg== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao Subject: [PATCH 17/21] hrtimers: Delete hrtimer_init_sleeper_on_stack() Date: Mon, 28 Oct 2024 08:29:36 +0100 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" hrtimer_init_sleeper_on_stack() is unused. Delete it. Signed-off-by: Nam Cao --- include/linux/hrtimer.h | 3 --- kernel/time/hrtimer.c | 14 -------------- 2 files changed, 17 deletions(-) diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 6e026730e803..4e4f04b3c0c2 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -235,9 +235,6 @@ extern void hrtimer_init_on_stack(struct hrtimer *timer= , clockid_t which_clock, extern void hrtimer_setup_on_stack(struct hrtimer *timer, enum hrtimer_restart (*function)(struct hrtimer *), clockid_t clock_id, enum hrtimer_mode mode); -extern void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl, - clockid_t clock_id, - enum hrtimer_mode mode); extern void hrtimer_setup_sleeper_on_stack(struct hrtimer_sleeper *sl, clo= ckid_t clock_id, enum hrtimer_mode mode); =20 diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 69430467a17d..376b8182b72e 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -2051,20 +2051,6 @@ static void __hrtimer_init_sleeper(struct hrtimer_sl= eeper *sl, sl->task =3D current; } =20 -/** - * hrtimer_init_sleeper_on_stack - initialize a sleeper in stack memory - * @sl: sleeper to be initialized - * @clock_id: the clock to be used - * @mode: timer mode abs/rel - */ -void hrtimer_init_sleeper_on_stack(struct hrtimer_sleeper *sl, - clockid_t clock_id, enum hrtimer_mode mode) -{ - debug_init_on_stack(&sl->timer, clock_id, mode); - __hrtimer_init_sleeper(sl, clock_id, mode); -} -EXPORT_SYMBOL_GPL(hrtimer_init_sleeper_on_stack); - /** * hrtimer_setup_sleeper_on_stack - initialize a sleeper in stack memory * @sl: sleeper to be initialized --=20 2.39.5 From nobody Mon Nov 25 09:47:37 2024 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 42A39191F87 for ; Mon, 28 Oct 2024 07:30:37 +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=1730100639; cv=none; b=Bj+EIv4xeQsk5P+X4uhkr6MdriLu/SQXUmTnq9edFsJtlkEqxkAMti0ObORPm/bJBqdsQsnWgfn4lj3FJ2kgV/peTJvvSiRyBOcnIX2ffMisNJQYNqJ20Afl9c57JkVT5HDiSnV3veb4L9ircJgg+1f7wu6UU7yBTxf28/ek3QA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100639; c=relaxed/simple; bh=AAQLFWRoUHVygOhusGzdBe1s2eupEuCbhk2Ngr6pcJA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oSKGCsJZoMdvZ1pg+1A+C633SBFLUF4ZhMeIPDKTX3ycjuam5MY9PqdkbIjvX+XFJQpGIDowZ5aGXpFxW7b//zrgywAUDndeki4pEoedEpUYWlZoXxoTjTz1p+M27siXHDhZnRizLQqqSWJWejlCDWtNcxMuQ0D3fOlDfoCqFjc= 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=J2pcl76O; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=zI32bFzH; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="J2pcl76O"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="zI32bFzH" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100635; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=slRmMQmEdb7f8rA3+n8RFcCYvgMT1T0/Oy8UU05OlVY=; b=J2pcl76OglaKensct5+lSXSwCIf8mbgV1MnKf3haM25D8RZymByNaYJxuj9ITPR8++VD3V vQ3lAzXPi68hpd0zuU6IW3vR7LoNXK2dSk8IHnIfD1+Ux0kwr8EXCpZSxP8UaMNfydTX3L RbreKsl0hq/bk9t8qZYa3eO6gbopHJWkUKbXLMCTjco8hJgm/H/tktxU1Kuu5gXbnlGrQA lQgv1RQ1zDOh/Fa50ayXnhPRvyVhBKWXOczWqlg2bigx0TDD1O46Cm9LKsWnr2fm3nETf5 4NS8zPeZYMcGvZ/ORqpI1Y+dunOXK1FpDHS/Fug8N816iSRU5yr2Ko6LWxuryQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100635; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=slRmMQmEdb7f8rA3+n8RFcCYvgMT1T0/Oy8UU05OlVY=; b=zI32bFzHG8pGiQuzyvcc598o1eecoAfRkoBZlPoFRmLzUCqwYAePTf88qYHN9ZROyJhHlV nxRe2Fn2cYtQfCDw== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao , Peter Zijlstra Subject: [PATCH 18/21] sched/idle: Switch to use hrtimer_setup_on_stack() Date: Mon, 28 Oct 2024 08:29:37 +0100 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is a newly introduced function hrtimer_setup_on_stack(), which will replace hrtimer_init_on_stack(). In addition to what hrtimer_init_on_stack() does, this new function also sanity-checks and initializes the callback function pointer. Switch to use the new function. Patch was created by using Coccinelle. Signed-off-by: Nam Cao --- Cc: Peter Zijlstra --- kernel/sched/idle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index d2f096bb274c..631e42802925 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -399,8 +399,8 @@ void play_idle_precise(u64 duration_ns, u64 latency_ns) cpuidle_use_deepest_state(latency_ns); =20 it.done =3D 0; - hrtimer_init_on_stack(&it.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD); - it.timer.function =3D idle_inject_timer_fn; + hrtimer_setup_on_stack(&it.timer, idle_inject_timer_fn, CLOCK_MONOTONIC, + HRTIMER_MODE_REL_HARD); hrtimer_start(&it.timer, ns_to_ktime(duration_ns), HRTIMER_MODE_REL_PINNED_HARD); =20 --=20 2.39.5 From nobody Mon Nov 25 09:47:37 2024 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 8B0401D0B83 for ; Mon, 28 Oct 2024 07:30:37 +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=1730100639; cv=none; b=eXzYNRksZuBQuZcL3kUzMXaFxkOX9KxzH7lildMoH3dELX0XHuY9ikKCt6FuAYTsPW0je1fN33s2M239xjei29jVmgxqCUK7DjwvsulHhpsEb2uHUw1rSvv8U0jsQPf6xdJ6l1FAQAV07r5rLFPOi9RHipoQHLz5FDFBMOJUN9c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100639; c=relaxed/simple; bh=pMy90q5Jw5JeY3oE9UnrkNMRYmEsCNbK9W/h0grLeRc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=j1WHURT9teEBvelCXaJrDXyO4aYxdYWA/nIJVyNibWVHWuPX2nKwdw+7yyK9HWkFATG/QDm0DJzsFq1eEJ7k5CLJ37IUc2q7qh689+jlf4Zag1I4ktD8TclcSxeu7wsYfHzTwK8BdGAZzySMxCf5tFqPTNBepMFzbg32svm7eZ4= 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=AqlkNyij; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=RQzvyhP5; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="AqlkNyij"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="RQzvyhP5" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100636; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tqIZfhlM6JiBAfAU0JkJcw91TW7sTXf1JjNEJjOsuQc=; b=AqlkNyijlprPbeaJPQ6tFeig2wgJA6GuzQ26qC+kazTusMa9NbcnvbhWGWOCdw5+vRv4sc CrKuoj20PpMwenoIV3NtVbsHPtuNHdbWq+EHZgkZPquVZzI6yN/yQEC6dmdzcrjDq/s2GP W1STdxirIeq+Jwd+CiwgO164C6fENPPCJXITpeay6uT8zc22OXu/i4IrhT5FML25YxgTtG H4n5TSXPxqCgn2XkUidDFrj19eexUyxHKYhKdME2OvmKybMGogfG2ZjdyTgfZxxCm7Yxik rqguIsBM14YrTzv3o96M1t9n+y8HLswAXn1sFcQSkaDTinLDMtxlHbcPQYEeoQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100636; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tqIZfhlM6JiBAfAU0JkJcw91TW7sTXf1JjNEJjOsuQc=; b=RQzvyhP54Nl9RFBwLxqHR1PZLvdphkSfprIAF1KbLfAVx7FdQs0RprEjOHBb5gpXZsJKQI ZDbvzUxpLczKAPCg== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao , Jens Axboe Subject: [PATCH 19/21] io_uring: Switch to use hrtimer_setup_on_stack() Date: Mon, 28 Oct 2024 08:29:38 +0100 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is a newly introduced function hrtimer_setup_on_stack(), which will replace hrtimer_init_on_stack(). In addition to what hrtimer_init_on_stack() does, this new function also sanity-checks and initializes the callback function pointer. Switch to use the new function. Signed-off-by: Nam Cao --- Cc: Jens Axboe --- io_uring/io_uring.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index feb61d68dca6..0842aa3f60e7 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -2435,13 +2435,14 @@ static int io_cqring_schedule_timeout(struct io_wai= t_queue *iowq, { ktime_t timeout; =20 - hrtimer_init_on_stack(&iowq->t, clock_id, HRTIMER_MODE_ABS); if (iowq->min_timeout) { timeout =3D ktime_add_ns(iowq->min_timeout, start_time); - iowq->t.function =3D io_cqring_min_timer_wakeup; + hrtimer_setup_on_stack(&iowq->t, io_cqring_min_timer_wakeup, clock_id, + HRTIMER_MODE_ABS); } else { timeout =3D iowq->timeout; - iowq->t.function =3D io_cqring_timer_wakeup; + hrtimer_setup_on_stack(&iowq->t, io_cqring_timer_wakeup, clock_id, + HRTIMER_MODE_ABS); } =20 hrtimer_set_expires_range_ns(&iowq->t, timeout, 0); --=20 2.39.5 From nobody Mon Nov 25 09:47:37 2024 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 5B9DE1D2F6F for ; Mon, 28 Oct 2024 07:30:37 +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=1730100640; cv=none; b=j5ybTJcgmh7QlwK2US2JakfHIy8mHBWB/jLWUyFOTJsLSa2KgLlGw6dXRft2txkLFaxKQjK6SlsCFn0IV6AYmbBppxX3yzYuFKxQf2psv+OP7tZzXbK5wMTZJfxLwPPjpGhHYARfZtl+obSl07P+g+VHFhQ0NjwAUySINZhR+KI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100640; c=relaxed/simple; bh=IW2dvXHtXHFDsIYV4XAPLaAUgKjPIL8JUW98j9mXX/k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=T7ZRioJPBQMtkTP3TttRpvUkp279602OPh2wxpVluFvGKxKIh5J0HE+pY4c6bWp4Q129QvaNRi1e7h+YYCqZJ/+L3BzGAoyh9IsqpK7PGDyiPLglIEgEvJlKInqQ1kTjQDC8XEzGImhyOQ+fUp/tXzzI52A5koZp76+pz2MYFCI= 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=wC1Marwv; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=m8uCnzQ1; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="wC1Marwv"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="m8uCnzQ1" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100636; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O1AA1NJRIJR372KlC5h6m7cnWrz+FjbPP6FjR2PwhQs=; b=wC1Marwv77zgarvjBkvBeUBVHTY/GukFTr3WzhTofkwFJvvzEY5YCtKoUs9JKqr8G0sEJR hT5eeETp3V7xZA1xpnLlYXi+vO/3NiyxdjntkGBxPtPitKHRJsBBhmmV3WEO+yJwa2qLQY gq/AkSx2qjTlNnJhWtmHgw2kvwZ1YyTbURRITHNMINRDOVLUKY4PPYFyEthFM++ZfsxXrh /qdocj5fAkYVNalQ/k8c6sAR9HM+BOfCIlGJjP5NusrCZtlDOJ1UKFyyYZ8up0mQVWuu3m JXuOZLbNrcvxAdU2mHWIMdIX9WBoYCxjzTuBNpn6ZCNUKDmJqvH8EB+aOoNLFA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100636; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O1AA1NJRIJR372KlC5h6m7cnWrz+FjbPP6FjR2PwhQs=; b=m8uCnzQ1NOxL4EdtHQfBPKV70eK4jb0WGaH8KayYcq/Z6I+8xfJdR8ljrzQWKAo+g43GwP wFVqFOlnKTr6yRAg== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao , John Stultz Subject: [PATCH 20/21] alarmtimer: Switch to use hrtimer_setup() and hrtimer_setup_on_stack() Date: Mon, 28 Oct 2024 08:29:39 +0100 Message-Id: <0ac2e27f4bd4f5206d706f536387eeba908aa7a4.1729864615.git.namcao@linutronix.de> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There are two newly introduced hrtimer_setup() and hrtimer_setup_on_stack() which will replace hrtimer_init() and hrtimer_init_on_stack(). The new functions are mostly similar, except that they also sanity-check and initialize the timer's callback function. Switch to use the new functions. Signed-off-by: Nam Cao --- Cc: John Stultz --- kernel/time/alarmtimer.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 8bf888641694..3c70a3abd6a2 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -337,7 +337,6 @@ __alarm_init(struct alarm *alarm, enum alarmtimer_type = type, enum alarmtimer_restart (*function)(struct alarm *, ktime_t)) { timerqueue_init(&alarm->node); - alarm->timer.function =3D alarmtimer_fired; alarm->function =3D function; alarm->type =3D type; alarm->state =3D ALARMTIMER_STATE_INACTIVE; @@ -352,8 +351,8 @@ __alarm_init(struct alarm *alarm, enum alarmtimer_type = type, void alarm_init(struct alarm *alarm, enum alarmtimer_type type, enum alarmtimer_restart (*function)(struct alarm *, ktime_t)) { - hrtimer_init(&alarm->timer, alarm_bases[type].base_clockid, - HRTIMER_MODE_ABS); + hrtimer_setup(&alarm->timer, alarmtimer_fired, alarm_bases[type].base_clo= ckid, + HRTIMER_MODE_ABS); __alarm_init(alarm, type, function); } EXPORT_SYMBOL_GPL(alarm_init); @@ -816,8 +815,8 @@ static void alarm_init_on_stack(struct alarm *alarm, enum alarmtimer_type type, enum alarmtimer_restart (*function)(struct alarm *, ktime_t)) { - hrtimer_init_on_stack(&alarm->timer, alarm_bases[type].base_clockid, - HRTIMER_MODE_ABS); + hrtimer_setup_on_stack(&alarm->timer, alarmtimer_fired, alarm_bases[type]= .base_clockid, + HRTIMER_MODE_ABS); __alarm_init(alarm, type, function); } =20 --=20 2.39.5 From nobody Mon Nov 25 09:47:37 2024 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 52FEC191489 for ; Mon, 28 Oct 2024 07:30:38 +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=1730100640; cv=none; b=VzrCWvHool7pijXoOVBH1b7Q7mNSerO1vVLYMtIQjzTGsLwBlD4Tk/ewOBi3s+mi05kbu54PmXJODc1FIu8F0C+qePX/spao+2QKUFVlXcTZf13zGz/mkeT/tSS8ApymO/J4A3bAeneV5gPhoL2rvH1xif7m8o0u9VLntdSOY2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730100640; c=relaxed/simple; bh=SDsWig1abADkGoEilxW6zwUHpoZk394qMZP7AwtvOak=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=L1XRaQVgTFcOg9oM6vXnqSd6cjfaB0fnUefSmr7Z/85obLVTUKKQ8rrz5YyrQSTUttpLN6rsqIgMFzogy3AhOTOt5CdeNV+cuHuMbwCx6GnAoGlKxnYTfAkhuu5PqGgdVV7wk4ijiQXfpU32mObh+XZPcZKJyF3HXeCSiodUrmE= 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=LGQZ4WjS; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=dBGOkLqy; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="LGQZ4WjS"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="dBGOkLqy" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1730100636; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ghm5t5hu/x6JQgXUC1QAejuM9cCD5lTbm5O7D/1weMw=; b=LGQZ4WjSxQK58/P8WHwZfUBvFhyr0thRj2YK4/zyoaJOCVtlc4T6IP/HEvVqisF8Y7sklW 3EQgCnYp7ty1D+s7nOzMbfiIb8uBrmAyLfS1ymKdxGDqJcYrdKj3Fat7SsDH91VV3cPZWZ CgvTJrSYGUYe5znXPvje1upPqeWijxvatlnnYUI7/RuNM8fu0ZgLsce86yPS4UAgLVJiTe z6W9pM9jk5QDySo0pl0zUJm5+rOhI0SfBA1fwknYcT6n079wtgkcmTShHt0sbIKlJtbzvv iJywPnyth+GbrtazIC1LiTNocSbCWWM6lzUfazJibMe4PCWCqje9fjhy9fB5vA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1730100636; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ghm5t5hu/x6JQgXUC1QAejuM9cCD5lTbm5O7D/1weMw=; b=dBGOkLqyK0z4NeTKXssV3a8c+1P5LvkFczO1MtkY8feoMqswisAswo3aBur8bjMo26V/2p IYYvkZIsWIDn9oCQ== To: Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , Andreas Hindborg , Alice Ryhl , Miguel Ojeda , Kees Cook , linux-kernel@vger.kernel.org Cc: Nam Cao Subject: [PATCH 21/21] hrtimers: Delete hrtimer_init_on_stack() Date: Mon, 28 Oct 2024 08:29:40 +0100 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" hrtimer_init_on_stack() is unused. Delete it. Signed-off-by: Nam Cao --- include/linux/hrtimer.h | 2 -- kernel/time/hrtimer.c | 17 ----------------- 2 files changed, 19 deletions(-) diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 4e4f04b3c0c2..7ef5f7ef31a9 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -230,8 +230,6 @@ extern void hrtimer_init(struct hrtimer *timer, clockid= _t which_clock, enum hrtimer_mode mode); extern void hrtimer_setup(struct hrtimer *timer, enum hrtimer_restart (*fu= nction)(struct hrtimer *), clockid_t clock_id, enum hrtimer_mode mode); -extern void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t which_c= lock, - enum hrtimer_mode mode); extern void hrtimer_setup_on_stack(struct hrtimer *timer, enum hrtimer_restart (*function)(struct hrtimer *), clockid_t clock_id, enum hrtimer_mode mode); diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 376b8182b72e..55e9ffbcd49a 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1629,23 +1629,6 @@ void hrtimer_setup(struct hrtimer *timer, enum hrtim= er_restart (*function)(struc } EXPORT_SYMBOL_GPL(hrtimer_setup); =20 -/** - * hrtimer_init_on_stack - initialize a timer in stack memory - * @timer: The timer to be initialized - * @clock_id: The clock to be used - * @mode: The timer mode - * - * Similar to hrtimer_init(), except that this one must be used if struct = hrtimer is in stack - * memory. - */ -void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t clock_id, - enum hrtimer_mode mode) -{ - debug_init_on_stack(timer, clock_id, mode); - __hrtimer_init(timer, clock_id, mode); -} -EXPORT_SYMBOL_GPL(hrtimer_init_on_stack); - /** * hrtimer_setup_on_stack - initialize a timer on stack memory * @timer: The timer to be initialized --=20 2.39.5