Re: [Patch v3] mm/slub: Remove repeated action in calculate_order()

From: Vlastimil Babka
Date: Mon May 09 2022 - 07:44:30 EST


On 5/9/22 11:42, Wonhyuk Yang wrote:

>> > + if (unlikely(order_objects(slub_min_order, size) > MAX_OBJS_PER_PAGE)) {
>> > + order = get_order(size * MAX_OBJS_PER_PAGE) - 1;
>> > + goto out;
>> > + }
>>
>> Hm interestingly, both before and after your patch, MAX_OBJS_PER_PAGE might
>> be theoretically overflowed not by slub_min_order, but then with higher
>> orders. Seems to be prevented only as a side-effect of fragmentation close
>> to none, thus higher orders not attempted. Would be maybe less confusing to
>> check that explicitly. Even if that's wasteful, but this is not really perf
>> critical code.
>
> Yes, I agree that checking the overflow of object number explicitly is
> better even if
> it is almost impossible. But it checked repeatedly by calling
> calc_slab_order(). It
> seems to me that is unnecessary doesn't it?

Yeah I'm OK with the goal of your patch.