lkml.org 
[lkml]   [2020]   [Apr]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] kmalloc_index optimization(add kmalloc max size check)
On Fri, 17 Apr 2020, Bernard Zhao wrote:

> kmalloc size should never exceed KMALLOC_MAX_SIZE.
> kmalloc_index realise if size is exceed KMALLOC_MAX_SIZE, e.g 64M,
> kmalloc_index just return index 26, but never check with OS`s max
> kmalloc config KMALLOC_MAX_SIZE. This index`s kmalloc caches maybe
> not create in function create_kmalloc_caches.
> We can throw an warninginfo in kmalloc at the beginning, instead of
> being guaranteed by the buddy alloc behind.

kmalloc_index(0 already bugs if the allocation is more than 64M


...

if (size <= 64 * 1024 * 1024) return 26;
BUG();


You could modify that to check for KMALLOC_MAX_SIZE with some more
conditionals but then kmalloc_index) is written so that the compiler gets
constant folding right.

If you have a patch like that then please verify that all c compilers in
use perform correct constant folding and do not add unnecessary code.


\
 
 \ /
  Last update: 2020-04-17 18:00    [W:0.085 / U:0.312 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site