From nobody Wed Apr 27 23:27:52 2022 X-Original-To: dev-commits-src-main@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 0FADA1AA9342; Wed, 27 Apr 2022 23:27: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 4KpZfx1QqRz4YQm; Wed, 27 Apr 2022 23:27:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651102073; 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=z8aYsmcS8c88JJQJjPEoSt2CbqsNXvgjS3JB8HZ3m+Y=; b=mCJM5b8/Wrw3sy9cMlqUg+14Gy3OR4/0Xze6V5x1hIlD80yqg+KR+sa+ucJE7htXlw3FAr ROXk4BZ8kkebxoMMGk/eyAgjSfHIWCQ3p5cVbKRJPj9zcqaTgZppDeYZi3GJl7/5NwKPIA yMH//p3hb85SJjYofQN7Z5+/KPsx8SjPg49P/sZXofSN28YuFJjLocwquUsVBchOkm9pPH n9fq7JXZoFgFtYHIXQAEaqL5AIeW5YpjJVoxyLLK4a0RlsiU+rdSoIb2ccEFgWlqou8b9b SgiVJMbV4v/Dtg4c82PvWW6cIQ5x53MaZmlZ1yOcxSjp/6zUTur7+NwHu0v1iw== 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 E0F485722; Wed, 27 Apr 2022 23:27:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23RNRqrb071917; Wed, 27 Apr 2022 23:27:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23RNRqi7071916; Wed, 27 Apr 2022 23:27:52 GMT (envelope-from git) Date: Wed, 27 Apr 2022 23:27:52 GMT Message-Id: <202204272327.23RNRqi7071916@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 2e7595ef2f53 - main - Add stop_all_proc_block(9) List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2e7595ef2f53f6debec3c3d89bb9e0cd10394ed3 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651102073; 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=z8aYsmcS8c88JJQJjPEoSt2CbqsNXvgjS3JB8HZ3m+Y=; b=H4PGMmXApRNtqTla/kHLWhoZ3tavMWGx6VsYAb1T5jQwUkTVVKom9+fAB1m0MDgZ8wMkhY WxNIFSxHBiZt/0uE1/4otuDgor/zRB4TjJZRtApiGiiZ0TpdhGVB29VnjWPguSucxy6b9h +UZfv/LX3f+1gFaXxjWNkaXTsTlV4tjPwJyNCxyrb0CgqWHv4d7zu00qiEcOUPwIREpi+7 c5IYT99FmI1bF6xoVLYpetAEwSxKYLG7oJpXtOkUdy0Ddqlzmilx8TPsKd0Vm2hkaJkjQD 2mmWT3QvKurNac7NnjUwd2BzqnLU94WUIHVXfaB7m+VymcPYu4/i7eq+7ZrWWg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651102073; a=rsa-sha256; cv=none; b=Yar+t3hX8ly8HGcqut4dm3HED/76DUReC+UPEcX+4S56yRXExrPbWkqDWSigm2Rvt4Gh2Y Yj6a/M/kLA3ZoDycGWvV7wtPIJEYUw2wP2NJqXiryH7jmhdgQBlvgirrGdVTU68XaBH0nu yX4Po7dvBcSZ1KszGbtPFG35O7Buvtv84WhLkR4NwT3B+FQQ5TBVuLn6J1zM8AenYFfI7F oDb08AACAXTkNtmS7Ok2jzMy7j37J4EJXBznESaLTfsYKHJg7AQ38O82JyWI11TZHMGLRV 8tpS54xRY2LJOsB9mMzmBG/sIGfJ/mr+W9SBEtKU2sAW8dlFlhQAY3qERnDQ5A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=2e7595ef2f53f6debec3c3d89bb9e0cd10394ed3 commit 2e7595ef2f53f6debec3c3d89bb9e0cd10394ed3 Author: Konstantin Belousov AuthorDate: 2022-04-23 22:55:04 +0000 Commit: Konstantin Belousov CommitDate: 2022-04-27 23:27:35 +0000 Add stop_all_proc_block(9) It allows to have more than one consumer of thread_signle(SIGNLE_ALLPROC) by serializing them. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D35014 --- sys/kern/kern_proc.c | 19 +++++++++++++++++++ sys/sys/proc.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index d5aae09f2c4e..cd528d47830d 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -3396,6 +3396,21 @@ static SYSCTL_NODE(_kern_proc, KERN_PROC_VM_LAYOUT, vm_layout, CTLFLAG_RD | CTLFLAG_ANYBODY | CTLFLAG_MPSAFE, sysctl_kern_proc_vm_layout, "Process virtual address space layout info"); +static struct sx stop_all_proc_blocker; +SX_SYSINIT(stop_all_proc_blocker, &stop_all_proc_blocker, "sapblk"); + +void +stop_all_proc_block(void) +{ + sx_xlock(&stop_all_proc_blocker); +} + +void +stop_all_proc_unblock(void) +{ + sx_xunlock(&stop_all_proc_blocker); +} + int allproc_gen; /* @@ -3411,6 +3426,8 @@ stop_all_proc(void) int r, gen; bool restart, seen_stopped, seen_exiting, stopped_some; + stop_all_proc_block(); + cp = curproc; allproc_loop: sx_xlock(&allproc_lock); @@ -3502,6 +3519,8 @@ again: goto again; } sx_xunlock(&allproc_lock); + + stop_all_proc_unblock(); } /* #define TOTAL_STOP_DEBUG 1 */ diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 2556fd574d84..223714724aca 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1232,6 +1232,8 @@ void thread_unlink(struct thread *td); void thread_unsuspend(struct proc *p); void thread_wait(struct proc *p); +void stop_all_proc_block(void); +void stop_all_proc_unblock(void); void stop_all_proc(void); void resume_all_proc(void);