diff options
author | Allan Stephens <allan.stephens@windriver.com> | 2008-04-16 21:21:16 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-04-16 21:21:16 -0400 |
commit | 4784b7c348779e957c82ba638ba2ada5ad8502d8 (patch) | |
tree | 635e99ff046b7f9519c515ee7e6edc844dced058 /net/tipc | |
parent | dd9e0dda66ba38a2ddd1405ac279894260dc5c36 (diff) |
[TIPC]: Remove inlining of reference table locking routines
This patch converts the TIPC reference table locking routines
into non-inlined routines, since they are mainly called from
non-performance critical areas of TIPC and the added code
footprint incurred through inlining can no longer be justified.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/ref.c | 91 | ||||
-rw-r--r-- | net/tipc/ref.h | 89 |
2 files changed, 91 insertions, 89 deletions
diff --git a/net/tipc/ref.c b/net/tipc/ref.c index c38744c96ed1..d0b240e86ccd 100644 --- a/net/tipc/ref.c +++ b/net/tipc/ref.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * net/tipc/ref.c: TIPC object registry code | 2 | * net/tipc/ref.c: TIPC object registry code |
3 | * | 3 | * |
4 | * Copyright (c) 1991-2006, Ericsson AB | 4 | * Copyright (c) 1991-2006, Ericsson AB |
5 | * Copyright (c) 2004-2005, Wind River Systems | 5 | * Copyright (c) 2004-2007, Wind River Systems |
6 | * All rights reserved. | 6 | * All rights reserved. |
7 | * | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
@@ -46,6 +46,37 @@ | |||
46 | #include "node.h" | 46 | #include "node.h" |
47 | #include "bcast.h" | 47 | #include "bcast.h" |
48 | 48 | ||
49 | /** | ||
50 | * struct reference - TIPC object reference entry | ||
51 | * @object: pointer to object associated with reference entry | ||
52 | * @lock: spinlock controlling access to object | ||
53 | * @data: reference value associated with object (or link to next unused entry) | ||
54 | */ | ||
55 | |||
56 | struct reference { | ||
57 | void *object; | ||
58 | spinlock_t lock; | ||
59 | union { | ||
60 | u32 next_plus_upper; | ||
61 | u32 reference; | ||
62 | } data; | ||
63 | }; | ||
64 | |||
65 | /** | ||
66 | * struct tipc_ref_table - table of TIPC object reference entries | ||
67 | * @entries: pointer to array of reference entries | ||
68 | * @index_mask: bitmask for array index portion of reference values | ||
69 | * @first_free: array index of first unused object reference entry | ||
70 | * @last_free: array index of last unused object reference entry | ||
71 | */ | ||
72 | |||
73 | struct ref_table { | ||
74 | struct reference *entries; | ||
75 | u32 index_mask; | ||
76 | u32 first_free; | ||
77 | u32 last_free; | ||
78 | }; | ||
79 | |||
49 | /* | 80 | /* |
50 | * Object reference table consists of 2**N entries. | 81 | * Object reference table consists of 2**N entries. |
51 | * | 82 | * |
@@ -61,7 +92,7 @@ | |||
61 | * because entry 0's reference field has the form XXXX|1--1. | 92 | * because entry 0's reference field has the form XXXX|1--1. |
62 | */ | 93 | */ |
63 | 94 | ||
64 | struct ref_table tipc_ref_table = { NULL }; | 95 | static struct ref_table tipc_ref_table = { NULL }; |
65 | 96 | ||
66 | static DEFINE_RWLOCK(ref_table_lock); | 97 | static DEFINE_RWLOCK(ref_table_lock); |
67 | 98 | ||
@@ -198,8 +229,8 @@ void tipc_ref_discard(u32 ref) | |||
198 | tipc_ref_table.first_free = index; | 229 | tipc_ref_table.first_free = index; |
199 | else | 230 | else |
200 | /* next_plus_upper is always XXXX|0--0 for last free entry */ | 231 | /* next_plus_upper is always XXXX|0--0 for last free entry */ |
201 | tipc_ref_table.entries[tipc_ref_table.last_free].data.next_plus_upper | 232 | tipc_ref_table.entries[tipc_ref_table.last_free]. |
202 | |= index; | 233 | data.next_plus_upper |= index; |
203 | tipc_ref_table.last_free = index; | 234 | tipc_ref_table.last_free = index; |
204 | 235 | ||
205 | /* increment upper bits of entry to invalidate subsequent references */ | 236 | /* increment upper bits of entry to invalidate subsequent references */ |
@@ -208,3 +239,55 @@ exit: | |||
208 | write_unlock_bh(&ref_table_lock); | 239 | write_unlock_bh(&ref_table_lock); |
209 | } | 240 | } |
210 | 241 | ||
242 | /** | ||
243 | * tipc_ref_lock - lock referenced object and return pointer to it | ||
244 | */ | ||
245 | |||
246 | void *tipc_ref_lock(u32 ref) | ||
247 | { | ||
248 | if (likely(tipc_ref_table.entries)) { | ||
249 | struct reference *r; | ||
250 | |||
251 | r = &tipc_ref_table.entries[ref & tipc_ref_table.index_mask]; | ||
252 | spin_lock_bh(&r->lock); | ||
253 | if (likely(r->data.reference == ref)) | ||
254 | return r->object; | ||
255 | spin_unlock_bh(&r->lock); | ||
256 | } | ||
257 | return NULL; | ||
258 | } | ||
259 | |||
260 | /** | ||
261 | * tipc_ref_unlock - unlock referenced object | ||
262 | */ | ||
263 | |||
264 | void tipc_ref_unlock(u32 ref) | ||
265 | { | ||
266 | if (likely(tipc_ref_table.entries)) { | ||
267 | struct reference *r; | ||
268 | |||
269 | r = &tipc_ref_table.entries[ref & tipc_ref_table.index_mask]; | ||
270 | if (likely(r->data.reference == ref)) | ||
271 | spin_unlock_bh(&r->lock); | ||
272 | else | ||
273 | err("tipc_ref_unlock() invoked using " | ||
274 | "obsolete reference\n"); | ||
275 | } | ||
276 | } | ||
277 | |||
278 | /** | ||
279 | * tipc_ref_deref - return pointer referenced object (without locking it) | ||
280 | */ | ||
281 | |||
282 | void *tipc_ref_deref(u32 ref) | ||
283 | { | ||
284 | if (likely(tipc_ref_table.entries)) { | ||
285 | struct reference *r; | ||
286 | |||
287 | r = &tipc_ref_table.entries[ref & tipc_ref_table.index_mask]; | ||
288 | if (likely(r->data.reference == ref)) | ||
289 | return r->object; | ||
290 | } | ||
291 | return NULL; | ||
292 | } | ||
293 | |||
diff --git a/net/tipc/ref.h b/net/tipc/ref.h index 38f3a7f4a78d..7e3798ea93b9 100644 --- a/net/tipc/ref.h +++ b/net/tipc/ref.h | |||
@@ -2,7 +2,7 @@ | |||
2 | * net/tipc/ref.h: Include file for TIPC object registry code | 2 | * net/tipc/ref.h: Include file for TIPC object registry code |
3 | * | 3 | * |
4 | * Copyright (c) 1991-2006, Ericsson AB | 4 | * Copyright (c) 1991-2006, Ericsson AB |
5 | * Copyright (c) 2005, Wind River Systems | 5 | * Copyright (c) 2005-2006, Wind River Systems |
6 | * All rights reserved. | 6 | * All rights reserved. |
7 | * | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
@@ -37,95 +37,14 @@ | |||
37 | #ifndef _TIPC_REF_H | 37 | #ifndef _TIPC_REF_H |
38 | #define _TIPC_REF_H | 38 | #define _TIPC_REF_H |
39 | 39 | ||
40 | /** | ||
41 | * struct reference - TIPC object reference entry | ||
42 | * @object: pointer to object associated with reference entry | ||
43 | * @lock: spinlock controlling access to object | ||
44 | * @data: reference value associated with object (or link to next unused entry) | ||
45 | */ | ||
46 | |||
47 | struct reference { | ||
48 | void *object; | ||
49 | spinlock_t lock; | ||
50 | union { | ||
51 | u32 next_plus_upper; | ||
52 | u32 reference; | ||
53 | } data; | ||
54 | }; | ||
55 | |||
56 | /** | ||
57 | * struct tipc_ref_table - table of TIPC object reference entries | ||
58 | * @entries: pointer to array of reference entries | ||
59 | * @index_mask: bitmask for array index portion of reference values | ||
60 | * @first_free: array index of first unused object reference entry | ||
61 | * @last_free: array index of last unused object reference entry | ||
62 | */ | ||
63 | |||
64 | struct ref_table { | ||
65 | struct reference *entries; | ||
66 | u32 index_mask; | ||
67 | u32 first_free; | ||
68 | u32 last_free; | ||
69 | }; | ||
70 | |||
71 | extern struct ref_table tipc_ref_table; | ||
72 | |||
73 | int tipc_ref_table_init(u32 requested_size, u32 start); | 40 | int tipc_ref_table_init(u32 requested_size, u32 start); |
74 | void tipc_ref_table_stop(void); | 41 | void tipc_ref_table_stop(void); |
75 | 42 | ||
76 | u32 tipc_ref_acquire(void *object, spinlock_t **lock); | 43 | u32 tipc_ref_acquire(void *object, spinlock_t **lock); |
77 | void tipc_ref_discard(u32 ref); | 44 | void tipc_ref_discard(u32 ref); |
78 | 45 | ||
79 | 46 | void *tipc_ref_lock(u32 ref); | |
80 | /** | 47 | void tipc_ref_unlock(u32 ref); |
81 | * tipc_ref_lock - lock referenced object and return pointer to it | 48 | void *tipc_ref_deref(u32 ref); |
82 | */ | ||
83 | |||
84 | static inline void *tipc_ref_lock(u32 ref) | ||
85 | { | ||
86 | if (likely(tipc_ref_table.entries)) { | ||
87 | struct reference *r = | ||
88 | &tipc_ref_table.entries[ref & tipc_ref_table.index_mask]; | ||
89 | |||
90 | spin_lock_bh(&r->lock); | ||
91 | if (likely(r->data.reference == ref)) | ||
92 | return r->object; | ||
93 | spin_unlock_bh(&r->lock); | ||
94 | } | ||
95 | return NULL; | ||
96 | } | ||
97 | |||
98 | /** | ||
99 | * tipc_ref_unlock - unlock referenced object | ||
100 | */ | ||
101 | |||
102 | static inline void tipc_ref_unlock(u32 ref) | ||
103 | { | ||
104 | if (likely(tipc_ref_table.entries)) { | ||
105 | struct reference *r = | ||
106 | &tipc_ref_table.entries[ref & tipc_ref_table.index_mask]; | ||
107 | |||
108 | if (likely(r->data.reference == ref)) | ||
109 | spin_unlock_bh(&r->lock); | ||
110 | else | ||
111 | err("tipc_ref_unlock() invoked using obsolete reference\n"); | ||
112 | } | ||
113 | } | ||
114 | |||
115 | /** | ||
116 | * tipc_ref_deref - return pointer referenced object (without locking it) | ||
117 | */ | ||
118 | |||
119 | static inline void *tipc_ref_deref(u32 ref) | ||
120 | { | ||
121 | if (likely(tipc_ref_table.entries)) { | ||
122 | struct reference *r = | ||
123 | &tipc_ref_table.entries[ref & tipc_ref_table.index_mask]; | ||
124 | |||
125 | if (likely(r->data.reference == ref)) | ||
126 | return r->object; | ||
127 | } | ||
128 | return NULL; | ||
129 | } | ||
130 | 49 | ||
131 | #endif | 50 | #endif |