[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] common: introduce brk_end



commit 82cab821d0b7afb98f0f7ae45ab365980893631e
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Thu Nov 26 09:16:35 2026 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Nov 26 09:16:35 2026 +0100

    common: introduce brk_end
    
    It is anticipated that all architectures meaning to use the BRK allocator
    will have a need for this variable. With this there's then also no need
    for brk_cease() to have a return value; it simply sets the variable.
    
    Since "finished" ends up redundant now, drop it.
    
    Requested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/common/brk.c      | 17 +++++++++--------
 xen/include/xen/brk.h |  5 ++++-
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/xen/common/brk.c b/xen/common/brk.c
index 1f7df86273..4e408a7552 100644
--- a/xen/common/brk.c
+++ b/xen/common/brk.c
@@ -18,15 +18,16 @@ static inline unsigned long brk_adjust_start(unsigned long 
start)
 extern char __brk_start[];
 extern const char __bss_end[];
 
+unsigned long __ro_after_init brk_end;
+
 static unsigned long __initdata allocated;
-static bool __initdata finished;
 
 void *__init brk_alloc(size_t size)
 {
     void *ptr;
     unsigned long alloc = allocated;
 
-    if ( finished )
+    if ( brk_end )
         return NULL;
 
     /* Allocations PAGE_SIZE and up will be page-aligned. */
@@ -52,20 +53,20 @@ void *__init brk_alloc(size_t size)
     return ptr;
 }
 
-unsigned long __init brk_cease(void)
+void __init brk_cease(void)
 {
-    finished = true;
-
     allocated = ROUNDUP(allocated, PAGE_SIZE);
 
-    return (unsigned long)__brk_start + allocated;
+    brk_end = (unsigned long)__brk_start + allocated;
 }
 
 void __init brk_free_unused(void)
 {
-    unsigned long start = brk_cease(), end = (unsigned long)__bss_end;
+    unsigned long start, end = (unsigned long)__bss_end;
+
+    brk_cease();
 
-    start = brk_adjust_start(start);
+    start = brk_adjust_start(brk_end);
 
     if ( start >= end )
         return;
diff --git a/xen/include/xen/brk.h b/xen/include/xen/brk.h
index 91f7ad1961..43eaa72333 100644
--- a/xen/include/xen/brk.h
+++ b/xen/include/xen/brk.h
@@ -24,8 +24,11 @@
     static char __section(".bss..brk.page_aligned") __aligned(PAGE_SIZE) \
         __used var ## _brk_[size]
 
+/* Set by brk_cease(), and becomes the permanent bound of the Xen image. */
+extern unsigned long brk_end;
+
 void *brk_alloc(size_t size);
-unsigned long brk_cease(void);
+void brk_cease(void);
 void brk_free_unused(void);
 
 #endif /* XEN_BRK_H */
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.