From nobody Tue Jul 30 14:39:31 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 4WYHtW3kBkz5S55y; Tue, 30 Jul 2024 14:39:31 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WYHtW36JTz52wt; Tue, 30 Jul 2024 14:39:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722350371; 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=KUO0Uyi+2qBj/YW5RySHERmOpNpI7eTVX8gbfwi3kbc=; b=SniokgihrB+7v1Wxnz9ope5vYEUfGtHRDNhqymyWXm6eNsqxB0Ctdpwa1GI4yCCoeGxW5b ryM229Z6UWpudiFV5RWK/occoWN1oiYQA+XxD+IIM4Vc1/WeiOyA4mW1sZdB9yzLt0aHkn iGnS3xfnU7bU4XIO/G4be5ZrKOeZ2LyRBdC6gAgSa2L+fq2+hoBXuVhmprGRd7ETgV9Ol9 1uoOCE0S02mSrE7CDddfjI6x/Fae2ejmUAdg5YvK7juAClAni4Uielw/kdoDfMTcqbvk2g 75QMndZKeMKfx+GvrJto2r9uE4lxt32YRFl1f/eOUvxDLLDOGtRgLDkCxMwSmQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722350371; a=rsa-sha256; cv=none; b=G1IRvPWlp8d7U6k83ug4jC02MiWrPb3IESCj0jJ6xI+mtVCS4rTioWzamfrH+ULOS/CT0H KAj6XbWC3HM8y0K3eZ6tOVEiQeUeJoYUHhjt5+d27kfspab2A1/wEX5pmAVTd+Qu/yJwiu ayN1UjqwmtJEjpzP3NcLJRC58EGHZ4PD6ZDEdbbL3Ups9RwDypi+5qoQVFsOICpxcfk1fr NtpqP+t582erjrdVkpcubdqvkg3daoRaHZH8bujkgvI97/Q/yFh1FI9MYZ9qpPFTwD/iKO JOjSV2djb7zklwyP1mQNuIQMUA7VCI+IwK4x6T7O/lF2soCVPtiu2Sjp5fJ4cA== 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=1722350371; 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=KUO0Uyi+2qBj/YW5RySHERmOpNpI7eTVX8gbfwi3kbc=; b=pK/oOjGBkL+X5iXaH37gjGViS6isQWCA1gmUn5muuX6oTGpm9tHDuMJzGII0B2tJBjx/32 0DGNQLyQLRBC0c9cbHOFPMkKkkybEccvducbesph+U8aGGloTEDpRBG1BtjyEH4Uom32yc 7w1sprYjdpScNLqmMuDpjE0aX33X6hQQal6QMwBQ4EnNp3IpC2DFz7rQCqGojn2vciIVbr mskFAdNIq6M41l2hPGv+VgLqvau2x3xEm6ki2OH684EluDySDZpfDezikvCXPEhtxS2U2H BpIkuuhPw00ZbEvgeKH6PT8GQpyx/fNMiHcdNR2g6lEczhEOo2JUTluhCTOREA== 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 4WYHtW2jwpzLgW; Tue, 30 Jul 2024 14:39:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46UEdVRF046220; Tue, 30 Jul 2024 14:39:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46UEdVU1046217; Tue, 30 Jul 2024 14:39:31 GMT (envelope-from git) Date: Tue, 30 Jul 2024 14:39:31 GMT Message-Id: <202407301439.46UEdVU1046217@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 177624f2f425 - main - intr: Remove dead code from intr_event_remove_handler() 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 177624f2f425901bb241789d639a16bded2247ae Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=177624f2f425901bb241789d639a16bded2247ae commit 177624f2f425901bb241789d639a16bded2247ae Author: Mark Johnston AuthorDate: 2024-07-30 14:35:53 +0000 Commit: Mark Johnston CommitDate: 2024-07-30 14:35:53 +0000 intr: Remove dead code from intr_event_remove_handler() We currently destroy the ithread in intr_event_destroy(). In preparation for fixing a bug there, remove this dead code and reorganize a bit to avoid some code duplication. No functional change intended. Reviewed by: kib, jhb MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D45490 --- sys/kern/kern_intr.c | 64 ++++++++++++++++------------------------------------ 1 file changed, 19 insertions(+), 45 deletions(-) diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c index 7a57d964acd9..6ccf758ae266 100644 --- a/sys/kern/kern_intr.c +++ b/sys/kern/kern_intr.c @@ -851,9 +851,6 @@ intr_event_remove_handler(void *cookie) struct intr_event *ie; struct intr_handler *ih; struct intr_handler **prevptr; -#ifdef notyet - int dead; -#endif if (handler == NULL) return (EINVAL); @@ -874,53 +871,30 @@ intr_event_remove_handler(void *cookie) "interrupt event \"%s\"", handler->ih_name, ie->ie_name); } - /* - * If there is no ithread, then directly remove the handler. Note that - * intr_event_handle() iterates ie_handlers in a lock-less fashion, so - * care needs to be taken to keep ie_handlers consistent and to free - * the removed handler only when ie_handlers is quiescent. - */ if (ie->ie_thread == NULL) { + /* + * If there is no ithread, then directly remove the handler. + * Note that intr_event_handle() iterates ie_handlers in a + * lock-less fashion, so care needs to be taken to keep + * ie_handlers consistent and to free the removed handler only + * when ie_handlers is quiescent. + */ CK_SLIST_REMOVE_PREVPTR(prevptr, ih, ih_next); intr_event_barrier(ie); - intr_event_update(ie); - mtx_unlock(&ie->ie_lock); - free(handler, M_ITHREAD); - return (0); + } else { + /* + * Let the interrupt thread do the job. The interrupt source is + * disabled when the interrupt thread is running, so it does not + * have to worry about interaction with intr_event_handle(). + */ + KASSERT((handler->ih_flags & IH_DEAD) == 0, + ("duplicate handle remove")); + handler->ih_flags |= IH_DEAD; + intr_event_schedule_thread(ie, NULL); + while (handler->ih_flags & IH_DEAD) + msleep(handler, &ie->ie_lock, 0, "iev_rmh", 0); } - - /* - * Let the interrupt thread do the job. - * The interrupt source is disabled when the interrupt thread is - * running, so it does not have to worry about interaction with - * intr_event_handle(). - */ - KASSERT((handler->ih_flags & IH_DEAD) == 0, - ("duplicate handle remove")); - handler->ih_flags |= IH_DEAD; - intr_event_schedule_thread(ie, NULL); - while (handler->ih_flags & IH_DEAD) - msleep(handler, &ie->ie_lock, 0, "iev_rmh", 0); intr_event_update(ie); - -#ifdef notyet - /* - * XXX: This could be bad in the case of ppbus(8). Also, I think - * this could lead to races of stale data when servicing an - * interrupt. - */ - dead = 1; - CK_SLIST_FOREACH(ih, &ie->ie_handlers, ih_next) { - if (ih->ih_handler != NULL) { - dead = 0; - break; - } - } - if (dead) { - ithread_destroy(ie->ie_thread); - ie->ie_thread = NULL; - } -#endif mtx_unlock(&ie->ie_lock); free(handler, M_ITHREAD); return (0);