Skip to contentSkip to conversation

help linked lists and locks

DISCUSSION Giacomo Strangolino 1 participant 1 message Nov 23, 2005 netfilter

lore
Share & tools
lore
#0 lore raw

Good morning.
In a packet filter which i wrote on my own, i have a linked list of structures which i read periodically by means of list_for_each_safe macro. These structures have a timer, when it expires, the entry is deleted. The timer can on the other way be updated by mod_timer.

The context of execution is that of a software interrupt (i attach my code at netfilter hooks), and some times (after tenths of millions of packets filtered) the system goes into panic.

I think i should put some locks when reading in list_for_each or when deleting an item, or when updating timers.

I thought it was not necessary because of the atomic context.

In fact, should i use read/write_lock? Or spinlocks?

Should i put the locks when reading in list_for_each, when adding an entry with list_add, when deleting with list_del and also when mod_timer?

I verified that when i put those locks, things go better, but do i need them so many in my code?

Thanks in advance

Giacomo.