Message ID | 20210209214232.hlVJaEmRu%akpm@linux-foundation.org |
---|---|
State | New |
Headers | show |
Series | [01/14] squashfs: avoid out of bounds writes in decompressors | expand |
On 2/9/21 10:42 PM, Andrew Morton wrote: > From: Vlastimil Babka <vbabka@suse.cz> > Subject: mm, slub: better heuristic for number of cpus when calculating slab order > ... > Link: https://lkml.kernel.org/r/20210208134108.22286-1-vbabka@suse.cz > Fixes: 045ab8c9487b ("mm/slub: let number of online CPUs determine the slub page order") > Signed-off-by: Vlastimil Babka <vbabka@suse.cz> > Reported-by: Vincent Guittot <vincent.guittot@linaro.org> > Reported-by: Mel Gorman <mgorman@techsingularity.net> > Tested-by: Vincent Guittot <vincent.guittot@linaro.org> As Andrew's incoming series might have been not merged yet, I will point to Mel's Tested-by: https://lore.kernel.org/linux-mm/20210210140712.GB3697@techsingularity.net/ Thanks, Mel! > Cc: Catalin Marinas <catalin.marinas@arm.com> > Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> > Cc: Bharata B Rao <bharata@linux.ibm.com> > Cc: Christoph Lameter <cl@linux.com> > Cc: Roman Gushchin <guro@fb.com> > Cc: Johannes Weiner <hannes@cmpxchg.org> > Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> > Cc: Jann Horn <jannh@google.com> > Cc: Michal Hocko <mhocko@kernel.org> > Cc: David Rientjes <rientjes@google.com> > Cc: Shakeel Butt <shakeelb@google.com> > Cc: Will Deacon <will@kernel.org> > Cc: <stable@vger.kernel.org> > Signed-off-by: Andrew Morton <akpm@linux-foundation.org> > --- > > mm/slub.c | 18 ++++++++++++++++-- > 1 file changed, 16 insertions(+), 2 deletions(-) >
On Wed, Feb 10, 2021 at 6:34 AM Vlastimil Babka <vbabka@suse.cz> wrote: > > As Andrew's incoming series might have been not merged yet, I will point to > Mel's Tested-by: Thanks, added. Linus
--- a/mm/slub.c~mm-slub-better-heuristic-for-number-of-cpus-when-calculating-slab-order +++ a/mm/slub.c @@ -3423,6 +3423,7 @@ static inline int calculate_order(unsign unsigned int order; unsigned int min_objects; unsigned int max_objects; + unsigned int nr_cpus; /* * Attempt to find best configuration for a slab. This @@ -3433,8 +3434,21 @@ static inline int calculate_order(unsign * we reduce the minimum objects required in a slab. */ min_objects = slub_min_objects; - if (!min_objects) - min_objects = 4 * (fls(num_online_cpus()) + 1); + if (!min_objects) { + /* + * Some architectures will only update present cpus when + * onlining them, so don't trust the number if it's just 1. But + * we also don't want to use nr_cpu_ids always, as on some other + * architectures, there can be many possible cpus, but never + * onlined. Here we compromise between trying to avoid too high + * order on systems that appear larger than they are, and too + * low order on systems that appear smaller than they are. + */ + nr_cpus = num_present_cpus(); + if (nr_cpus <= 1) + nr_cpus = nr_cpu_ids; + min_objects = 4 * (fls(nr_cpus) + 1); + } max_objects = order_objects(slub_max_order, size); min_objects = min(min_objects, max_objects);