From nobody Thu Jun 06 21:50:53 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VwJ1B1tVJz5N5Cf; Thu, 06 Jun 2024 21:50:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VwJ1B0cRnz43jW; Thu, 6 Jun 2024 21:50:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717710654; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=eCwid2u4q7Rcb2ApE/yU1JZeJu0e5XXmz/sXN+zLLhE=; b=hUztkBiGdoFAVoIoOWk+YLOWiVcL0IAN40wTNpFGKR3DAOHchyI3bbWBBWvpITwd7WNckV lSjSL6hRWP1hcUtz+1ykPrGB/50KjfLwzqky99OFLkMHGUapZP034R8LdyTQIcw4GLgNli XxyP3W0R0N02nULklZuFF/GKyX3xkPREOpDMIYDopskYb19fYvYr11J/uqgeJWMuClhccK 5EnOzSTlSITuc3MoRV+B6KSr1KU0dT9eUnhwibzpqJjgwyKYD3limHva2nnVY/MMS8OR0F x1I5RcZBy618plCiRSa0idoH1V/0Ce9BHezTqDF/bmg8VpCOnf/WgoOIm1oafw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1717710654; a=rsa-sha256; cv=none; b=L7j7IJHQ9bgqhMvssx12UTWDnsH0mWAOaabnSq+1LS5xDPlq6kI10guwfognie+A00ITBH pLa2u85wc7VehDJWGnGJPBJ8hGZ6ursBYgWU4m3n8npveOmBFJXl9sAx+6lPJHEKt45MoB dnSexLleRq+WPPNPiVMG7o4Ip8lbjkMZaogJOt01MGs8ZYZ+8ubuTodmnO4H1zSztbj1f4 pNrrmiPRZTr6NXna10pd52dIV1g+3t1AOHeHBjcHvwHiNBjNTdv3U7WHJDhcDO6YpLOVp6 PcOkCMgZ+hzIeAYwgmRBifTDe+Zr2XmDHC8PDP7R//EZs52PWl2DsjOtl/OAZg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717710654; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=eCwid2u4q7Rcb2ApE/yU1JZeJu0e5XXmz/sXN+zLLhE=; b=TgEJ2SkW6QwDyhI7EB88hCSklusXUBiH53TZXlfGkQKodyDEtPvv/gRySXcTirHGdxOdEQ j/LJ09s9xDVqGzDxRMNl/hw7M7ORNZQerFbyP5mCPYqidZcJBxFFh0DzJ3cDglu7lVEUIn ddednxwgN4GJMxYR5BDdZMbuigX2CQPyAWs/A0kPgjrW/1JPzMYd6I3Jp3HMOtSPx2FBYf RMN9X1onoTCI3Hp5tgE5kxg+SFaSXceBYF04/ZQTFCTV6CpKj1L7N/qA6Lx+987DGppAkp VOYhiCXptC+GltC0gf2csYHiYmK7v27M3o3sJztxKmpvXl9YTznjBikNQ1XdhA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VwJ1B0DSzz13F8; Thu, 6 Jun 2024 21:50:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 456Lorsw058079; Thu, 6 Jun 2024 21:50:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 456LorpK058076; Thu, 6 Jun 2024 21:50:53 GMT (envelope-from git) Date: Thu, 6 Jun 2024 21:50:53 GMT Message-Id: <202406062150.456LorpK058076@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 7cae020b9c97 - main - Simplify signal handling code in libthr by removing use of SYS_sigreturn List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7cae020b9c977c11881363d726b13d1cd2feec5e Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=7cae020b9c977c11881363d726b13d1cd2feec5e commit 7cae020b9c977c11881363d726b13d1cd2feec5e Author: Dapeng Gao AuthorDate: 2024-06-03 18:18:13 +0000 Commit: Warner Losh CommitDate: 2024-06-06 21:48:39 +0000 Simplify signal handling code in libthr by removing use of SYS_sigreturn The use of SYS_sigreturn is unnecessary here. If handle_signal is called when a signal is delivered, it can just return normally back to sigcode which will call sigreturn anyway. In case handle_signal is called by check_deferred_signal, using setcontext is better than SYS_sigreturn because that is the correct system call to pair with the earlier getcontext. Reviewed by: imp, kib Differential Revision: https://reviews.freebsd.org/D44893 --- lib/libthr/thread/thr_sig.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/libthr/thread/thr_sig.c b/lib/libthr/thread/thr_sig.c index ad291d106001..b953c430158c 100644 --- a/lib/libthr/thread/thr_sig.c +++ b/lib/libthr/thread/thr_sig.c @@ -247,7 +247,6 @@ static void handle_signal(struct sigaction *actp, int sig, siginfo_t *info, ucontext_t *ucp) { struct pthread *curthread = _get_curthread(); - ucontext_t uc2; __siginfohandler_t *sigfunc; int cancel_point; int cancel_async; @@ -307,13 +306,11 @@ handle_signal(struct sigaction *actp, int sig, siginfo_t *info, ucontext_t *ucp) curthread->cancel_point = cancel_point; curthread->cancel_enable = cancel_enable; - memcpy(&uc2, ucp, sizeof(uc2)); - SIGDELSET(uc2.uc_sigmask, SIGCANCEL); + SIGDELSET(ucp->uc_sigmask, SIGCANCEL); /* reschedule cancellation */ - check_cancel(curthread, &uc2); + check_cancel(curthread, ucp); errno = err; - syscall(SYS_sigreturn, &uc2); } void @@ -400,6 +397,7 @@ check_deferred_signal(struct pthread *curthread) /* remove signal */ curthread->deferred_siginfo.si_signo = 0; handle_signal(&act, info.si_signo, &info, uc); + syscall(SYS_sigreturn, uc); } static void