From nobody Thu Aug 15 14:29:57 2024 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 4Wl6w60mzLz5SGK9; Thu, 15 Aug 2024 14:29:58 +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 4Wl6w60J0mz4NY3; Thu, 15 Aug 2024 14:29:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723732198; 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=O4RrTHWsQtQileqWsK5OdwN+bXiCSRt+WGJtX8FdvXI=; b=eacCNhLRXdRjK0yvCchuTMEqzhoUfw7HILQX+kQI7OqIbLv6tfFvbuQcgq6iLvYrC4BFqF VqiFWm2coq+LpVHuKy9NFyEReSdBDXgk4q/3TXEMZHHlDhokjo2X0Y1QWIgEzbEepqe6MS LoWhGk9Kp5NhOAFAtafbrtJOaHsjj5FNvn+FRoxtvBaQ2a0+qz9M2gBicLUXrelwbaG/m1 /lY5BT/Sb7/q0FF9QSneAuftYAF3L7ph6UoFluBkg5RdhXdVF5NmD23N3H+Ch8gdKjMFp0 I5DcthEViQEfh/IcCq1Hs6kUR3L813Q/bmjKZ1A1eUpRdGYdd3dLg8aG3F5nGw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1723732198; a=rsa-sha256; cv=none; b=Ql25fzHdXA9MrJiqAx37Sq4g2i/LTx3FkzlbCkRpx3RB5dSFG8tP4VYigD+u46C9OYl1xQ vIa3B34r0199xY0sQSOTU1lQepqxWh7BsuexmQq7yh7UOMDg4HjHyAPIngYvQRHI2nRsfc jE2d8SeLlQhc586nLcckVnekXx67erfCyW8w3vfGIalCzuflV/Uqq40uVieF4emeZ9Ow38 W60UwCCDLCLyfq2DYJF2JAG1cNzWeodfaqn626EAX6YTfObtir1sDrz1m3JgxMYp6idzBg i152FrIWt1kiQMUyBDL7g5QPFvSxlKke8fLc3sr1rHOLMzcqZvxaThD4SYXC8w== 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=1723732198; 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=O4RrTHWsQtQileqWsK5OdwN+bXiCSRt+WGJtX8FdvXI=; b=xrpgpW/Uh9tX1Mk8s2RguNsz9LDElXk2AAdidBTAa8IBLe4zXI0dYqOqbi1rO3ybf7XdeR 9peOFpmI2xijyVuen0I0Gs5BdrenNN8gOmvm8jtUVJiyPBKgiK9gKG5eNNYlJFtL2ypsTo C0wa2o5yeYQ0E9R48aKjiGJHTz0+xwrlfIjZF8vnq6e9v5a/ljZgUOSLy3gPUDjgh7J/O2 rgvTWzzfG7tvnFLKaMIsSY118DHubqFEvwSLJlyJkx3p8TmFodn0BOozVNO4wi62iU/tRH P9TcSMSiHZ9fqX9a4u10cHif9D3AQiqAqw6E6u9gOhm6KN2fjeOOPN5EPkj/Lg== 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 4Wl6w571LQzRGC; Thu, 15 Aug 2024 14:29:57 +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 47FETvlI016636; Thu, 15 Aug 2024 14:29:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47FETv8u016633; Thu, 15 Aug 2024 14:29:57 GMT (envelope-from git) Date: Thu, 15 Aug 2024 14:29:57 GMT Message-Id: <202408151429.47FETv8u016633@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 665b21f583e8 - stable/14 - intr: Remove dead code from intr_event_remove_handler() 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: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 665b21f583e8066df90e9e07d66657ddd8a02a53 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=665b21f583e8066df90e9e07d66657ddd8a02a53 commit 665b21f583e8066df90e9e07d66657ddd8a02a53 Author: Mark Johnston AuthorDate: 2024-07-30 14:35:53 +0000 Commit: Mark Johnston CommitDate: 2024-08-15 14:29:49 +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 (cherry picked from commit 177624f2f425901bb241789d639a16bded2247ae) --- 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 912504f8b1d0..6869d9112ea9 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);