Print this page
pbchk
cleanup port_free_event_local() semantics
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/sys/port_kernel.h
+++ new/usr/src/uts/common/sys/port_kernel.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
|
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 +/*
28 + * Copyright 2020 Joyent, Inc.
29 + */
30 +
27 31 #ifndef _SYS_PORT_KERNEL_H
28 32 #define _SYS_PORT_KERNEL_H
29 33
30 -#pragma ident "%Z%%M% %I% %E% SMI"
31 -
32 34 #include <sys/vnode.h>
33 35 #include <sys/list.h>
34 36
35 37 #ifdef __cplusplus
36 38 extern "C" {
37 39 #endif
38 40
39 41 /*
40 42 * Note:
41 43 * The contents of this file are private to the implementation of the
42 44 * Solaris system and event ports subsystem and are subject to change
43 45 * at any time without notice.
44 46 */
|
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
45 47
46 48 #ifdef _KERNEL
47 49
48 50 /*
49 51 * The port_kevent_t struct represents the kernel internal port event.
50 52 * Every event is associated to a port (portkev_port).
51 53 */
52 54 typedef struct port_kevent {
53 55 kmutex_t portkev_lock; /* used by PORT_SOURCE_FD source */
54 56 int portkev_source; /* event: source */
55 - int portkev_events; /* event: data */
57 + int portkev_events; /* event: data */
56 58 int portkev_flags; /* internal flags */
57 59 pid_t portkev_pid; /* pid of process using this struct */
58 60 long portkev_object; /* event: object */
59 61 void *portkev_user; /* event: user-defined value */
60 62 int (*portkev_callback)(void *, int *, pid_t, int, void *);
61 63 void *portkev_arg; /* event source callback arg */
62 64 struct port *portkev_port; /* associated port */
63 65 list_node_t portkev_node; /* pointer to neighbor events */
64 66 } port_kevent_t;
65 67
66 68 /* portkev_flags */
67 69 #define PORT_KEV_PRIVATE 0x01 /* subsystem private, don't free */
68 70 #define PORT_KEV_CACHED 0x02 /* port local cached, don't free */
69 71 #define PORT_KEV_SCACHED 0x04 /* source local cached, don't free */
70 72 #define PORT_KEV_VALID 0x08 /* event associated and enabled */
71 73 #define PORT_KEV_DONEQ 0x10 /* event is in done queue */
72 74 #define PORT_KEV_FREE 0x20 /* free event and don't copyout it */
73 75 #define PORT_KEV_NOSHARE 0x40 /* non-shareable across processes */
74 76
75 77 /* flags : port_alloc_event() */
76 78 #define PORT_ALLOC_DEFAULT 0
77 79 #define PORT_ALLOC_PRIVATE PORT_KEV_PRIVATE
78 80 #define PORT_ALLOC_CACHED PORT_KEV_CACHED
79 81 #define PORT_ALLOC_SCACHED PORT_KEV_SCACHED
80 82
81 83 /* flags : callback function */
82 84 #define PORT_CALLBACK_DEFAULT 0 /* free resources, event delivery */
83 85 #define PORT_CALLBACK_CLOSE 1 /* free resources, don't copyout */
84 86 #define PORT_CALLBACK_DISSOCIATE 2 /* dissociate object */
85 87
86 88 #define PORT_DEFAULT_PORTS 0x02000
87 89 #define PORT_MAX_PORTS 0x10000
88 90 #define PORT_DEFAULT_EVENTS 0x10000 /* default # of events per port */
89 91 #define PORT_MAX_EVENTS UINT_MAX/2 /* max. # of events per port */
90 92
91 93 /*
92 94 * port_source_t represents a source associated with a port.
93 95 * The portsrc_close() function is required to notify the source when
94 96 * a port is closed.
95 97 */
96 98 typedef struct port_source {
97 99 int portsrc_source;
98 100 int portsrc_cnt; /* # of associations */
99 101 void (*portsrc_close)(void *, int, pid_t, int);
100 102 void *portsrc_closearg; /* callback arg */
101 103 void *portsrc_data; /* Private data of source */
102 104 struct port_source *portsrc_next;
103 105 struct port_source *portsrc_prev;
104 106 } port_source_t;
105 107
106 108
107 109 /*
108 110 * PORT_SOURCE_FILE cache structure.
109 111 */
110 112 #define PORTFOP_HASHSIZE 256 /* cache space for fop events */
111 113
112 114 /*
113 115 * One cache for each port that uses PORT_SOURCE_FILE.
114 116 */
115 117 typedef struct portfop_cache {
116 118 kmutex_t pfc_lock; /* lock to protect cache */
117 119 kcondvar_t pfc_lclosecv; /* last close cv */
118 120 int pfc_objcount; /* track how many file obj are hashed */
119 121 struct portfop *pfc_hash[PORTFOP_HASHSIZE]; /* hash table */
120 122 } portfop_cache_t;
121 123
122 124 /*
123 125 * PORT_SOURCE_FD cache per port.
124 126 * One cache for each port that uses PORT_SOURCE_FD.
125 127 * pc_lock must be the first element of port_fdcache_t to keep it
126 128 * synchronized with the offset of pc_lock in pollcache_t (see pollrelock()).
127 129 */
128 130 typedef struct port_fdcache {
129 131 kmutex_t pc_lock; /* lock to protect portcache */
130 132 kcondvar_t pc_lclosecv;
131 133 struct portfd **pc_hash; /* points to a hash table of ptrs */
132 134 int pc_hashsize; /* the size of current hash table */
133 135 int pc_fdcount; /* track how many fd's are hashed */
134 136 } port_fdcache_t;
135 137
136 138 /*
137 139 * Structure of port_ksource_tab[] table.
138 140 * The port_ksource_tab[] is required to allow kernel sources to become
139 141 * associated with a port at the time of port creation. This feature is
140 142 * required to avoid performance degradation in sub-systems, specially when
141 143 * they should need to check the association on every event activity.
142 144 */
143 145 typedef struct port_ksource {
144 146 int pks_source;
145 147 void (*pks_close)(void *, int, pid_t, int);
146 148 void *pks_closearg;
147 149 void *pks_portsrc;
148 150 } port_ksource_t;
149 151
150 152 /* event port and source management */
151 153 int port_associate_ksource(int, int, struct port_source **,
152 154 void (*)(void *, int, pid_t, int), void *arg,
153 155 int (*)(port_kevent_t *, int, int, uintptr_t, void *));
154 156 int port_dissociate_ksource(int, int, struct port_source *);
155 157
156 158 /* event management */
157 159 int port_alloc_event(int, int, int, port_kevent_t **);
158 160 int port_pollwkup(struct port *);
159 161 void port_pollwkdone(struct port *);
160 162 void port_send_event(port_kevent_t *);
|
↓ open down ↓ |
95 lines elided |
↑ open up ↑ |
161 163 void port_free_event(port_kevent_t *);
162 164 void port_init_event(port_kevent_t *, uintptr_t, void *,
163 165 int (*)(void *, int *, pid_t, int, void *), void *);
164 166 int port_dup_event(port_kevent_t *, port_kevent_t **, int);
165 167 int port_associate_fd(struct port *, int, uintptr_t, int, void *);
166 168 int port_dissociate_fd(struct port *, uintptr_t);
167 169 int port_associate_fop(struct port *, int, uintptr_t, int, void *);
168 170 int port_dissociate_fop(struct port *, uintptr_t);
169 171
170 172 /* misc functions */
171 -void port_free_event_local(port_kevent_t *, int counter);
173 +void port_free_event_local(port_kevent_t *, boolean_t);
172 174 int port_alloc_event_local(struct port *, int, int, port_kevent_t **);
173 175 void port_close_pfd(struct portfd *);
174 176
175 177 #endif /* _KERNEL */
176 178
177 179 #ifdef __cplusplus
178 180 }
179 181 #endif
180 182
181 183 #endif /* _SYS_PORT_KERNEL_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX