From nobody Fri Jun 24 19:36:57 2022 X-Original-To: dev-commits-src-branches@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 360CB8644D4; Fri, 24 Jun 2022 19:36:59 +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 4LV6nj6VGdz4XFf; Fri, 24 Jun 2022 19:36:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656099418; 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=/N0hPPxsxKigW+nVXecTkgSqS2qGg16qDbt9MsP9OL0=; b=aZ5A1MHMCg0svKeE3r2e+afsHEmUKRLZEKJscd/hxQcArEj1zaTiMxOnMLYnWzS0j3X4SY mdSpmFt2/b8sAL0wKUFmLwGq0LzlqhpTt/OZvInpNgb5+/uwlxQb/uj7CAtJcHmVITBqta 7Dfk5J2eaBmRbdXyERJLzY+OHISlO86Qie54w4GSeNGpNbax6tejE7+8soxbSkUFZK07dm fwa/dcKv3UNmkotd9h3cpVOCI8aPnlTahn2IbIdV5u+CIU35GTsgHvY9X+hcM9aZ7kw15M Rcz1AH0ZlCsYBJCN2Bun0KjF//XYIGqGFI5ovswwWOlyu+DX3C7SCDFAjUcfxQ== 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 4536C1597F; Fri, 24 Jun 2022 19:36:57 +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 25OJav6p084212; Fri, 24 Jun 2022 19:36:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25OJav40084211; Fri, 24 Jun 2022 19:36:57 GMT (envelope-from git) Date: Fri, 24 Jun 2022 19:36:57 GMT Message-Id: <202206241936.25OJav40084211@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: ed770595b084 - stable/13 - thread_single: wait for P_STOPPED_SINGLE to pass List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: ed770595b08464f1422c86a3801d2d208a32e388 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656099418; 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=/N0hPPxsxKigW+nVXecTkgSqS2qGg16qDbt9MsP9OL0=; b=a76NRA/TxgxkyUssexrzV7ROoBkLbWmK9jQfJJLrdjsveH9lufk1vjCTwJbj4GDFfGKosR vnKCOO7l2LdTZw0sXn3u6PCSqDWWOZDNB4PVEfniBIfUUcCSkBoNgQnEWvnNd3uNRYCEw4 Paei83+B5ydbVX8DtUT4CkHK2OJI0wp39z9MQDAjol+NhqBMFHcVsWRohJGzLaYLP06bve wa9/hi6CwHU0KuqWKqkU+EBa9wYeelESHqeYn8M9LDrXFoMiWqBOSV9HRSb4vso1l+2WE3 TCdYSaz/Tzyn+oeTR9DK4cTSICjPNVw4STulY8wlkhkUro/7x9npbMQePlR5Yg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656099418; a=rsa-sha256; cv=none; b=VYXCI+bMn/F2qITZpHnzec7rCPV1QL2O9KFkIb9O8t6R/veXS9h10j/bWE/EibGTHL0i8B LRNzv4B8vssakB9RNbMTa+eBw0J7Dj4MmcOvhg8hBfdq0G/oHrZhmKeJmrmePjXQ5a+9BX B9D5NxAr7fhHacoUY8/in7HbWsH1oREfbd8N6hJc4doeY+ufPECqb1ev4noAawxwC1hVca otL/nCCZXtjbqs4VCNxOD6GDZ+h/0tvkXZ8OcA3EFmQpU4qpMk7iUNM64itT04PrVgJlE8 kY8yCzQ3CE4mgLa9wBrM2OzzAS4z4LwBt7ovEiL7HBMuj1mpYfgrTRRklc/f0A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ed770595b08464f1422c86a3801d2d208a32e388 commit ed770595b08464f1422c86a3801d2d208a32e388 Author: Konstantin Belousov AuthorDate: 2022-05-03 19:48:50 +0000 Commit: Konstantin Belousov CommitDate: 2022-06-24 14:45:45 +0000 thread_single: wait for P_STOPPED_SINGLE to pass (cherry picked from commit d7a9e6e74067f70eeec74dcd64a9bcc851503a6e) --- sys/kern/kern_thread.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index c56465835b3d..5e32a8be8f4e 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -1195,10 +1195,18 @@ thread_single(struct proc *p, int mode) mtx_assert(&Giant, MA_NOTOWNED); PROC_LOCK_ASSERT(p, MA_OWNED); - if ((p->p_flag & P_HADTHREADS) == 0 && mode != SINGLE_ALLPROC) + /* + * Is someone already single threading? + * Or may be singlethreading is not needed at all. + */ + if (mode == SINGLE_ALLPROC) { + while ((p->p_flag & P_STOPPED_SINGLE) != 0) { + if ((p->p_flag2 & P2_WEXIT) != 0) + return (1); + msleep(&p->p_flag, &p->p_mtx, PCATCH, "thrsgl", 0); + } + } else if ((p->p_flag & P_HADTHREADS) == 0) return (0); - - /* Is someone already single threading? */ if (p->p_singlethread != NULL && p->p_singlethread != td) return (1); @@ -1657,6 +1665,7 @@ thread_single_end(struct proc *p, int mode) PROC_SUNLOCK(p); if (wakeup_swapper) kick_proc0(); + wakeup(&p->p_flag); } /*