From 6c9dee3f715e7d13cb56766048e701b5cd33261e Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Jun 2025 15:50:28 +0200 Subject: [PATCH] base: Fill dataspace with zeros upon free instead of at allocatiing. This avoids the high cost for clearing huge dataspaces at allocation time. --- repos/base/src/core/ram_dataspace_factory.cc | 27 +++++++------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/repos/base/src/core/ram_dataspace_factory.cc b/repos/base/src/core/ram_dataspace_factory.cc index 575c10b193..093ecd33ab 100644 --- a/repos/base/src/core/ram_dataspace_factory.cc +++ b/repos/base/src/core/ram_dataspace_factory.cc @@ -140,7 +140,7 @@ Ram_dataspace_factory::try_alloc(size_t ds_size, Cache cache) * function must also make sure to flush all cache lines related to the * address range used by the dataspace. */ - _clear_ds(ds); + //_clear_ds(ds); Dataspace_capability ds_cap = _ep.manage(&ds); @@ -236,23 +236,6 @@ Ram_dataspace_factory::try_alloc(size_t ds_size, Cache cache, Range_allocator::R Dataspace_component &ds = *ds_ptr; - /* create native shared memory representation of dataspace */ - try { _export_ram_ds(ds); } - catch (Core_virtual_memory_exhausted) { - warning("could not export RAM dataspace of size ", ds.size()); - - /* cleanup unneeded resources */ - destroy(_ds_slab, &ds); - return Alloc_error::DENIED; - } - - /* - * Fill new dataspaces with zeros. For non-cached RAM dataspaces, this - * function must also make sure to flush all cache lines related to the - * address range used by the dataspace. - */ - _clear_ds(ds); - Dataspace_capability ds_cap = _ep.manage(&ds); phys_alloc_guard.keep = true; @@ -270,6 +253,14 @@ void Ram_dataspace_factory::free(Ram_dataspace_capability ds_cap) ds = c; + /* + * Fill old dataspaces with zeros. For non-cached RAM dataspaces, this + * function must also make sure to flush all cache lines related to the + * address range used by the dataspace. + */ + + _export_ram_ds(*ds); + _clear_ds(*ds); size_t const ds_size = ds->size(); /* tell entry point to forget the dataspace */