Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp486878lqp; Mon, 10 Jun 2024 09:50:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWqkoJ2DYMwxyI477KT6IkI//klQx/6OT3cG3o1hdo+yBxLAqEmEeZ5BmjKhBHGhBTu5bLRzNS5p9EQ4twgznuCX1iHVFJBzzehDtkmCg== X-Google-Smtp-Source: AGHT+IH4Pb/g8jhyfW86uo8Hp3gliG7arSnbEqAEI1JfQkKv+mLzOxDrlXP0Bu2GcPUK511hNfYL X-Received: by 2002:a17:90a:d581:b0:2c2:7bbe:d6ba with SMTP id 98e67ed59e1d1-2c2bc9ba54fmr9214927a91.8.1718038254658; Mon, 10 Jun 2024 09:50:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718038254; cv=pass; d=google.com; s=arc-20160816; b=ihgtdFqsrCfxc4wGJV/zIJOZhnoCCH0PhMbPHs7XOqS2vs+QFJLJA1CvocxGXXmA5w mzrQe+/Mx+nuSBAEdWSQyyRswe2agcOvACxjGMIUzOW7MhXHiC0kfPsfANXhXfq0sMid 24tP+mcGk2jnCme9K52kNVLsCHtxjomNDwD9dM8Ayt2yjBEb1VLayODjc40xMhBcUGNy weaEdjldlMukDMCYj5NcLyRDKT8PaBfNyljM3tTQvw2BoSAa/b+/Poi0ZBHsSAcBLRmB aF6JdUAy+EaUkUf4xLEkC8pHH3LhLvBFYCYRdxY03JChZT1mqaEYwpjXRDcTUMr6sBOA Chzg== 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=lbd4hY6DO5yS4CWfhpTcHrpvo9CKLyiSwH3SuNY1ueE=; fh=joBs/8L+orz77ylyCy6wqNwwi35f7sYhLR+/TQjQjhI=; b=bKkFGwDHoYQT9j3kGvcLD1UoqQw1aDTXaH6HQy0Vy24sP//l8x4D2XjRbugePIEABV Ks5xYxbkH2mzaLfPWxumEsFJirvOo/hiio/rLvDaxo4gwmEyVaGprbb0bAL1gR37Ht/L PiGsAb2gTMPaJGwk+VLcDD4BSIVJpS1ew67Lk6hwMUqq7pJ4rYbViLYMhq8vpkhZlXgb Ye8C1Xvrp2QxiJwGO+VFw5Ssw2JhawO4FBsnUUuacRYL5z5uxHt5VeDn7umnYjr4DNNk Uu39uBjdBpylmh8kI45YS52Ld3ewP5TsW3ME74L9UgA1h6WYh6DX46O6GmvE07uJ2MaX WMZQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="TlfQ/fIz"; 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-208603-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208603-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 98e67ed59e1d1-2c2806d27fesi8957054a91.140.2024.06.10.09.50.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 09:50:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208603-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="TlfQ/fIz"; 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-208603-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208603-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 4CB8B281FBE for ; Mon, 10 Jun 2024 16:50:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A0365158849; Mon, 10 Jun 2024 16:42:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="TlfQ/fIz"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="bKGP3LVD" 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 7A678158219 for ; Mon, 10 Jun 2024 16:42:56 +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=1718037777; cv=none; b=kN36ILygXyRucWVZvUEU9PtVti1WxwtlJar0rKNhiK6pm4qNPjFP0bEdxN0msWiwD9Ef9kf+AHHqtHej60DWelHu1qsjQc1GbhV2MqiBv9FodGJTR7vdLrZrflIPVflBSKM15C/kL+2vw17xYAF8JclMqBApm9w71ujh0MEDXmU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718037777; c=relaxed/simple; bh=Bp/mJsKy0K7y+W6reqzXaf54OlcjiFTLH7F90/BxRvU=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=dqpVTtiSCgeSbV7/qg8n5VOoqF73XvJh2OynCpzmZbk3GMfsTW4Av1gZ0+OzDmgQWizGHEZySAYgtBzCGwKQM/b/MrIuewlHQNq2WLImsV3u9devbwVtV7Km3L1HZ3wO+W/bBdOFiKNtO/PrzJbnsRIyBoz5z4j9l1c3krSDOg4= 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=TlfQ/fIz; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=bKGP3LVD; 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.988500833@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1718037774; 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=lbd4hY6DO5yS4CWfhpTcHrpvo9CKLyiSwH3SuNY1ueE=; b=TlfQ/fIznRlByLSiADsEJwsOcku5dU6LmwbMrS8AZlxssOeIUNHq+I7HrAcOeTb4HqwDdc qQWlGS0aNatffUpAZJBZ2LOvgdCTS9ovP9x625JfMfM5Jm00HlZ9/GAv8NRoze3c288sul 2d37JX/HRgjjsKCm0C7lZvjGYf19BOD0UlIUYNqJtXhIyX1PA4SM6NrwdHzspLf/+VBe0n HZD/OKOarTTiT6MM3FGftR9UOls5EhCSCmK0Oan3ivZhhVgWG1glAoy8d8u+opb5MoCq2l xVrxsluJ7qi6ZEkwf7qEZ6gNGlnyrKlLHKo96BHYFp6/wi7FdlCDMdoXqmtKCQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1718037774; 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=lbd4hY6DO5yS4CWfhpTcHrpvo9CKLyiSwH3SuNY1ueE=; b=bKGP3LVDlYFypVVTX2jeGI/ZNIYcbxKRNZr85L909WGLUoLLg4DaWDiNFpAprk+U4qPbjQ kDpYOZevpE/ndxAQ== 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 40/51] posix-timers: Store PID type in the timer 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:54 +0200 (CEST) instead of re-evaluating the signal delivery mode everywhere. Signed-off-by: Thomas Gleixner --- include/linux/posix-timers.h | 2 ++ kernel/time/posix-timers.c | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) --- a/include/linux/posix-timers.h +++ b/include/linux/posix-timers.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -180,6 +181,7 @@ struct k_itimer { s64 it_overrun_last; unsigned int it_signal_seq; int it_sigev_notify; + enum pid_type it_pid_type; ktime_t it_interval; struct signal_struct *it_signal; union { --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -298,7 +298,6 @@ bool posixtimer_deliver_signal(struct ke int posix_timer_queue_signal(struct k_itimer *timr) { enum posix_timer_state state = POSIX_TIMER_DISARMED; - enum pid_type type; int ret; lockdep_assert_held(&timr->it_lock); @@ -309,8 +308,7 @@ int posix_timer_queue_signal(struct k_it } timr->it_status = state; - type = !(timr->it_sigev_notify & SIGEV_THREAD_ID) ? PIDTYPE_TGID : PIDTYPE_PID; - ret = send_sigqueue(timr->sigq, timr->it_pid, type, timr->it_signal_seq); + ret = send_sigqueue(timr->sigq, timr->it_pid, timr->it_pid_type, timr->it_signal_seq); /* If we failed to send the signal the timer stops. */ return ret > 0; } @@ -504,6 +502,11 @@ static int do_timer_create(clockid_t whi new_timer->it_pid = get_pid(task_tgid(current)); } + if (new_timer->it_sigev_notify & SIGEV_THREAD_ID) + new_timer->it_pid_type = PIDTYPE_PID; + else + new_timer->it_pid_type = PIDTYPE_TGID; + new_timer->sigq->info.si_tid = new_timer->it_id; new_timer->sigq->info.si_code = SI_TIMER; new_timer->sigq->info.si_sys_privptr = new_timer;