Wed Apr 27 00:38:37 2011 UTC ()
Make stopsigmask static, sprinkle __cacheline_aligned and __read_mostly.


(rmind)
diff -r1.307 -r1.308 src/sys/kern/kern_sig.c
diff -r1.78 -r1.79 src/sys/sys/signalvar.h

cvs diff -r1.307 -r1.308 src/sys/kern/kern_sig.c (expand / switch to unified diff)

--- src/sys/kern/kern_sig.c 2011/01/17 07:13:31 1.307
+++ src/sys/kern/kern_sig.c 2011/04/27 00:38:37 1.308
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: kern_sig.c,v 1.307 2011/01/17 07:13:31 uebayasi Exp $ */ 1/* $NetBSD: kern_sig.c,v 1.308 2011/04/27 00:38:37 rmind Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Andrew Doran. 8 * by Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -55,28 +55,32 @@ @@ -55,28 +55,32 @@
55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 56 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * SUCH DAMAGE. 63 * SUCH DAMAGE.
64 * 64 *
65 * @(#)kern_sig.c 8.14 (Berkeley) 5/14/95 65 * @(#)kern_sig.c 8.14 (Berkeley) 5/14/95
66 */ 66 */
67 67
 68/*
 69 * Signal subsystem.
 70 */
 71
68#include <sys/cdefs.h> 72#include <sys/cdefs.h>
69__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.307 2011/01/17 07:13:31 uebayasi Exp $"); 73__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.308 2011/04/27 00:38:37 rmind Exp $");
70 74
71#include "opt_ptrace.h" 75#include "opt_ptrace.h"
72#include "opt_compat_sunos.h" 76#include "opt_compat_sunos.h"
73#include "opt_compat_netbsd.h" 77#include "opt_compat_netbsd.h"
74#include "opt_compat_netbsd32.h" 78#include "opt_compat_netbsd32.h"
75#include "opt_pax.h" 79#include "opt_pax.h"
76#include "opt_sa.h" 80#include "opt_sa.h"
77 81
78#define SIGPROP /* include signal properties table */ 82#define SIGPROP /* include signal properties table */
79#include <sys/param.h> 83#include <sys/param.h>
80#include <sys/signalvar.h> 84#include <sys/signalvar.h>
81#include <sys/proc.h> 85#include <sys/proc.h>
82#include <sys/systm.h> 86#include <sys/systm.h>
@@ -95,41 +99,48 @@ __KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v @@ -95,41 +99,48 @@ __KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v
95#include <sys/callout.h> 99#include <sys/callout.h>
96#include <sys/atomic.h> 100#include <sys/atomic.h>
97#include <sys/cpu.h> 101#include <sys/cpu.h>
98#include <sys/module.h> 102#include <sys/module.h>
99#include <sys/sdt.h> 103#include <sys/sdt.h>
100 104
101#ifdef PAX_SEGVGUARD 105#ifdef PAX_SEGVGUARD
102#include <sys/pax.h> 106#include <sys/pax.h>
103#endif /* PAX_SEGVGUARD */ 107#endif /* PAX_SEGVGUARD */
104 108
105#include <uvm/uvm_extern.h> 109#include <uvm/uvm_extern.h>
106#include <uvm/uvm_extern.h> 110#include <uvm/uvm_extern.h>
107 111
 112static pool_cache_t sigacts_cache __read_mostly;
 113static pool_cache_t ksiginfo_cache __read_mostly;
 114static callout_t proc_stop_ch __cacheline_aligned;
 115
 116#ifdef KERN_SA
 117static pool_cache_t siginfo_cache;
 118#endif
 119
 120sigset_t contsigmask __cacheline_aligned;
 121static sigset_t stopsigmask __cacheline_aligned;
 122sigset_t sigcantmask __cacheline_aligned;
 123
108static void ksiginfo_exechook(struct proc *, void *); 124static void ksiginfo_exechook(struct proc *, void *);
109static void proc_stop_callout(void *); 125static void proc_stop_callout(void *);
110static int sigchecktrace(void); 126static int sigchecktrace(void);
111static int sigpost(struct lwp *, sig_t, int, int, int); 127static int sigpost(struct lwp *, sig_t, int, int, int);
112static void sigput(sigpend_t *, struct proc *, ksiginfo_t *); 128static void sigput(sigpend_t *, struct proc *, ksiginfo_t *);
113static int sigunwait(struct proc *, const ksiginfo_t *); 129static int sigunwait(struct proc *, const ksiginfo_t *);
114static void sigswitch(bool, int, int); 130static void sigswitch(bool, int, int);
115 131
116sigset_t contsigmask, stopsigmask, sigcantmask; 
117static pool_cache_t sigacts_cache; /* memory pool for sigacts structures */ 
118static void sigacts_poolpage_free(struct pool *, void *); 132static void sigacts_poolpage_free(struct pool *, void *);
119static void *sigacts_poolpage_alloc(struct pool *, int); 133static void *sigacts_poolpage_alloc(struct pool *, int);
120static callout_t proc_stop_ch; 
121static pool_cache_t siginfo_cache; 
122static pool_cache_t ksiginfo_cache; 
123 134
124void (*sendsig_sigcontext_vec)(const struct ksiginfo *, const sigset_t *); 135void (*sendsig_sigcontext_vec)(const struct ksiginfo *, const sigset_t *);
125int (*coredump_vec)(struct lwp *, const char *) = 136int (*coredump_vec)(struct lwp *, const char *) =
126 (int (*)(struct lwp *, const char *))enosys; 137 (int (*)(struct lwp *, const char *))enosys;
127 138
128/* 139/*
129 * DTrace SDT provider definitions 140 * DTrace SDT provider definitions
130 */ 141 */
131SDT_PROBE_DEFINE(proc,,,signal_send,  142SDT_PROBE_DEFINE(proc,,,signal_send,
132 "struct lwp *", NULL, /* target thread */ 143 "struct lwp *", NULL, /* target thread */
133 "struct proc *", NULL, /* target process */ 144 "struct proc *", NULL, /* target process */
134 "int", NULL, /* signal */ 145 "int", NULL, /* signal */
135 NULL, NULL, NULL, NULL); 146 NULL, NULL, NULL, NULL);
@@ -192,30 +203,30 @@ signal_listener_cb(kauth_cred_t cred, ka @@ -192,30 +203,30 @@ signal_listener_cb(kauth_cred_t cred, ka
192 * signal_init: 203 * signal_init:
193 * 204 *
194 * Initialize global signal-related data structures. 205 * Initialize global signal-related data structures.
195 */ 206 */
196void 207void
197signal_init(void) 208signal_init(void)
198{ 209{
199 210
200 sigactspool_allocator.pa_pagesz = (PAGE_SIZE)*2; 211 sigactspool_allocator.pa_pagesz = (PAGE_SIZE)*2;
201 212
202 sigacts_cache = pool_cache_init(sizeof(struct sigacts), 0, 0, 0, 213 sigacts_cache = pool_cache_init(sizeof(struct sigacts), 0, 0, 0,
203 "sigacts", sizeof(struct sigacts) > PAGE_SIZE ? 214 "sigacts", sizeof(struct sigacts) > PAGE_SIZE ?
204 &sigactspool_allocator : NULL, IPL_NONE, NULL, NULL, NULL); 215 &sigactspool_allocator : NULL, IPL_NONE, NULL, NULL, NULL);
205 216#ifdef KERN_SA
206 siginfo_cache = pool_cache_init(sizeof(siginfo_t), 0, 0, 0, 217 siginfo_cache = pool_cache_init(sizeof(siginfo_t), 0, 0, 0,
207 "siginfo", NULL, IPL_NONE, NULL, NULL, NULL); 218 "siginfo", NULL, IPL_NONE, NULL, NULL, NULL);
208 219#endif
209 ksiginfo_cache = pool_cache_init(sizeof(ksiginfo_t), 0, 0, 0, 220 ksiginfo_cache = pool_cache_init(sizeof(ksiginfo_t), 0, 0, 0,
210 "ksiginfo", NULL, IPL_VM, NULL, NULL, NULL); 221 "ksiginfo", NULL, IPL_VM, NULL, NULL, NULL);
211 222
212 exechook_establish(ksiginfo_exechook, NULL); 223 exechook_establish(ksiginfo_exechook, NULL);
213 224
214 callout_init(&proc_stop_ch, CALLOUT_MPSAFE); 225 callout_init(&proc_stop_ch, CALLOUT_MPSAFE);
215 callout_setfunc(&proc_stop_ch, proc_stop_callout, NULL); 226 callout_setfunc(&proc_stop_ch, proc_stop_callout, NULL);
216 227
217 signal_listener = kauth_listen_scope(KAUTH_SCOPE_PROCESS, 228 signal_listener = kauth_listen_scope(KAUTH_SCOPE_PROCESS,
218 signal_listener_cb, NULL); 229 signal_listener_cb, NULL);
219} 230}
220 231
221/* 232/*

cvs diff -r1.78 -r1.79 src/sys/sys/signalvar.h (expand / switch to unified diff)

--- src/sys/sys/signalvar.h 2011/01/14 02:06:34 1.78
+++ src/sys/sys/signalvar.h 2011/04/27 00:38:37 1.79
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: signalvar.h,v 1.78 2011/01/14 02:06:34 rmind Exp $ */ 1/* $NetBSD: signalvar.h,v 1.79 2011/04/27 00:38:37 rmind Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1991, 1993 4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -110,27 +110,27 @@ typedef struct sigstore { @@ -110,27 +110,27 @@ typedef struct sigstore {
110#define SA_STOP 0x0004 /* suspend process */ 110#define SA_STOP 0x0004 /* suspend process */
111#define SA_TTYSTOP 0x0008 /* ditto, from tty */ 111#define SA_TTYSTOP 0x0008 /* ditto, from tty */
112#define SA_IGNORE 0x0010 /* ignore by default */ 112#define SA_IGNORE 0x0010 /* ignore by default */
113#define SA_CONT 0x0020 /* continue if suspended */ 113#define SA_CONT 0x0020 /* continue if suspended */
114#define SA_CANTMASK 0x0040 /* non-maskable, catchable */ 114#define SA_CANTMASK 0x0040 /* non-maskable, catchable */
115#define SA_NORESET 0x0080 /* not reset when caught */ 115#define SA_NORESET 0x0080 /* not reset when caught */
116#define SA_TOLWP 0x0100 /* to LWP that generated, if local */ 116#define SA_TOLWP 0x0100 /* to LWP that generated, if local */
117#define SA_TOALL 0x0200 /* always to all LWPs */ 117#define SA_TOALL 0x0200 /* always to all LWPs */
118 118
119#ifdef _KERNEL 119#ifdef _KERNEL
120 120
121#include <sys/systm.h> /* for copyin_t/copyout_t */ 121#include <sys/systm.h> /* for copyin_t/copyout_t */
122 122
123extern sigset_t contsigmask, stopsigmask, sigcantmask; 123extern sigset_t contsigmask, sigcantmask;
124 124
125struct vnode; 125struct vnode;
126 126
127/* 127/*
128 * Machine-independent functions: 128 * Machine-independent functions:
129 */ 129 */
130int coredump_netbsd(struct lwp *, void *); 130int coredump_netbsd(struct lwp *, void *);
131void execsigs(struct proc *); 131void execsigs(struct proc *);
132int issignal(struct lwp *); 132int issignal(struct lwp *);
133void pgsignal(struct pgrp *, int, int); 133void pgsignal(struct pgrp *, int, int);
134void kpgsignal(struct pgrp *, struct ksiginfo *, void *, int); 134void kpgsignal(struct pgrp *, struct ksiginfo *, void *, int);
135void postsig(int); 135void postsig(int);
136void psignal(struct proc *, int); 136void psignal(struct proc *, int);