[openib-general] mr_table.max_mtt_order

Michael S. Tsirkin mst at mellanox.co.il
Wed Mar 2 02:43:11 PST 2005


Roland, two questions:

1. I'm looking at mthca_init_mr_table.
The following loop:

        for (i = 1, dev->mr_table.max_mtt_order = 0;
             i < dev->limits.num_mtt_segs;
             i <<= 1, ++dev->mr_table.max_mtt_order)
                ; /* nothing */

Seems to exit th first time when 
      (1 << (dev->mr_table.max_mtt_order) ) >= dev->limits.num_mtt_segs

So if dev->limits.num_mtt_segs is not a power of 2, 
  (1 << (dev->mr_table.max_mtt_order) ) > dev->limits.num_mtt_segs

and so max_mtt_order seems to be too large by 1?

Did I misunderstand something, or is there something that forces
dev->limits.num_mtt_segs to be a power of 2?

2. There are some places in mthca where we try to round some value
	up to the power of 2, some done by loops like this one.
	I find them error-prone. Will you accept a patch replacing
	them with an inline function? Using fls, this function will also
	be more efficient than a linear loop.

-- 
MST - Michael S. Tsirkin



More information about the general mailing list