----- Original Message -----
At 2012-5-22 23:15, Dave Anderson wrote:
> Doing it that way really confuses two different "offset" issues that are
associated
> with this command:
>
> (1) the offset of an rb_root or radix_tree_node within a containing
> data structure, and
> (2) the offset of an rb_node within a containing data structure.
>
> And in both cases, forget trying to implement the "the -o is not
necessary" and
> "the -o is only necessary..." optimizations, because it would be almost
impossible
> to do.
Hello Dave,
I will list all the situations I was concerning.
First red-black tree:
1. rb_node is embedded in a structure. Address is the address of the
structure, and -o shows the offset of rb_node to the structure.
2. same as 1., but the address is the address of rb_node when using -N
in command line.
rb_root was not concering. I will recall the reason. I can get the root
node from rb_root. And then the offspring of the root node. Then I still
need a offset that shows the offset of the offspring node to its related
structure to get the structure's information.
Then radix tree:
3. radix_tree_root's address is specified.
4. radix_tree_node's address is specified.
According to your reply, "-r offset" indicates rb_root and radix_tree_root,
Correct, but only if the rb_root or radix_tree_root are embedded in a
data structure, and the address argument points to the data stucture.
and "-n offset" indicates rb_node and radix_tree_node.
No -- the "-n offset" would only applicable to rb_nodes.
radix_tree_node structures data are standalone entities that are allocated
from the "radix_tree_node" slab cache, correct? When would a radix_tree_node
ever be embedded in a containing data structure?
And if I use "-r offset", then I need another option to
show the offset
of rb_node. And when using "-n offset" together with an address, which
can only be one of rb_node's address and address of the structure
rb_node embedded in, I may need another option to indicate the address's
type.
The address is either that of an rb_root or radix_tree_root, or the
address of the containing data structure, in which case it would
require the "-r offset" option.
So I think "tree -t type -r offset -n offset -m addr..." is a good
choice. "-r offset" indicates the rb_root or radix_tree_root's offset,
and "-n offset" indicates the rb_node or radix_tree_node's offset.
Again, what is a "radix_tree_node offset"?
only using "-n offset" indicates the addr is related to
rb_node or
radix_tree_node, but if "-r offset" is also specified, the addr is
related to rb_root or radix_tree_root. When "-m" is specified, the addr
is the address of the root(when specified "-r offset") or the node. If
"-m" is not specified, the addr is the address of the structure that
containing the root(when specified "-r offset") or the node.
Do you think it's OK?
No, that confuses the hell out me...
I really don't understand the need for the additional "-m" option?
To me it's simple -- but I may be missing something. The address argument
can be either:
(1) A pointer to an rb_root or radix_tree_root.
The "-r offset" is not required.
(2) A pointer to a data structure containing an rb_root or radix_tree_root.
The "-r offset" option is required if the member offset is non-zero.
That being the case, this should work:
red-black tree: tree -t type [-r offset] [-n offset] address
radix tree: tree -t type [-r offset] address
In the case of a red-black tree, it seems that you are also trying to
support the bypassing of the rb_root entirely, and point to an rb_node
directly? That would seem to be an odd-ball case, because the list
would be truncated if you don't point to the topmost rb_node. Is that
what you have in mind? If so, I suppose that you could also have a
additional "-N" option or something like that to signal that the address
argument is a pointer to an rb_node (and not applicable to radix trees).
Dave