This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efl.
View the commit online.
commit 3098ef9a850d5ff385cc5d2c1b562be31e6b7c73
Author: Carsten Haitzler <[email protected]>
AuthorDate: Thu Feb 5 08:08:35 2026 +0000
page size - let's be runtime adaptable as much as possible
use runtime fetched page size everywhere i can find
---
src/lib/eina/eina_safepointer.c | 12 +++++++-----
src/lib/eo/eo_add_fallback.c | 9 ++++-----
src/lib/eo/eo_ptr_indirection.x | 8 +++++---
src/lib/evas/common/evas_image_main.c | 17 ++++++++---------
4 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/src/lib/eina/eina_safepointer.c b/src/lib/eina/eina_safepointer.c
index dd832b68d6..f6e6e428bf 100644
--- a/src/lib/eina/eina_safepointer.c
+++ b/src/lib/eina/eina_safepointer.c
@@ -28,6 +28,7 @@
#include "eina_trash.h"
#include "eina_log.h"
#include "eina_lock.h"
+#include "eina_cpu.h"
typedef struct _Eina_Memory_Header Eina_Memory_Header;
@@ -69,7 +70,7 @@ static Eina_Memory_Table *empty_table = NULL;
// take that long anyway.
static Eina_Spinlock sl;
-#define MEM_PAGE_SIZE 4096
+#define MEM_PAGE_SIZE eina_cpu_page_size()
#define SAFEPOINTER_MAGIC 0x7DEADC03
static int no_anon = -1;
@@ -84,12 +85,13 @@ _eina_safepointer_calloc(int number, size_t size)
# endif
{
Eina_Memory_Header *header;
- size_t newsize;
+ size_t newsize, pagesize;
+ pagesize = MEM_PAGE_SIZE;
size = size * number + sizeof (Eina_Memory_Header);
- newsize = ((size / MEM_PAGE_SIZE) +
- (size % MEM_PAGE_SIZE ? 1 : 0))
- * MEM_PAGE_SIZE;
+ newsize = ((size / pagesize) +
+ (size % pagesize ? 1 : 0))
+ * pagesize;
if (no_anon == -1)
{
diff --git a/src/lib/eo/eo_add_fallback.c b/src/lib/eo/eo_add_fallback.c
index 32a736a02a..6352f94495 100644
--- a/src/lib/eo/eo_add_fallback.c
+++ b/src/lib/eo/eo_add_fallback.c
@@ -31,8 +31,6 @@ typedef struct _Efl_Object_Call_Stack {
static Eina_TLS _eo_call_stack_key = 0;
-#define MEM_PAGE_SIZE 4096
-
static void *
_eo_call_stack_mem_alloc(size_t size)
{
@@ -53,9 +51,10 @@ _eo_call_stack_mem_alloc(size_t size)
// allocate eo call stack via mmped anon segment if on linux - more
// secure and safe. also gives page aligned memory allowing madvise
void *ptr;
- size_t newsize;
- newsize = MEM_PAGE_SIZE * ((size + MEM_PAGE_SIZE - 1) /
- MEM_PAGE_SIZE);
+ size_t newsize, pagesize;
+
+ pagesize = MEM_PAGE_SIZE;
+ newsize = pagesize * ((size + pagesize - 1) / pagesize);
ptr = mmap(NULL, newsize, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, -1, 0);
if (ptr == MAP_FAILED)
diff --git a/src/lib/eo/eo_ptr_indirection.x b/src/lib/eo/eo_ptr_indirection.x
index 33043b36e6..7b94538d76 100644
--- a/src/lib/eo/eo_ptr_indirection.x
+++ b/src/lib/eo/eo_ptr_indirection.x
@@ -174,9 +174,11 @@ _eo_id_mem_alloc(size_t size)
{
void *ptr;
Mem_Header *hdr;
- size_t newsize;
- newsize = MEM_PAGE_SIZE * ((size + MEM_HEADER_SIZE + MEM_PAGE_SIZE - 1) /
- MEM_PAGE_SIZE);
+ size_t newsize, pagesize;
+
+ pagesize = MEM_PAGE_SIZE;
+ newsize = pagesize * ((size + MEM_HEADER_SIZE + pagesize - 1) /
+ pagesize);
ptr = mmap(NULL, newsize, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, -1, 0);
if (ptr == MAP_FAILED)
diff --git a/src/lib/evas/common/evas_image_main.c b/src/lib/evas/common/evas_image_main.c
index 6d3e09fd84..5f96cadcfb 100644
--- a/src/lib/evas/common/evas_image_main.c
+++ b/src/lib/evas/common/evas_image_main.c
@@ -23,6 +23,8 @@
# include <memcheck.h>
#endif
+#define MEM_PAGE_SIZE ((size_t)eina_cpu_page_size())
+
//#define SURFDBG 1
static Evas_Cache_Image *eci = NULL;
@@ -84,17 +86,14 @@ _evas_common_rgba_image_surface_size(unsigned int w, unsigned int h,
Evas_Colorspace cspace,
/*inout*/int *l, int *r, int *t, int *b)
{
-#ifndef PAGE_SIZE
-# define PAGE_SIZE (4 * 1024)
-#endif
#define HUGE_PAGE_SIZE (2 * 1024 * 1024)
#if defined (HAVE_SYS_MMAN_H) && (!defined (_WIN32))
# define ALIGN_TO_PAGE(Siz) \
- (((Siz / PAGE_SIZE) + (Siz % PAGE_SIZE ? 1 : 0)) * PAGE_SIZE)
+ (((Siz / MEM_PAGE_SIZE) + (Siz % MEM_PAGE_SIZE ? 1 : 0)) * MEM_PAGE_SIZE)
#else
# define ALIGN_TO_PAGE(Siz) Siz
#endif
- int siz, block_size = 8;
+ size_t siz, block_size = 8;
Eina_Bool reset_borders = EINA_TRUE;
#ifdef HAVE_VALGRIND
@@ -150,7 +149,7 @@ _evas_common_rgba_image_surface_size(unsigned int w, unsigned int h,
if (b) *b = 0;
}
- if ((siz < PAGE_SIZE) || evas_image_no_mmap) return siz;
+ if ((siz < MEM_PAGE_SIZE) || evas_image_no_mmap) return siz;
return ALIGN_TO_PAGE(siz);
#undef ALIGN_TO_PAGE
@@ -389,7 +388,7 @@ _evas_common_rgba_image_surface_mmap(Image_Entry *ie,
/*inout*/int *pl, int *pr,
int *pt, int *pb)
{
- int siz;
+ size_t siz;
#if defined (HAVE_SYS_MMAN_H) && (!defined (_WIN32))
void *r = MAP_FAILED;
#endif
@@ -402,7 +401,7 @@ _evas_common_rgba_image_surface_mmap(Image_Entry *ie,
#endif
if (siz < 0) return NULL;
- if ((siz < PAGE_SIZE) || evas_image_no_mmap) return malloc(siz);
+ if ((siz < MEM_PAGE_SIZE) || evas_image_no_mmap) return malloc(siz);
if (siz > ((HUGE_PAGE_SIZE * 75) / 100))
r = mmap(NULL, siz, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_HUGETLB, -1, 0);
@@ -426,7 +425,7 @@ evas_common_rgba_image_surface_munmap(void *data, unsigned int w, unsigned int h
siz = _evas_common_rgba_image_surface_size(w, h, cspace,
NULL, NULL, NULL, NULL);
- if ((siz < PAGE_SIZE) || evas_image_no_mmap) free(data);
+ if ((siz < MEM_PAGE_SIZE) || evas_image_no_mmap) free(data);
else munmap(data, siz);
#else
(void)w;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.