Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp486419lqp; Mon, 10 Jun 2024 09:49:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWuJqZ8CVOTUAC0UlQ/4McRhqbrUgDTvMhN61D6jejStJP8lHde5taHyeVl2vyuOUGXlfwudiTIrVHfL8UPYi6sF3geuMqwWP1DGDtOJA== X-Google-Smtp-Source: AGHT+IGODzc56yQp8a81sKh1bBt5YaU97Uuj7Ehvd8HjS91K66mx0WB8WdZ1xP3NauMrBdrO3nGk X-Received: by 2002:a05:6e02:190c:b0:375:adcd:e6c3 with SMTP id e9e14a558f8ab-375adcde968mr16845075ab.14.1718038197892; Mon, 10 Jun 2024 09:49:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718038197; cv=pass; d=google.com; s=arc-20160816; b=P653Ew5aRbDVn3mhlVoX+Oi6QIjDl297dXAbH4lHKv+XnycvYYQ9OkZD0Mg/KmfkG2 pZKsCFxklxryZzzr53pNKLBUQsyOppgB4IUoCtSjgnbSOAh7NMkwnXT4Sy1osf+t8W3Z Fewt5zdrjUoVjHW5ISkEZFvps/AkKIuxe3nLUylQDc9hM1iMFENKQRN6CEiP1BuPLWts YxKRjY7dgs+mhukDcx+0a1QrG0qSuABQXsmWUp/9zl+5rIgL1JVkpGlLddB65JE2CDp2 m51TGh/rHNb584MrBqfbZB7lxK62htjgB5pPLYtyMCfUuCDf5FBv+HALwaSDeeM4HhHY nSxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=date:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:subject:cc:to:from:dkim-signature :dkim-signature:message-id; bh=MQO2EYZPqj5U7pySt49QYzOaZrWaUy6rIJlwsdY8EF8=; fh=joBs/8L+orz77ylyCy6wqNwwi35f7sYhLR+/TQjQjhI=; b=z1uexVMIIX0qQV8DNKQrWRuAf7Qz+Yk/gHOpCBVnKt84kVY5YIxmJ9P8n4giyQPZsx fuIjNXw0f+3scSpn0UXsJo5cJT+ccZXoEpgRo4uSxSyohi8M3Ca6BKjkdPb2Z0GVDH31 833NNm3RplK4LOnvlUWBxcqOf60ruk4rfCFHp6DoR3xQLhauoVveECBmoIS5NmcMlwkM lh97cL2/+SSQOne1IHVWy6sIrKbyJImBKTTCI7vl/+OOLwpKYm+U0D40Whm3zZw/ZBoP UKM6PEpuyZQjbxZ5xYS/Nwr3+gweMRT6J8LwD8ilFNt8hghNusfoKgjxeuoMwyQT8qfg kFYQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=m8KyEwe1; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-208599-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208599-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6e3ba950387si4349025a12.250.2024.06.10.09.49.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 09:49:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208599-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=m8KyEwe1; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-208599-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208599-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A5586282099 for ; Mon, 10 Jun 2024 16:49:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4E042157E61; Mon, 10 Jun 2024 16:42:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="m8KyEwe1"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="XdXl50y8" 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 07FB115746B for ; Mon, 10 Jun 2024 16:42:51 +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=1718037772; cv=none; b=R5AFIkas5FPGOK/ql+coa/hexl6SudUyd9QYrVu7P/y7UIGPTjncBhVUZh/W1bLXcdr77SWxzSSCLIhr0jRif/5mrNvRFvPMxqSv6qQyH9jzg+EQ0rpC1tKg4Pa48oZhql/NLzs0lcGpfLmkr2QfaksIHPVZB7HnopEABguuB5I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718037772; c=relaxed/simple; bh=XsbgZtCOc5ETrVPrJ/FtKkFplUEZ2QIE7aWQKb1cCHc=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=J4UTIdkB9Ayc2cHzg039AEneTokql2F3fh1gUMRSgWwNJqvtD7Pqjak7i0a4TH2RSf3DmqdHuzJKX95mZ1L9/pGu44SyXeMTqSHcxjZpOapASSmuByMDllMmECKq87aJnu/FzkIhbijBBKN9q5yrRxoYpRQoTfsyYwP+QnQZuVU= 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=m8KyEwe1; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=XdXl50y8; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Message-ID: <20240610164027.668436817@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1718037768; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=MQO2EYZPqj5U7pySt49QYzOaZrWaUy6rIJlwsdY8EF8=; b=m8KyEwe1gjtu0ioaXkqDH0NdHS5e7870xH+P/Er08pBjYu3j+CqFMytL1ZRMJJccQtcGIm BvQg3DVQ9qZPH/GzaNwwwwbAyScyefiCxakaLeuV5R6z3fMycHzHy9SYyiFR9Gs2LelNfJ EVzU83uta+xIIRQv7IJ1IW9JNECB7lx9AirX0PDKIMcWn/bAv8q9rWKAxxnGSQrZXPN+Wq eUM/pLHiwXtaCIMmW8O08uaSXu8SdMf5CWLKuHK5mPB15IfzIqDLzUtAj+Js82Yo1eHgH9 aAVDu2YLoUoAEOcZydkawavbsGI2pNONcAZlNgRwRtF8g2hyeJ8w7d7LufrgDg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1718037768; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=MQO2EYZPqj5U7pySt49QYzOaZrWaUy6rIJlwsdY8EF8=; b=XdXl50y8CR72X2P5yTJolkSBEZppLYYiiLyKFa1EMw9V6lPiC33K2YD9eGtC8/+LdCUrp0 S7sm1HrIW82IMYBg== From: Thomas Gleixner To: LKML Cc: Anna-Maria Behnsen , Frederic Weisbecker , John Stultz , Peter Zijlstra , Ingo Molnar , Stephen Boyd , Eric Biederman , Oleg Nesterov Subject: [patch V3 35/51] posix-cpu-timers: Use dedicated flag for CPU timer nanosleep References: <20240610163452.591699700@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Mon, 10 Jun 2024 18:42:48 +0200 (CEST) POSIX CPU timer nanosleep creates a k_itimer on stack and uses the sigq pointer to detect the nanosleep case in the expiry function. Prepare for embedding sigqueue into struct k_itimer by using a dedicated flag for nanosleep. Signed-off-by: Thomas Gleixner --- include/linux/posix-timers.h | 4 +++- kernel/time/posix-cpu-timers.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h @@ -42,6 +42,7 @@ static inline int clockid_to_fd(const cl * @pid: Pointer to target task PID * @elist: List head for the expiry list * @firing: Timer is currently firing + * @nanosleep: Timer is used for nanosleep and is not a regular posix-timer * @handling: Pointer to the task which handles expiry */ struct cpu_timer { @@ -49,7 +50,8 @@ struct cpu_timer { struct timerqueue_head *head; struct pid *pid; struct list_head elist; - int firing; + bool firing; + bool nanosleep; struct task_struct __rcu *handling; }; --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -588,7 +588,7 @@ static void cpu_timer_fire(struct k_itim timer->it_status = POSIX_TIMER_DISARMED; - if (unlikely(timer->sigq == NULL)) { + if (unlikely(ctmr->nanosleep)) { /* * This a special case for clock_nanosleep, * not a normal timer from sys_timer_create. @@ -1479,6 +1479,7 @@ static int do_cpu_nanosleep(const clocki timer.it_overrun = -1; error = posix_cpu_timer_create(&timer); timer.it_process = current; + timer.it.cpu.nanosleep = true; if (!error) { static struct itimerspec64 zero_it;