From owner-dev-commits-src-all@freebsd.org Tue Aug 3 10:52:59 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E882A636276; Tue, 3 Aug 2021 10:52: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 4GfBY763H9z3lGN; Tue, 3 Aug 2021 10:52:59 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 B27F8121B5; Tue, 3 Aug 2021 10:52:59 +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 173AqxQ0063672; Tue, 3 Aug 2021 10:52:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 173AqxgH063671; Tue, 3 Aug 2021 10:52:59 GMT (envelope-from git) Date: Tue, 3 Aug 2021 10:52:59 GMT Message-Id: <202108031052.173AqxgH063671@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: 130f41810ea7 - stable/13 - linuxkpi: remove global atomic counter of the task allocations 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: 130f41810ea754d4ba2da636d7804458185b7ed0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Aug 2021 10:53:00 -0000 The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=130f41810ea754d4ba2da636d7804458185b7ed0 commit 130f41810ea754d4ba2da636d7804458185b7ed0 Author: Konstantin Belousov AuthorDate: 2021-05-20 15:28:20 +0000 Commit: Konstantin Belousov CommitDate: 2021-08-03 09:56:02 +0000 linuxkpi: remove global atomic counter of the task allocations (cherry picked from commit d96f55bc7159e8d018847abe5b1782d74c8aa415) --- sys/compat/linuxkpi/common/src/linux_current.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_current.c b/sys/compat/linuxkpi/common/src/linux_current.c index 51e396081c04..925d96770cc2 100644 --- a/sys/compat/linuxkpi/common/src/linux_current.c +++ b/sys/compat/linuxkpi/common/src/linux_current.c @@ -45,7 +45,6 @@ extern u_int first_msi_irq, num_msi_irqs; static eventhandler_tag linuxkpi_thread_dtor_tag; -static atomic_t linux_current_allocs; static uma_zone_t linux_current_zone; static uma_zone_t linux_mm_zone; @@ -147,10 +146,6 @@ linux_alloc_current(struct thread *td, int flags) /* free mm_struct pointer, if any */ uma_zfree(linux_mm_zone, mm); - /* keep track of number of allocations */ - if (atomic_add_return(1, &linux_current_allocs) == INT_MAX) - panic("linux_alloc_current: Refcount too high!"); - return (0); } @@ -178,10 +173,6 @@ linux_free_current(struct task_struct *ts) { mmput(ts->mm); uma_zfree(linux_current_zone, ts); - - /* keep track of number of allocations */ - if (atomic_sub_return(1, &linux_current_allocs) < 0) - panic("linux_free_current: Negative refcount!"); } static void @@ -306,9 +297,9 @@ linux_current_init(void *arg __unused) atomic_thread_fence_seq_cst(); - lkpi_alloc_current = linux_alloc_current; linuxkpi_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor, linuxkpi_thread_dtor, NULL, EVENTHANDLER_PRI_ANY); + lkpi_alloc_current = linux_alloc_current; } SYSINIT(linux_current, SI_SUB_EVENTHANDLER, SI_ORDER_SECOND, linux_current_init, NULL); @@ -337,17 +328,10 @@ linux_current_uninit(void *arg __unused) } sx_sunlock(&allproc_lock); - /* - * There is a window where threads are removed from the - * process list and where the thread destructor is invoked. - * Catch that window by waiting for all task_struct - * allocations to be returned before freeing the UMA zone. - */ - while (atomic_read(&linux_current_allocs) != 0) - pause("W", 1); + thread_reap_barrier(); EVENTHANDLER_DEREGISTER(thread_dtor, linuxkpi_thread_dtor_tag); - + uma_zdestroy(linux_current_zone); uma_zdestroy(linux_mm_zone); }