Message ID | cbe2fb30-54b3-663e-4e30-448353723b8f@cybernetics.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Series | mpt3sas and dmapool scalability | expand |
On Tue, Aug 7, 2018 at 7:49 PM, Tony Battersby <tonyb@cybernetics.com> wrote: > The "total number of blocks in pool" debug statistic currently does not > take the boundary value into account, so it diverges from the "total > number of blocks in use" statistic when a boundary is in effect. Add a > calculation for the number of blocks per allocation that takes the > boundary into account, and use it to replace the inaccurate calculation. > + retval->blks_per_alloc = > + (allocation / boundary) * (boundary / size) + > + (allocation % boundary) / size; If boundary is guaranteed to be power of 2, this can avoid cost divisions (though it's a slow path anyway).
On 08/08/2018 05:54 AM, Andy Shevchenko wrote: > On Tue, Aug 7, 2018 at 7:49 PM, Tony Battersby <tonyb@cybernetics.com> wrote: >> The "total number of blocks in pool" debug statistic currently does not >> take the boundary value into account, so it diverges from the "total >> number of blocks in use" statistic when a boundary is in effect. Add a >> calculation for the number of blocks per allocation that takes the >> boundary into account, and use it to replace the inaccurate calculation. > >> + retval->blks_per_alloc = >> + (allocation / boundary) * (boundary / size) + >> + (allocation % boundary) / size; > If boundary is guaranteed to be power of 2, this can avoid cost > divisions (though it's a slow path anyway). > At this point in the function, boundary is guaranteed to be either a power of 2 or equal to allocation, which might not be a power of 2. Not worth special-casing a slow path.
--- linux/mm/dmapool.c.orig 2018-08-06 17:48:54.000000000 -0400 +++ linux/mm/dmapool.c 2018-08-06 17:52:53.000000000 -0400 @@ -61,6 +61,7 @@ struct dma_pool { /* the pool */ struct device *dev; unsigned int allocation; unsigned int boundary; + unsigned int blks_per_alloc; char name[32]; struct list_head pools; }; @@ -105,8 +106,7 @@ show_pools(struct device *dev, struct de /* per-pool info, no real statistics yet */ temp = scnprintf(next, size, "%-16s %4zu %4zu %4u %2u\n", pool->name, blocks, - (size_t) pages * - (pool->allocation / pool->size), + (size_t) pages * pool->blks_per_alloc, pool->size, pages); size -= temp; next += temp; @@ -182,6 +182,9 @@ struct dma_pool *dma_pool_create(const c retval->size = size; retval->boundary = boundary; retval->allocation = allocation; + retval->blks_per_alloc = + (allocation / boundary) * (boundary / size) + + (allocation % boundary) / size; INIT_LIST_HEAD(&retval->pools);
The "total number of blocks in pool" debug statistic currently does not take the boundary value into account, so it diverges from the "total number of blocks in use" statistic when a boundary is in effect. Add a calculation for the number of blocks per allocation that takes the boundary into account, and use it to replace the inaccurate calculation. Signed-off-by: Tony Battersby <tonyb@cybernetics.com> --- This was split off from "dmapool: reduce footprint in struct page" in v2. This depends on patch #1 "dmapool: fix boundary comparison" for the calculated blks_per_alloc value to be correct. The added blks_per_alloc value will also be used in the next patch.