CVS commit: src/external/cddl/osnet/sys/kern
Module Name:src Committed By: riastradh Date: Sat Sep 9 00:14:16 UTC 2023 Modified Files: src/external/cddl/osnet/sys/kern: kmem.c Log Message: solaris: Use pool_cache_reclaim, not pool_cache_invalidate. pool_cache_invalidate invalidates cached objects, but doesn't return any backing pages to the underlying page allocator. pool_cache_reclaim does pool_cache_invalidate _and_ reutrns backing pages to the underlying page alloator, so it is actually useful for the page daemon to do when trying to free memory. PR kern/57558 XXX pullup-10 XXX pullup-9 XXX pullup-8 (by patch to kmem.h instead of kmem.c) To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/sys/kern/kmem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/sys/kern/kmem.c diff -u src/external/cddl/osnet/sys/kern/kmem.c:1.3 src/external/cddl/osnet/sys/kern/kmem.c:1.4 --- src/external/cddl/osnet/sys/kern/kmem.c:1.3 Wed Nov 11 03:31:04 2020 +++ src/external/cddl/osnet/sys/kern/kmem.c Sat Sep 9 00:14:16 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: kmem.c,v 1.3 2020/11/11 03:31:04 chs Exp $ */ +/* $NetBSD: kmem.c,v 1.4 2023/09/09 00:14:16 riastradh Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. @@ -123,7 +123,7 @@ void kmem_cache_reap_now(kmem_cache_t *km) { - pool_cache_invalidate(km->km_pool); + pool_cache_reclaim(km->km_pool); } #undef kmem_alloc
CVS commit: src/external/cddl/osnet/sys/kern
Module Name:src Committed By: riastradh Date: Sat Sep 9 00:14:16 UTC 2023 Modified Files: src/external/cddl/osnet/sys/kern: kmem.c Log Message: solaris: Use pool_cache_reclaim, not pool_cache_invalidate. pool_cache_invalidate invalidates cached objects, but doesn't return any backing pages to the underlying page allocator. pool_cache_reclaim does pool_cache_invalidate _and_ reutrns backing pages to the underlying page alloator, so it is actually useful for the page daemon to do when trying to free memory. PR kern/57558 XXX pullup-10 XXX pullup-9 XXX pullup-8 (by patch to kmem.h instead of kmem.c) To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/sys/kern/kmem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/cddl/osnet/sys/kern
Module Name:src Committed By: christos Date: Wed Mar 30 16:34:27 UTC 2022 Modified Files: src/external/cddl/osnet/sys/kern: policy.c Log Message: Add link our policy. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/external/cddl/osnet/sys/kern/policy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/sys/kern/policy.c diff -u src/external/cddl/osnet/sys/kern/policy.c:1.9 src/external/cddl/osnet/sys/kern/policy.c:1.10 --- src/external/cddl/osnet/sys/kern/policy.c:1.9 Fri Aug 28 12:13:48 2020 +++ src/external/cddl/osnet/sys/kern/policy.c Wed Mar 30 12:34:27 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: policy.c,v 1.9 2020/08/28 16:13:48 hannken Exp $ */ +/* $NetBSD: policy.c,v 1.10 2022/03/30 16:34:27 christos Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -144,7 +144,8 @@ int secpolicy_basic_link(vnode_t *vp, cred_t *cred) { - return kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, NULL); + return kauth_authorize_vnode(cred, KAUTH_VNODE_ADD_LINK, vp, + /* XXX dvp, currently unused */ NULL, 0); } int
CVS commit: src/external/cddl/osnet/sys/kern
Module Name:src Committed By: christos Date: Wed Mar 30 16:34:27 UTC 2022 Modified Files: src/external/cddl/osnet/sys/kern: policy.c Log Message: Add link our policy. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/external/cddl/osnet/sys/kern/policy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/cddl/osnet/sys/kern
Module Name:src Committed By: riastradh Date: Fri Mar 18 23:32:14 UTC 2022 Modified Files: src/external/cddl/osnet/sys/kern: ddi.c Log Message: osnet: Delete dead #if 0 code using hardclock_ticks. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/external/cddl/osnet/sys/kern/ddi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/cddl/osnet/sys/kern
Module Name:src Committed By: riastradh Date: Fri Mar 18 23:32:14 UTC 2022 Modified Files: src/external/cddl/osnet/sys/kern: ddi.c Log Message: osnet: Delete dead #if 0 code using hardclock_ticks. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/external/cddl/osnet/sys/kern/ddi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/sys/kern/ddi.c diff -u src/external/cddl/osnet/sys/kern/ddi.c:1.8 src/external/cddl/osnet/sys/kern/ddi.c:1.9 --- src/external/cddl/osnet/sys/kern/ddi.c:1.8 Tue Jun 18 22:34:26 2019 +++ src/external/cddl/osnet/sys/kern/ddi.c Fri Mar 18 23:32:14 2022 @@ -675,19 +675,3 @@ ddi_remove_minor_node(dev_info_t *dip, c do_rmdirp(pn); PNBUF_PUT(pn); } - -#if 0 -clock_t -ddi_get_lbolt() -{ - - return hardclock_ticks; -} - -int64_t -ddi_get_lbolt64() -{ - - return hardclock_ticks; -} -#endif
CVS commit: src/external/cddl/osnet/sys/kern
Module Name:src Committed By: mlelstv Date: Sun Sep 5 11:43:22 UTC 2021 Modified Files: src/external/cddl/osnet/sys/kern: vfs.c Log Message: Don't use __FBSDID, similar to kern/kobj.c, kern/misc.c, kern/sysevent.c To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/external/cddl/osnet/sys/kern/vfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/sys/kern/vfs.c diff -u src/external/cddl/osnet/sys/kern/vfs.c:1.8 src/external/cddl/osnet/sys/kern/vfs.c:1.9 --- src/external/cddl/osnet/sys/kern/vfs.c:1.8 Wed May 22 08:42:57 2019 +++ src/external/cddl/osnet/sys/kern/vfs.c Sun Sep 5 11:43:22 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs.c,v 1.8 2019/05/22 08:42:57 hannken Exp $ */ +/* $NetBSD: vfs.c,v 1.9 2021/09/05 11:43:22 mlelstv Exp $ */ /*- * Copyright (c) 2006-2007 Pawel Jakub Dawidek @@ -27,8 +27,9 @@ */ #include -#define __FBSDID(x) +#ifdef __FreeBSD__ __FBSDID("$FreeBSD: head/sys/cddl/compat/opensolaris/kern/opensolaris_lookup.c 314194 2017-02-24 07:53:56Z avg $"); +#endif #include #include
CVS commit: src/external/cddl/osnet/sys/kern
Module Name:src Committed By: mlelstv Date: Sun Sep 5 11:43:22 UTC 2021 Modified Files: src/external/cddl/osnet/sys/kern: vfs.c Log Message: Don't use __FBSDID, similar to kern/kobj.c, kern/misc.c, kern/sysevent.c To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/external/cddl/osnet/sys/kern/vfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/cddl/osnet/sys/kern
Module Name:src Committed By: hannken Date: Tue Aug 20 08:12:50 UTC 2019 Modified Files: src/external/cddl/osnet/sys/kern: taskq.c Log Message: task_executor: prevent use after free, the task function may free the tasq entry. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/external/cddl/osnet/sys/kern/taskq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/cddl/osnet/sys/kern
Module Name:src Committed By: hannken Date: Tue Aug 20 08:12:50 UTC 2019 Modified Files: src/external/cddl/osnet/sys/kern: taskq.c Log Message: task_executor: prevent use after free, the task function may free the tasq entry. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/external/cddl/osnet/sys/kern/taskq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/sys/kern/taskq.c diff -u src/external/cddl/osnet/sys/kern/taskq.c:1.10 src/external/cddl/osnet/sys/kern/taskq.c:1.11 --- src/external/cddl/osnet/sys/kern/taskq.c:1.10 Tue Jun 11 09:05:33 2019 +++ src/external/cddl/osnet/sys/kern/taskq.c Tue Aug 20 08:12:50 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: taskq.c,v 1.10 2019/06/11 09:05:33 hannken Exp $ */ +/* $NetBSD: taskq.c,v 1.11 2019/08/20 08:12:50 hannken Exp $ */ /*- * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -75,6 +75,7 @@ task_executor(struct threadpool_job *job struct taskq_executor *state = (struct taskq_executor *)job; taskq_t *tq = state->te_self; taskq_ent_t *tqe; + bool is_dynamic; int error; lwp_setspecific(taskq_lwp_key, tq); @@ -97,13 +98,14 @@ task_executor(struct threadpool_job *job tqe = SIMPLEQ_FIRST(&tq->tq_list); KASSERT(tqe != NULL); SIMPLEQ_REMOVE_HEAD(&tq->tq_list, tqent_list); + is_dynamic = tqe->tqent_dynamic; tqe->tqent_queued = 0; mutex_exit(&tq->tq_lock); (*tqe->tqent_func)(tqe->tqent_arg); mutex_enter(&tq->tq_lock); - if (tqe->tqent_dynamic) + if (is_dynamic) kmem_free(tqe, sizeof(*tqe)); tq->tq_active--; }
CVS commit: src/external/cddl/osnet/sys/kern
Module Name:src Committed By: hannken Date: Tue Jun 11 09:05:33 UTC 2019 Modified Files: src/external/cddl/osnet/sys/kern: taskq.c Log Message: There is no 1:1 relation between cv_signal() and cv_timedwait() as the latter implicitly calls cv_signal() on error. This leads to "tq_waiting > 0" with "tq_running == 0" and the taskq stalls. Change task_executor() to increment and decrement "tq_waiting" and always check and run the queue after cv_timedwait(). Use mstohz(), fix timeout and sort includes. Addresses PR port-xen/54273: "zpool create pool xbd2" panics DOMU kernel To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/external/cddl/osnet/sys/kern/taskq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/sys/kern/taskq.c diff -u src/external/cddl/osnet/sys/kern/taskq.c:1.9 src/external/cddl/osnet/sys/kern/taskq.c:1.10 --- src/external/cddl/osnet/sys/kern/taskq.c:1.9 Tue May 7 08:49:59 2019 +++ src/external/cddl/osnet/sys/kern/taskq.c Tue Jun 11 09:05:33 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: taskq.c,v 1.9 2019/05/07 08:49:59 hannken Exp $ */ +/* $NetBSD: taskq.c,v 1.10 2019/06/11 09:05:33 hannken Exp $ */ /*- * Copyright (c) 2019 The NetBSD Foundation, Inc. @@ -30,9 +30,11 @@ */ #include -#include +#include #include +#include #include +#include #include #include @@ -65,7 +67,7 @@ static specificdata_key_t taskq_lwp_key; /* * Threadpool job to service tasks from task queue. - * Runs until the task queue gets destroyed or the queue is empty for 5 secs. + * Runs until the task queue gets destroyed or the queue is empty for 10 secs. */ static void task_executor(struct threadpool_job *job) @@ -73,22 +75,27 @@ task_executor(struct threadpool_job *job struct taskq_executor *state = (struct taskq_executor *)job; taskq_t *tq = state->te_self; taskq_ent_t *tqe; + int error; lwp_setspecific(taskq_lwp_key, tq); mutex_enter(&tq->tq_lock); while (!tq->tq_destroyed) { - tqe = SIMPLEQ_FIRST(&tq->tq_list); - if (tqe == NULL) { + if (SIMPLEQ_EMPTY(&tq->tq_list)) { if (ISSET(tq->tq_flags, TASKQ_DYNAMIC)) break; tq->tq_waiting++; - if (cv_timedwait(&tq->tq_cv, &tq->tq_lock, 5000) != 0) { -tq->tq_waiting--; -break; + error = cv_timedwait(&tq->tq_cv, &tq->tq_lock, + mstohz(1)); + tq->tq_waiting--; + if (SIMPLEQ_EMPTY(&tq->tq_list)) { +if (error) + break; +continue; } - continue; } + tqe = SIMPLEQ_FIRST(&tq->tq_list); + KASSERT(tqe != NULL); SIMPLEQ_REMOVE_HEAD(&tq->tq_list, tqent_list); tqe->tqent_queued = 0; mutex_exit(&tq->tq_lock); @@ -144,7 +151,6 @@ taskq_dispatch_common(taskq_t *tq, taskq tq->tq_active++; if (tq->tq_waiting) { cv_signal(&tq->tq_cv); - tq->tq_waiting--; mutex_exit(&tq->tq_lock); return; }
CVS commit: src/external/cddl/osnet/sys/kern
Module Name:src Committed By: hannken Date: Tue Jun 11 09:05:33 UTC 2019 Modified Files: src/external/cddl/osnet/sys/kern: taskq.c Log Message: There is no 1:1 relation between cv_signal() and cv_timedwait() as the latter implicitly calls cv_signal() on error. This leads to "tq_waiting > 0" with "tq_running == 0" and the taskq stalls. Change task_executor() to increment and decrement "tq_waiting" and always check and run the queue after cv_timedwait(). Use mstohz(), fix timeout and sort includes. Addresses PR port-xen/54273: "zpool create pool xbd2" panics DOMU kernel To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/external/cddl/osnet/sys/kern/taskq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/cddl/osnet/sys/kern
Module Name:src Committed By: hannken Date: Fri Jun 7 10:31:21 UTC 2019 Modified Files: src/external/cddl/osnet/sys/kern: callb.c fm.c Log Message: Sync with upstream r315983. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/external/cddl/osnet/sys/kern/callb.c cvs rdiff -u -r1.2 -r1.3 src/external/cddl/osnet/sys/kern/fm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/cddl/osnet/sys/kern
Module Name:src Committed By: hannken Date: Fri Jun 7 10:31:21 UTC 2019 Modified Files: src/external/cddl/osnet/sys/kern: callb.c fm.c Log Message: Sync with upstream r315983. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/external/cddl/osnet/sys/kern/callb.c cvs rdiff -u -r1.2 -r1.3 src/external/cddl/osnet/sys/kern/fm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/sys/kern/callb.c diff -u src/external/cddl/osnet/sys/kern/callb.c:1.1 src/external/cddl/osnet/sys/kern/callb.c:1.2 --- src/external/cddl/osnet/sys/kern/callb.c:1.1 Fri Aug 7 20:57:57 2009 +++ src/external/cddl/osnet/sys/kern/callb.c Fri Jun 7 10:31:21 2019 @@ -1,12 +1,9 @@ -/* $NetBSD: callb.c,v 1.1 2009/08/07 20:57:57 haad Exp $ */ - /* * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -22,12 +19,10 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include #include #include @@ -111,14 +106,24 @@ void callb_fini(void *dummy __unused) { callb_t *cp; + int i; mutex_enter(&ct->ct_lock); - while ((cp = ct->ct_freelist) != NULL) { - ct->ct_freelist = cp->c_next; - ct->ct_ncallb--; - kmem_free(cp, sizeof (callb_t)); + for (i = 0; i < 16; i++) { + while ((cp = ct->ct_freelist) != NULL) { + ct->ct_freelist = cp->c_next; + ct->ct_ncallb--; + kmem_free(cp, sizeof (callb_t)); + } + if (ct->ct_ncallb == 0) + break; + /* Not all callbacks finished, waiting for the rest. */ + mutex_exit(&ct->ct_lock); + tsleep(ct, 0, "callb", hz / 4); + mutex_enter(&ct->ct_lock); } - ASSERT(ct->ct_ncallb == 0); + if (ct->ct_ncallb > 0) + printf("%s: Leaked %d callbacks!\n", __func__, ct->ct_ncallb); mutex_exit(&ct->ct_lock); mutex_destroy(&callb_safe_mutex); mutex_destroy(&callb_table.ct_lock); @@ -270,7 +275,7 @@ callb_execute_class(int class, int code) #ifdef CALLB_DEBUG printf("callb_execute: name=%s func=%p arg=%p\n", - cp->c_name, (void *)cp->c_func, (void *)cp->c_arg); + cp->c_name, (void *)cp->c_func, (void *)cp->c_arg); #endif /* CALLB_DEBUG */ mutex_exit(&ct->ct_lock); @@ -309,12 +314,14 @@ callb_generic_cpr(void *arg, int code) switch (code) { case CB_CODE_CPR_CHKPT: cp->cc_events |= CALLB_CPR_START; +#ifdef CPR_NOT_THREAD_SAFE while (!(cp->cc_events & CALLB_CPR_SAFE)) /* cv_timedwait() returns -1 if it times out. */ - if ((ret = cv_timedwait(&cp->cc_callb_cv, - cp->cc_lockp, - callb_timeout_sec * hz)) == -1) + if ((ret = cv_reltimedwait(&cp->cc_callb_cv, + cp->cc_lockp, (callb_timeout_sec * hz), + TR_CLOCK_TICK)) == -1) break; +#endif break; case CB_CODE_CPR_RESUME: @@ -360,3 +367,74 @@ callb_unlock_table(void) cv_broadcast(&ct->ct_busy_cv); mutex_exit(&ct->ct_lock); } + +#ifdef illumos +/* + * Return a boolean value indicating whether a particular kernel thread is + * stopped in accordance with the cpr callback protocol. If returning + * false, also return a pointer to the thread name via the 2nd argument. + */ +boolean_t +callb_is_stopped(kthread_id_t tp, caddr_t *thread_name) +{ + callb_t *cp; + boolean_t ret_val; + + mutex_enter(&ct->ct_lock); + + for (cp = ct->ct_first_cb[CB_CL_CPR_DAEMON]; + cp != NULL && tp != cp->c_thread; cp = cp->c_next) + ; + + ret_val = (cp != NULL); + if (ret_val) { + /* + * We found the thread in the callback table and have + * provisionally set the return value to true. Now + * see if it is marked "safe" and is sleeping or stopped. + */ + callb_cpr_t *ccp = (callb_cpr_t *)cp->c_arg; + + *thread_name = cp->c_name; /* in case not stopped */ + mutex_enter(ccp->cc_lockp); + + if (ccp->cc_events & CALLB_CPR_SAFE) { + int retry; + + mutex_exit(ccp->cc_lockp); + for (retry = 0; retry < CALLB_MAX_RETRY; retry++) { +thread_lock(tp); +if (tp->t_state & (TS_SLEEP | TS_STOPPED)) { + thread_unlock(tp); + break; +} +thread_unlock(tp); +delay(CALLB_THREAD_DELAY); + } + ret_val = retry < CALLB_MAX_RETRY; + } else { + ret_val = + (ccp->cc_events & CALLB_CPR_ALWAYS_SAFE) != 0; + mutex_exit(ccp->cc_lockp); + } + } else { + /* + * Thread not found in callback table. Make the best + * attempt to identify the thread in the error message. + */ + ulong_t offset; +