DEV Community

pipishuo
pipishuo

Posted on

Linux xarray

xa_index xa_offset xa_shift
static unsigned int get_offset(unsigned long index, struct xa_node *node)
{
return (index >> node->shift) & XA_CHUNK_MASK;
}
static void xas_set_offset(struct xa_state *xas)
{
xas->xa_offset = get_offset(xas->xa_index, xas->xa_node);
}

Through the above code, the xa_index must be xa_shift align.the xa_offset represent the xa_index's high (64-shift) bits data.For example.Assume that the xa_index is 0111 0000,xa_shift is 4.so xa_offset is 0111

what is relationship between xa_node and entry?

Top comments (1)

Collapse
 
pipishuo profile image
pipishuo

The relationship of entry and xa_node
`static inline void *xa_mk_node(const struct xa_node *node)
{
return (void *)((unsigned long)node | 2);
}

/* Private */
static inline struct xa_node *xa_to_node(const void *entry)
{
return (struct xa_node *)((unsigned long)entry - 2);
}`