Updated ntdll-ForceBottomUpAlloc patchset.

This commit is contained in:
Paul Gofman 2020-06-24 17:49:51 +03:00
parent 7766c17912
commit f2686a1537
6 changed files with 27 additions and 41 deletions

View File

@ -1,8 +1,7 @@
From c0a24a86c70b3cf2bfe118cff4d9ab03efaa9689 Mon Sep 17 00:00:00 2001
From 980ca40adb1f4d268b42f434c353dc461df19b49 Mon Sep 17 00:00:00 2001
From: Paul Gofman <gofmanp@gmail.com>
Date: Thu, 9 Jan 2020 15:05:09 +0300
Subject: [PATCH 1/6] ntdll: Stop search on mmap() error in
try_map_free_area().
Subject: [PATCH] ntdll: Stop search on mmap() error in try_map_free_area().
The anon mmap errors do not depend on start address hint. Ignoring them
makes the search take incredible time until it fails.
@ -11,7 +10,7 @@ makes the search take incredible time until it fails.
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index b2725e3ae9a..5c2ecfab398 100644
index 04889113c339..088e73b17b34 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -1063,8 +1063,14 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step,

View File

@ -1,8 +1,8 @@
From 68e035e381f5d53980a8bcd7c0798dfd4b4fbe95 Mon Sep 17 00:00:00 2001
From 1aa1c57302aef175849799185f324e461161f9eb Mon Sep 17 00:00:00 2001
From: Paul Gofman <gofmanp@gmail.com>
Date: Thu, 16 Jan 2020 16:09:24 +0300
Subject: [PATCH 2/6] ntdll: Use MAP_FIXED_NOREPLACE flag in
try_map_free_area() if available.
Subject: [PATCH] ntdll: Use MAP_FIXED_NOREPLACE flag in try_map_free_area() if
available.
Avoids actual mapping followed by unmapping back if the memory range is
already mapped.
@ -11,7 +11,7 @@ already mapped.
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 5c2ecfab398..93b5d99dadd 100644
index 088e73b17b34..3907b0db70a9 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -1055,22 +1055,28 @@ static struct wine_rb_entry *find_view_inside_range( void **base_ptr, void **end

View File

@ -1,7 +1,7 @@
From 25be7201abeb509db4b28b81914036bc0c00c2f9 Mon Sep 17 00:00:00 2001
From c9f4923096e5c6dcb1591355e3cdab63167448d4 Mon Sep 17 00:00:00 2001
From: Paul Gofman <gofmanp@gmail.com>
Date: Mon, 25 Nov 2019 12:19:20 +0300
Subject: [PATCH 3/6] ntdll: Force bottom up allocation order for 64 bit arch
Subject: [PATCH] ntdll: Force bottom up allocation order for 64 bit arch
unless top down is requested.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48175
@ -11,7 +11,7 @@ Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46568
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 93b5d99dadd..87b33016b72 100644
index 3907b0db70a9..4b8942b1b53b 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -1775,13 +1775,19 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,

View File

@ -1,7 +1,7 @@
From d74a5c586c00a879fa1182af72c15c154e5dd096 Mon Sep 17 00:00:00 2001
From 0e03dab87634938bf9b6462a3e7dce1def1289c9 Mon Sep 17 00:00:00 2001
From: Paul Gofman <gofmanp@gmail.com>
Date: Tue, 14 Jan 2020 21:39:23 +0300
Subject: [PATCH 4/6] ntdll: Increase step after failed map attempt in
Subject: [PATCH] ntdll: Increase step after failed map attempt in
try_map_free_area().
---
@ -9,7 +9,7 @@ Subject: [PATCH 4/6] ntdll: Increase step after failed map attempt in
1 file changed, 1 insertion(+)
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 87b33016b72..5e79faaf6fc 100644
index 4b8942b1b53b..f4dba39cb160 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -1083,6 +1083,7 @@ static void* try_map_free_area( void *base, void *end, ptrdiff_t step,

View File

@ -1,14 +1,14 @@
From f14407ee5755b6482714a6232a4313bcd1531781 Mon Sep 17 00:00:00 2001
From 2e8d11bd7433a4f5f1fe67cdb2290086e1628fee Mon Sep 17 00:00:00 2001
From: Paul Gofman <pgofman@codeweavers.com>
Date: Tue, 14 Jan 2020 21:42:21 +0300
Subject: [PATCH 5/6] ntdll: Use free area list for virtual memory allocation.
Subject: [PATCH] ntdll: Use free area list for virtual memory allocation.
---
dlls/ntdll/unix/virtual.c | 348 +++++++++++++++++++++++++-------------
1 file changed, 234 insertions(+), 114 deletions(-)
dlls/ntdll/unix/virtual.c | 342 +++++++++++++++++++++++++-------------
1 file changed, 230 insertions(+), 112 deletions(-)
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 5e79faaf6fc..7f194effcaa 100644
index f4dba39cb160..76be52d3d56f 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -195,7 +195,11 @@ static BYTE *pages_vprot;
@ -209,7 +209,7 @@ index 5e79faaf6fc..7f194effcaa 100644
};
/***********************************************************************
@@ -1697,6 +1615,212 @@ static int CDECL alloc_reserved_area_callback( void *start, SIZE_T size, void *a
@@ -1697,6 +1615,210 @@ static int CDECL alloc_reserved_area_callback( void *start, SIZE_T size, void *a
return 0;
}
@ -268,9 +268,7 @@ index 5e79faaf6fc..7f194effcaa 100644
+ else
+ {
+ if (area->map_area_end <= (char *)start)
+ {
+ return 1;
+ }
+
+ if (area->map_area_start >= (char *)end)
+ return 0;
@ -422,7 +420,7 @@ index 5e79faaf6fc..7f194effcaa 100644
/***********************************************************************
* map_fixed_area
*
@@ -1782,11 +1906,15 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
@@ -1782,11 +1904,15 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
alloc.size = size;
alloc.top_down = top_down;
alloc.limit = (void*)(get_zero_bits_64_mask( zero_bits_64 ) & (UINT_PTR)user_space_limit);
@ -441,7 +439,7 @@ index 5e79faaf6fc..7f194effcaa 100644
}
if (mmap_enum_reserved_areas( alloc_reserved_area_callback, &alloc, top_down ))
@@ -1798,15 +1926,6 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
@@ -1798,15 +1924,6 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
goto done;
}
@ -457,7 +455,7 @@ index 5e79faaf6fc..7f194effcaa 100644
view_size = size + granularity_mask + 1;
for (;;)
@@ -2500,6 +2619,7 @@ void virtual_init(void)
@@ -2500,6 +2617,7 @@ void virtual_init(void)
if (preload_reserve_start)
address_space_start = min( address_space_start, preload_reserve_start );
}
@ -465,17 +463,6 @@ index 5e79faaf6fc..7f194effcaa 100644
}
size = ROUND_SIZE( 0, sizeof(TEB) ) + max( MINSIGSTKSZ, 8192 );
@@ -2528,8 +2648,8 @@ void virtual_init(void)
pages_vprot = (void *)((char *)alloc_views.base + 2 * view_block_size);
wine_rb_init( &views_tree, compare_view );
- free_ranges[0].base = (void *)0;
- free_ranges[0].end = (void *)~0;
+ free_ranges[0].base = address_space_start;
+ free_ranges[0].end = address_space_limit;
free_ranges_end = free_ranges + 1;
/* make the DOS area accessible (except the low 64K) to hide bugs in broken apps like Excel 2003 */
--
2.26.2

View File

@ -1,15 +1,15 @@
From ac8fd6b34fa269ce840566055cc1c0b6c023516e Mon Sep 17 00:00:00 2001
From db4188d9c8bcb98326a0c61023cc9d2d4ffd4566 Mon Sep 17 00:00:00 2001
From: Paul Gofman <pgofman@codeweavers.com>
Date: Tue, 2 Jun 2020 21:06:33 +0300
Subject: [PATCH 6/6] ntdll: Permanently exclude natively mapped areas from
free areas list.
Subject: [PATCH] ntdll: Permanently exclude natively mapped areas from free
areas list.
---
dlls/ntdll/unix/virtual.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 7f194effcaa..0e2e20396f3 100644
index 76be52d3d56f..b73eb4257476 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -124,6 +124,9 @@ static const BYTE VIRTUAL_Win32Flags[16] =
@ -36,7 +36,7 @@ index 7f194effcaa..0e2e20396f3 100644
if ((step > 0 && (char *)end - (char *)start < step) ||
(step < 0 && (char *)start - (char *)base < -step) ||
step == 0)
@@ -1910,9 +1920,24 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
@@ -1908,9 +1918,24 @@ static NTSTATUS map_view( struct file_view **view_ret, void *base, size_t size,
if (is_win64 || zero_bits_64)
{