@@ -103,7 +103,7 @@ static struct kprobe_blackpoint kprobe_blacklist[] = {
103103#define INSNS_PER_PAGE (PAGE_SIZE/(MAX_INSN_SIZE * sizeof(kprobe_opcode_t)))
104104
105105struct kprobe_insn_page {
106- struct hlist_node hlist ;
106+ struct list_head list ;
107107 kprobe_opcode_t * insns ; /* Page of instruction slots */
108108 char slot_used [INSNS_PER_PAGE ];
109109 int nused ;
@@ -117,7 +117,7 @@ enum kprobe_slot_state {
117117};
118118
119119static DEFINE_MUTEX (kprobe_insn_mutex ); /* Protects kprobe_insn_pages */
120- static struct hlist_head kprobe_insn_pages ;
120+ static LIST_HEAD ( kprobe_insn_pages ) ;
121121static int kprobe_garbage_slots ;
122122static int collect_garbage_slots (void );
123123
@@ -152,10 +152,9 @@ static int __kprobes check_safety(void)
152152static kprobe_opcode_t __kprobes * __get_insn_slot (void )
153153{
154154 struct kprobe_insn_page * kip ;
155- struct hlist_node * pos ;
156155
157156 retry :
158- hlist_for_each_entry (kip , pos , & kprobe_insn_pages , hlist ) {
157+ list_for_each_entry (kip , & kprobe_insn_pages , list ) {
159158 if (kip -> nused < INSNS_PER_PAGE ) {
160159 int i ;
161160 for (i = 0 ; i < INSNS_PER_PAGE ; i ++ ) {
@@ -189,8 +188,8 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(void)
189188 kfree (kip );
190189 return NULL ;
191190 }
192- INIT_HLIST_NODE (& kip -> hlist );
193- hlist_add_head (& kip -> hlist , & kprobe_insn_pages );
191+ INIT_LIST_HEAD (& kip -> list );
192+ list_add (& kip -> list , & kprobe_insn_pages );
194193 memset (kip -> slot_used , SLOT_CLEAN , INSNS_PER_PAGE );
195194 kip -> slot_used [0 ] = SLOT_USED ;
196195 kip -> nused = 1 ;
@@ -219,12 +218,8 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
219218 * so as not to have to set it up again the
220219 * next time somebody inserts a probe.
221220 */
222- hlist_del (& kip -> hlist );
223- if (hlist_empty (& kprobe_insn_pages )) {
224- INIT_HLIST_NODE (& kip -> hlist );
225- hlist_add_head (& kip -> hlist ,
226- & kprobe_insn_pages );
227- } else {
221+ if (!list_is_singular (& kprobe_insn_pages )) {
222+ list_del (& kip -> list );
228223 module_free (NULL , kip -> insns );
229224 kfree (kip );
230225 }
@@ -235,14 +230,13 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
235230
236231static int __kprobes collect_garbage_slots (void )
237232{
238- struct kprobe_insn_page * kip ;
239- struct hlist_node * pos , * next ;
233+ struct kprobe_insn_page * kip , * next ;
240234
241235 /* Ensure no-one is preepmted on the garbages */
242236 if (check_safety ())
243237 return - EAGAIN ;
244238
245- hlist_for_each_entry_safe (kip , pos , next , & kprobe_insn_pages , hlist ) {
239+ list_for_each_entry_safe (kip , next , & kprobe_insn_pages , list ) {
246240 int i ;
247241 if (kip -> ngarbage == 0 )
248242 continue ;
@@ -260,19 +254,17 @@ static int __kprobes collect_garbage_slots(void)
260254void __kprobes free_insn_slot (kprobe_opcode_t * slot , int dirty )
261255{
262256 struct kprobe_insn_page * kip ;
263- struct hlist_node * pos ;
264257
265258 mutex_lock (& kprobe_insn_mutex );
266- hlist_for_each_entry (kip , pos , & kprobe_insn_pages , hlist ) {
259+ list_for_each_entry (kip , & kprobe_insn_pages , list ) {
267260 if (kip -> insns <= slot &&
268261 slot < kip -> insns + (INSNS_PER_PAGE * MAX_INSN_SIZE )) {
269262 int i = (slot - kip -> insns ) / MAX_INSN_SIZE ;
270263 if (dirty ) {
271264 kip -> slot_used [i ] = SLOT_DIRTY ;
272265 kip -> ngarbage ++ ;
273- } else {
266+ } else
274267 collect_one_slot (kip , i );
275- }
276268 break ;
277269 }
278270 }
0 commit comments