From 7ac89421b5a801d998dd60ee8cd0684bc6e83fcd Mon Sep 17 00:00:00 2001 From: Robert Mustacchi Date: Sun, 3 Nov 2013 16:36:38 +0000 Subject: [PATCH] 4285 preemption leaves a context op behind Reviewed by: Bryan Cantrill Reviewed by: Richard Lowe Approved by: Dan McDonald --- usr/src/uts/common/disp/thread.c | 8 ++++++++ usr/src/uts/common/os/proc.c | 10 ++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/usr/src/uts/common/disp/thread.c b/usr/src/uts/common/disp/thread.c index 5ed9110251..8998b6ea51 100644 --- a/usr/src/uts/common/disp/thread.c +++ b/usr/src/uts/common/disp/thread.c @@ -21,6 +21,7 @@ /* * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, Joyent, Inc. All rights reserved. */ #include @@ -1092,6 +1093,7 @@ removectx( */ mutex_enter(&t->t_ctx_lock); prev_ctx = NULL; + kpreempt_disable(); for (ctx = t->t_ctx; ctx != NULL; ctx = ctx->next) { if (ctx->save_op == save && ctx->restore_op == restore && ctx->fork_op == fork && ctx->lwp_create_op == lwp_create && @@ -1105,11 +1107,13 @@ removectx( if (ctx->free_op != NULL) (ctx->free_op)(ctx->arg, 0); kmem_free(ctx, sizeof (struct ctxop)); + kpreempt_enable(); return (1); } prev_ctx = ctx; } mutex_exit(&t->t_ctx_lock); + kpreempt_enable(); return (0); } @@ -1187,12 +1191,14 @@ freectx(kthread_t *t, int isexec) { struct ctxop *ctx; + kpreempt_disable(); while ((ctx = t->t_ctx) != NULL) { t->t_ctx = ctx->next; if (ctx->free_op != NULL) (ctx->free_op)(ctx->arg, isexec); kmem_free(ctx, sizeof (struct ctxop)); } + kpreempt_enable(); } /* @@ -1209,12 +1215,14 @@ freectx_ctx(struct ctxop *ctx) ASSERT(ctx != NULL); + kpreempt_disable(); do { nctx = ctx->next; if (ctx->free_op != NULL) (ctx->free_op)(ctx->arg, 0); kmem_free(ctx, sizeof (struct ctxop)); } while ((ctx = nctx) != NULL); + kpreempt_enable(); } /* diff --git a/usr/src/uts/common/os/proc.c b/usr/src/uts/common/os/proc.c index 83563f34a9..3d4c82fcad 100644 --- a/usr/src/uts/common/os/proc.c +++ b/usr/src/uts/common/os/proc.c @@ -22,11 +22,12 @@ /* * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * Copyright (c) 2013, Joyent, Inc. All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include +#include +#include /* * Install process context ops for the current process. @@ -70,6 +71,7 @@ removepctx( struct pctxop *pctx, *prev_pctx; prev_pctx = NULL; + kpreempt_disable(); for (pctx = p->p_pctx; pctx != NULL; pctx = pctx->next) { if (pctx->save_op == save && pctx->restore_op == restore && pctx->fork_op == fork && @@ -82,10 +84,12 @@ removepctx( if (pctx->free_op != NULL) (pctx->free_op)(pctx->arg, 0); kmem_free(pctx, sizeof (struct pctxop)); + kpreempt_enable(); return (1); } prev_pctx = pctx; } + kpreempt_enable(); return (0); } @@ -146,10 +150,12 @@ freepctx(proc_t *p, int isexec) { struct pctxop *pctx; + kpreempt_disable(); while ((pctx = p->p_pctx) != NULL) { p->p_pctx = pctx->next; if (pctx->free_op != NULL) (pctx->free_op)(pctx->arg, isexec); kmem_free(pctx, sizeof (struct pctxop)); } + kpreempt_enable(); } -- 2.11.4.GIT