Skip to contentSkip to conversation

posix-timers: Drop redundant memset call

PATCH Applied Cyrill Gorcunov 2 participants 2 messages Mar 16, 2025 – Mar 17, 2025 Posix clocks and timers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 posix-timers: Drop redundant memset call

Initially in the commit 6891c4509c79 memset call has been needed to clear the memory allocated on a stack, then in the commit 2482097c6c0f memset call occasionally sneaked in regardless the fact that we're using kmem_cache_zalloc to allocate a new timer, lets save a few cycles dropping this call.

---
 kernel/time/posix-timers.c |    1 -
 1 file changed, 1 deletion(-)
kernel/time/posix-timers.c +0 -1
Index: linux-tip.git/kernel/time/posix-timers.c
===================================================================
@@ -526,7 +526,6 @@ static int do_timer_create(clockid_t whi
 	} else {
 		new_timer->it_sigev_notify     = SIGEV_SIGNAL;
 		new_timer->sigq.info.si_signo = SIGALRM;
-		memset(&new_timer->sigq.info.si_value, 0, sizeof(sigval_t));
 		new_timer->sigq.info.si_value.sival_int = new_timer->it_id;
 		new_timer->it_pid = get_pid(task_tgid(current));
 	}
#1 lore raw

[tip: timers/core] posix-timers: Drop redundant memset() invocation

The following commit has been merged into the timers/core branch of tip:

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     d1c3a3f1c9a1dfc2b41696b7903972f4b3fbcd02
Gitweb:        https://git.kernel.org/tip/d1c3a3f1c9a1dfc2b41696b7903972f4b3fbcd02
Author:        Cyrill Gorcunov <[email protected]>
AuthorDate:    Sun, 16 Mar 2025 22:58:15 +03:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Mon, 17 Mar 2025 10:38:49 +01:00

posix-timers: Drop redundant memset() invocation

Initially in commit 6891c4509c79 memset() was required to clear a variable allocated on stack. Commit 2482097c6c0f removed the on stack variable and retained the memset() despite the fact that the memory is allocated via kmem_cache_zalloc() and therefore zereoed already.

Drop the redundant memset().

---
 kernel/time/posix-timers.c | 1 -
 1 file changed, 1 deletion(-)
kernel/time/posix-timers.c +0 -1
index 2ca1c55..bc0bdf4 100644
@@ -526,7 +526,6 @@ static int do_timer_create(clockid_t which_clock, struct sigevent *event,
 	} else {
 		new_timer->it_sigev_notify     = SIGEV_SIGNAL;
 		new_timer->sigq.info.si_signo = SIGALRM;
-		memset(&new_timer->sigq.info.si_value, 0, sizeof(sigval_t));
 		new_timer->sigq.info.si_value.sival_int = new_timer->it_id;
 		new_timer->it_pid = get_pid(task_tgid(current));
 	}