Re: [PATCH v4 1/2] mm: Adjust new region size to take management overhead into account

2023-01-29 Thread Zhang Boyang
Hi, Sorry for late reply... On 2023/1/19 23:36, Daniel Kiper wrote: I looked at this patch again and found a few more (minor) issues... On Sat, Jan 14, 2023 at 09:23:22PM +0800, Zhang Boyang wrote: When grub_memalign() encounters out-of-memory, it will try grub_mm_add_region_fn() to request m

[PATCH v5 0/3] mm: Better handling of adding new regions

2023-01-29 Thread Zhang Boyang
Hi, Sorry for late reply. This is the V5 patchset. For changes in V4->V5, please see my reply at: https://lists.gnu.org/archive/html/grub-devel/2023-01/msg00174.html V4 is at: https://lists.gnu.org/archive/html/grub-devel/2023-01/msg00101.html V3 is at: https://lists.gnu.org/archive/html/grub-d

[PATCH v5 1/3] mm: Adjust new region size to take management overhead into account

2023-01-29 Thread Zhang Boyang
When grub_memalign() encounters out-of-memory, it will try grub_mm_add_region_fn() to request more memory from system firmware. However, the size passed to it doesn't take region management overhead into account. Adding a memory area of "size" bytes may result in a heap region of less than "size" b

[PATCH v5 2/3] mm: Preallocate some space when adding new regions

2023-01-29 Thread Zhang Boyang
When grub_memalign() encounters out-of-memory, it will try grub_mm_add_region_fn() to request more memory from system firmware. However, it doesn't preallocate memory space for future allocation requests. In extreme cases, it requires one call to grub_mm_add_region_fn() for each memory allocation r

[PATCH v5 3/3] mm: Avoid complex heap growth math in hot path

2023-01-29 Thread Zhang Boyang
We do a lot of math about heap growth in hot path of grub_memalign(). However, the result is only used if out of memory is encountered, which is seldom. This patch moves these calculations away from hot path. These calculations is now only done if out of memory is encountered. This change can also