All of lore.kernel.org
 help / color / mirror / Atom feed
* locking while reading linked lists.
@ 2005-11-23  8:16 Giacomo
  2005-11-23  8:17 ` Fwd: " Giacomo
  2005-11-23 15:51 ` Stephen Hemminger
  0 siblings, 2 replies; 3+ messages in thread
From: Giacomo @ 2005-11-23  8:16 UTC (permalink / raw)
  To: netfilter devel

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.





--

Giacomo S.
http://www.giacomos.it

- - - - - - - - - - - - - - - - - - - - - -

Running `IPFIRE-wall` on debian GNU/Linux
http://www.giacomos.it/ipfire
http://www.debian.org

mailto:
delleceste@gmail.com
giacomo.strangolino@elettra.trieste.it
jacum@libero.it

- - - - - - - - - - - - - - - - - - - - - -

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Fwd: locking while reading linked lists.
  2005-11-23  8:16 locking while reading linked lists Giacomo
@ 2005-11-23  8:17 ` Giacomo
  2005-11-23 15:51 ` Stephen Hemminger
  1 sibling, 0 replies; 3+ messages in thread
From: Giacomo @ 2005-11-23  8:17 UTC (permalink / raw)
  To: netfilter devel

---------- Forwarded message ----------
From: Giacomo <delleceste@gmail.com>
Date: 23-nov-2005 9.16
Subject: locking while reading linked lists.
To: netfilter devel <netfilter-devel@lists.netfilter.org>


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.





--

Giacomo S.
http://www.giacomos.it

- - - - - - - - - - - - - - - - - - - - - -

Running `IPFIRE-wall` on debian GNU/Linux
http://www.giacomos.it/ipfire
http://www.debian.org

mailto:
delleceste@gmail.com
giacomo.strangolino@elettra.trieste.it
jacum@libero.it

- - - - - - - - - - - - - - - - - - - - - -


--

Giacomo S.
http://www.giacomos.it

- - - - - - - - - - - - - - - - - - - - - -

Running `IPFIRE-wall` on debian GNU/Linux
http://www.giacomos.it/ipfire
http://www.debian.org

mailto:
delleceste@gmail.com
giacomo.strangolino@elettra.trieste.it
jacum@libero.it

- - - - - - - - - - - - - - - - - - - - - -

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: locking while reading linked lists.
  2005-11-23  8:16 locking while reading linked lists Giacomo
  2005-11-23  8:17 ` Fwd: " Giacomo
@ 2005-11-23 15:51 ` Stephen Hemminger
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2005-11-23 15:51 UTC (permalink / raw)
  To: Giacomo; +Cc: netfilter devel

On Wed, 23 Nov 2005 09:16:46 +0100
Giacomo <delleceste@gmail.com> wrote:

> 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?

Learn how to use RCU. There is lots of info in Documentation/RCU/
and there are list macro's that make it painless.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-11-23 15:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-23  8:16 locking while reading linked lists Giacomo
2005-11-23  8:17 ` Fwd: " Giacomo
2005-11-23 15:51 ` Stephen Hemminger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.