Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp66065lqg; Wed, 10 Apr 2024 15:51:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVwyMMhp3UlqNxlcfvFixz2GvghwRLiiDg77FgmVgCV1hRmzsgddBj5qzX4n82seushH0Bsv1uQt3iPYKvipZmtzX8b/2mLq+lueLmPgw== X-Google-Smtp-Source: AGHT+IFFNyh+c6dvr9QwPLTqTQwYohMF+rv8bEDJEjQvPoYzudFKQFgP3UMLtt/MP1Siik1msvmZ X-Received: by 2002:a05:620a:4111:b0:788:2b1c:1e57 with SMTP id j17-20020a05620a411100b007882b1c1e57mr4609803qko.55.1712789495683; Wed, 10 Apr 2024 15:51:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712789495; cv=pass; d=google.com; s=arc-20160816; b=ZroSvXJayrZGqRMczPUZ0gWgLf2VOw2UCF2Lr1ihw/kw37kjYhkxjTWvR+p+SvAMMF CL/+pe73dRiP5WLBsHRBPsvil5E6gARCW9H658g3TF1SEPWYQA46/i8k3mXxJCSKLRVI lsNrP4R5c4rdWrw+CSm4H2SvPz+veGq3k6b+HtAAd38Lu+4SoFCzOa3mNTi218bsSYso pYdJ/Qr9B6oSCgur0JPCzYEmkCXLSgqNPFTrx13mPtsaSeJ1fp0uBj90sNYPMM1X9WxN 7b7YPuVr6q6l1eVZnOLg+pMp6zxoce9OwuWQ1S7Y8xicXdKAFs9CBcW5RKLlfWTEw1WA yw5g== 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=t7pjsSQKBc6tEHZWynKUhlTqjE2Ct45jVqlBq7pgRI0=; fh=joBs/8L+orz77ylyCy6wqNwwi35f7sYhLR+/TQjQjhI=; b=axlmwYHXZXTNKU1Y6RLhm9QQa3bF3Ec19WglReqqcOpMNc07yD8VBivJGeKUPZVqIj MVx1f4m32p1qePkpmWTrsYjJeHTNP72K/gndOsnov+IFJFfD8uECeIJ2XQzFXGKISDnT urXfUnIWcpFONh0rPDRbvDMzgEp9bq9Yyq81O279wXGmDMG9JIdJUANeFHUeCNNY2jTo Pr5PEDJDJDTzMlzZSRCAd0avkttPo9n6NhCOPx7DeBM0g/BgNYTuKo+BWCz7o4OozOD9 vNMEo4ebqz+6B+O9iXEffwNMryR2ppx14NnhBKpMKjOzc+Cj0VUW9tkLbQUYJ/lO2cbq BiIw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=mPDwHGzM; 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-139479-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139479-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o22-20020a05620a111600b0078a078f100csi268656qkk.333.2024.04.10.15.51.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 15:51:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139479-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=mPDwHGzM; 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-139479-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139479-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6A8291C218CB for ; Wed, 10 Apr 2024 22:51:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 617EE54FA2; Wed, 10 Apr 2024 22:47:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="mPDwHGzM"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="cbDIKNug" 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 1A87654F91 for ; Wed, 10 Apr 2024 22:46:59 +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=1712789221; cv=none; b=sX/m7inHdMmGH3K6bceYpIL5yXf0/nO7Bcc1KI961gfkSyLMc18rGxgG4o5y23lyMLxMp8e1PYdVmyPieY3N1e+pXEl1qiuRm4HrW5ZxLYaOaYq31vS8IFLLOyo8VM3AJVs2bnz8F2VWp0/KCTqMSnXQd9NozNnb/sV2tfthZVM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712789221; c=relaxed/simple; bh=ipfz+AaYDg2jRk2QzxjlJP24YxnDWUAysNYhb2QjuYU=; h=Message-ID:From:To:Cc:Subject:References:MIME-Version: Content-Type:Date; b=Ictxthlcx/mIf9UnRdAVhABgsC59MgCIVKrxBu1nlqXEhIl5WcpXd5okF7tXlWyifEPx1/K/Pojk2ar+UAlwAqiH13Q7qq0vlGC+ooiYY9ONNeFUf+L/ZNAbNRszGxpd2AJfnCPisC7/BS69ZtQFiydoB1YD7lEIZcW7yt//GrI= 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=mPDwHGzM; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=cbDIKNug; 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: <20240410165552.572304080@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1712789218; 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=t7pjsSQKBc6tEHZWynKUhlTqjE2Ct45jVqlBq7pgRI0=; b=mPDwHGzMsYi9guyziH1nqXc1/wh9AIulGLHFee23j+SNPuBzYg17wR2FD3n2ytABEFRe5V 7zzTKUgFXVZwjBnMm5VYbofTEf8mrJ3mW1x1hndkMX3QhRAE6QUXoIfz9zH1obhBN21VCT +tXZGzOJ9G2lNMsgp3uOIk/jxysM/vsKR7IZoydMfjzaY7FAJ0/biRpjLTcP1id51HhBzn g20pxjgMUnTce3UhlaBWSmsVTQ+OkbqmJ0JK7j1vTBNjte8uOPOD1PtBHcxkm2pJykX/nc yk1LJlOQvrIaVYpRBc5xW2ymV3/YQcD5Bz7VDa7LcJM+oJFOpal8hCbta/zz5Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1712789218; 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=t7pjsSQKBc6tEHZWynKUhlTqjE2Ct45jVqlBq7pgRI0=; b=cbDIKNugg358Psea1JVSW1YSq4zWt2pclLbdfx6o180qJhFcPTu1xY5dzI6MFHhxiyLJ9i 8SqzYdSfVCSzSLCg== 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 V2 26/50] signal: Get rid of resched_timer logic References: <20240410164558.316665885@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: Thu, 11 Apr 2024 00:46:57 +0200 (CEST) There is no reason for handing the *resched pointer argument through several functions just to check whether the signal is related to a self rearming posix timer. SI_TIMER is only used by the posix timer code and cannot be queued from user space. The only extra check in collect_signal() to verify whether the queued signal is preallocated is not really useful. Some other places already check purely the SI_TIMER type. Signed-off-by: Thomas Gleixner --- kernel/signal.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) --- a/kernel/signal.c +++ b/kernel/signal.c @@ -526,8 +526,7 @@ bool unhandled_signal(struct task_struct return !tsk->ptrace; } -static void collect_signal(int sig, struct sigpending *list, kernel_siginfo_t *info, - bool *resched_timer) +static void collect_signal(int sig, struct sigpending *list, kernel_siginfo_t *info) { struct sigqueue *q, *first = NULL; @@ -549,12 +548,6 @@ static void collect_signal(int sig, stru still_pending: list_del_init(&first->list); copy_siginfo(info, &first->info); - - *resched_timer = - (first->flags & SIGQUEUE_PREALLOC) && - (info->si_code == SI_TIMER) && - (info->si_sys_private); - __sigqueue_free(first); } else { /* @@ -571,13 +564,12 @@ static void collect_signal(int sig, stru } } -static int __dequeue_signal(struct sigpending *pending, sigset_t *mask, - kernel_siginfo_t *info, bool *resched_timer) +static int __dequeue_signal(struct sigpending *pending, sigset_t *mask, kernel_siginfo_t *info) { int sig = next_signal(pending, mask); if (sig) - collect_signal(sig, pending, info, resched_timer); + collect_signal(sig, pending, info); return sig; } @@ -589,17 +581,15 @@ static int __dequeue_signal(struct sigpe int dequeue_signal(sigset_t *mask, kernel_siginfo_t *info, enum pid_type *type) { struct task_struct *tsk = current; - bool resched_timer = false; int signr; lockdep_assert_held(&tsk->sighand->siglock); *type = PIDTYPE_PID; - signr = __dequeue_signal(&tsk->pending, mask, info, &resched_timer); + signr = __dequeue_signal(&tsk->pending, mask, info); if (!signr) { *type = PIDTYPE_TGID; - signr = __dequeue_signal(&tsk->signal->shared_pending, - mask, info, &resched_timer); + signr = __dequeue_signal(&tsk->signal->shared_pending, mask, info); if (unlikely(signr == SIGALRM)) posixtimer_rearm_itimer(tsk); @@ -626,7 +616,7 @@ int dequeue_signal(sigset_t *mask, kerne } if (IS_ENABLED(CONFIG_POSIX_TIMERS)) { - if (unlikely(resched_timer)) + if (unlikely(info->si_code == SI_TIMER && info->si_sys_private)) posixtimer_rearm(info); } @@ -1011,6 +1001,9 @@ static int __send_signal_locked(int sig, lockdep_assert_held(&t->sighand->siglock); + if (WARN_ON_ONCE(!is_si_special(info) && info->si_code == SI_TIMER)) + return 0; + result = TRACE_SIGNAL_IGNORED; if (!prepare_signal(sig, t, force)) goto ret;