public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [Slightly off topic] A question about R/B trees.
@ 2008-10-17 21:34 Maxim Levitsky
  2008-10-17 22:15 ` Chris Snook
  0 siblings, 1 reply; 7+ messages in thread
From: Maxim Levitsky @ 2008-10-17 21:34 UTC (permalink / raw)
  To: linux-kernel

Hi,

I am working on my small project, and I need a fast container to hold a large sparse array.
Balanced trees seem to fit perfectly.

I decided to implement a red/black tree, and took a look at kernel rb tree for reference,
and I noticed that tree item has no parent pointer, while it seems that it should have it.

I know now that it has parent pointer, but it is mixed with current and parent node colour.
Thus it is assumed that last two bits of this pointer are zero.

I can see anywhere that this restriction is applied.
I see that structure is "aligned" but that I think only ensures that compiler places it
aligned in static data, does the alignment ensures that it will always place it on aligned address in a structure?
But then, the whole container structure can be misaligned, can't it?

Besides a comment there states that alignment is only for CRIS

How about a check for misalignment?

Best regards,
	Maxim Levitsky

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

end of thread, other threads:[~2008-10-20 15:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-17 21:34 [Slightly off topic] A question about R/B trees Maxim Levitsky
2008-10-17 22:15 ` Chris Snook
2008-10-17 22:47   ` Maxim Levitsky
2008-10-20 14:54     ` Chris Friesen
2008-10-18  7:53   ` Andi Kleen
2008-10-18  8:45     ` Pekka Enberg
2008-10-20 15:57       ` Maxim Levitsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox