Re: Problem with LIST_HEAD and list_add (was Page Fault Handler Hijacking and Oops)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 05, 2005 at 20:18:44 +0000, Vincenzo Mallozzi wrote:
> Alle 15:58, venerd? 5 agosto 2005, hai scritto:
> > On Fri, Aug 05, 2005 at 11:37:33 +0000, Vincenzo Mallozzi wrote:
> > > On Thu 5 Aug 2005, at 07:02, Jan Hudec wrote:
> > > > Perhaps your code is safe, but I would think you should have the list
> > > > modification itself (list_add_tail) protected by a spin_lock_irqsave.
> > > > That's the only way to exclude against interrupts (you can't lock
> > > > semaphores in interrupt context).
> > > > 
> > > 
> > > But I'm developing a project in a uniprocessor environment, so I think 
> it's 
> > > unnecessary to lock code with spinlock, or, better, it's redundant.
> > 
> > That's not true since the preempt patch went in. Preempt is equivalent
> > to SMP.
> > 
> 
> First, I'm very grateful to you because I'm resolved my struct list_head 
> problems and now I've really understood  the use of these data structures.
> For the problem with Exception Handler and the spinlock, I'm trying to modify 
> my code.
> But I've another question. Taking spinlock/spinlock_irq_save in an Exception 
> Handler in order to scan two list that can be big, doesn't make problem with 
> the mechanism of Interrupt Handling?
> In oder word, I've read in various Linux Kernel book (like Linux Kernel 
> Programming, Linux Kernel Development, etc) that the use of spin lock in 
> Interrupt Handler function must be very limited. Is it true?

Um, yes. And use of spin-lock should ALWAYS be very limited.

I have actually seen a comment somewhere, that there is a list in
kernel, that is only locked for writing, but searched without locks.
I don't currently recall which list it was. However, it does the
operations by hand, because some barrier() statement has to be put in
between.

Anyway, if the structure is likely to be large, you are probably a lot
better off using some kind of hash. In kernel, hashes are usually done
as arrays of list_heads, each of them holding one of the chains. Or
a tree or something (but there is only one tree AFAIK, so it's done by
hand).

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@xxxxxx>

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux