Linux/RADV: VICTORY_PORT_CONSTANTS=1 in run-7900.sh costs ~15% (kernel re-checks the in-place region on every submission); other RDNA 2 findings #12

Open
opened 2026-11-28 19:27:06 +00:00 by lyricalfrog3 · 4 comments
lyricalfrog3 commented 2026-11-28 19:27:06 +00:00 (Migrated from github.com)
Contributor

Imported from Slaktarn700/SlaktarnVI. Originally posted by lyricalfrog3 on 2026-11-28T19:27:06Z.


Setup: RX 6700 XT (RDNA 2, 12 GB, ReBAR on), i5-14600KF, Debian, kernel 7.3.4, Mesa 26.1.6 RADV, GE-Proton11-14. SlaktarnVI e5b0dc8, launched through linux/run-7900.sh, Series S profile, 720p with VICTORY_UPSCALER=6, 30 fps cap, shaders preloaded. All numbers are the median of the victory_gpu::host frame line in the prison scene.

1. Renderer port 1 makes every submission expensive on Linux

run-7900.sh forces VICTORY_PORT_CONSTANTS=1, which opens one 174 MB region of title memory in place (OpenExistingHeapFromAddress). On RADV that becomes an amdgpu userptr object. Because vkd3d-proton uses buffer device addresses, RADV attaches every allocation to every submission, and amdgpu re-validates userptr objects through HMM (hmm_range_fault) in each amdgpu_cs_ioctl. That is about 44,000 pages walked per submission, including the VICTORY_CARD_AWAKE job's ~500 submissions a second.

perf over 20 s of gameplay (diag build): the vkd3d queue threads use about one full core, ~95% of it in the kernel. The biggest parts are hmm_range_need_fault + hmm_vma_walk_pmd (~40% of those threads), amdgpu_cs_ioctl itself and clear_highpages.

Run Median frame Draws/frame
diag, port 1 on (as shipped) 121.9 ms 4,710
diag, VICTORY_PORT_CONSTANTS=0 104.2 ms 5,190
release, VICTORY_PORT_CONSTANTS=0 87.3 ms 4,504

Copies stayed about the same with port 1 off (87 → 83 MB/frame), and no visual problems were seen in a short session. Suggestion: default port 1 (and any in-place host import) to off on Linux/RADV, or make the script's value overridable (${VICTORY_PORT_CONSTANTS:-1}). Windows drivers may not pay this per-submission cost.

VICTORY_CARD_AWAKE=0 was slightly worse (wall ~14 fps vs ~16), so the awake job is worth keeping.

2. Release build stability depends on it

With port 1 on, the release build crashed in title code about 40 s in (0xc0000005, read 0x0). The diag build with the awake job off crashed the same way once while loading (read 0x38), then ran fine on the next try. With port 1 off, the release build ran without crashing. It looks like a timing race during loading, not proven.

3. VICTORY_FILL_TITLE=1 is a clear win here

Skipping the wait for small fills of title-written memory: 175 → 129–131 ms in the same scene, no visible glitches. Worth considering as a default.

4. Card buffer cap on 12 GB cards

shadow.rs default_card_limits_mb caps 12 GB cards at 512 MB. With VICTORY_CARD_BUFFERS_MB=1536 the card held 801 MB of copies (591 MB before) and snapshot time went from 11.4 to 0 ms. The 12 GB boundary may be too strict.

5. Wineserver view-tree patch on GE-Proton

linux/wineserver-view-tree.patch applied to GE-Proton11-14 crashed the title (access violation reading 0x5c), because GE adds views without an overlap check, so views sharing a base or overlapping were lost from the tree. Counting such views per process and falling back to the original list scans while any exist made it stable: 381 → 109 ms at 1080p. I can share the modified patch.

Not helpful here

  • VICTORY_THIN_THREADS=14: per-call time 19 → 35 µs, frames slower.
  • VICTORY_INPLACE=2: 520 ms (guards thrash).
  • vkd3d-proton built from master (71cae091): 145 ms vs 117 ms, dropped draws unchanged.

What limits it next (from the profile)

The list translation threads are only ~43% busy each, so they mostly wait. Their own top costs are the BTreeMap range iteration in the shadow lookup (btree::map::...::next over (u64,u64) -> (Arc<Shadow>, u64)), descriptor::view_at and draw::State::bind.

<!-- greyfinch-sync:Slaktarn700/SlaktarnVI:issue:6670166709 --> Imported from [Slaktarn700/SlaktarnVI](https://github.com/Slaktarn700/SlaktarnVI/issues/12). Originally posted by [lyricalfrog3](https://github.com/lyricalfrog3) on 2026-11-28T19:27:06Z. --- **Setup:** RX 6700 XT (RDNA 2, 12 GB, ReBAR on), i5-14600KF, Debian, kernel 7.3.4, Mesa 26.1.6 RADV, GE-Proton11-14. SlaktarnVI `e5b0dc8`, launched through `linux/run-7900.sh`, Series S profile, 720p with `VICTORY_UPSCALER=6`, 30 fps cap, shaders preloaded. All numbers are the median of the `victory_gpu::host` frame line in the prison scene. ### 1. Renderer port 1 makes every submission expensive on Linux `run-7900.sh` forces `VICTORY_PORT_CONSTANTS=1`, which opens one 174 MB region of title memory in place (`OpenExistingHeapFromAddress`). On RADV that becomes an amdgpu userptr object. Because vkd3d-proton uses buffer device addresses, RADV attaches every allocation to every submission, and amdgpu re-validates userptr objects through HMM (`hmm_range_fault`) in each `amdgpu_cs_ioctl`. That is about 44,000 pages walked per submission, including the `VICTORY_CARD_AWAKE` job's ~500 submissions a second. `perf` over 20 s of gameplay (diag build): the vkd3d queue threads use about one full core, ~95% of it in the kernel. The biggest parts are `hmm_range_need_fault` + `hmm_vma_walk_pmd` (~40% of those threads), `amdgpu_cs_ioctl` itself and `clear_highpages`. | Run | Median frame | Draws/frame | |---|---|---| | diag, port 1 on (as shipped) | 121.9 ms | 4,710 | | diag, `VICTORY_PORT_CONSTANTS=0` | 104.2 ms | 5,190 | | release, `VICTORY_PORT_CONSTANTS=0` | 87.3 ms | 4,504 | Copies stayed about the same with port 1 off (87 → 83 MB/frame), and no visual problems were seen in a short session. Suggestion: default port 1 (and any in-place host import) to off on Linux/RADV, or make the script's value overridable (`${VICTORY_PORT_CONSTANTS:-1}`). Windows drivers may not pay this per-submission cost. `VICTORY_CARD_AWAKE=0` was slightly worse (wall ~14 fps vs ~16), so the awake job is worth keeping. ### 2. Release build stability depends on it With port 1 on, the release build crashed in title code about 40 s in (0xc0000005, read 0x0). The diag build with the awake job off crashed the same way once while loading (read 0x38), then ran fine on the next try. With port 1 off, the release build ran without crashing. It looks like a timing race during loading, not proven. ### 3. `VICTORY_FILL_TITLE=1` is a clear win here Skipping the wait for small fills of title-written memory: 175 → 129–131 ms in the same scene, no visible glitches. Worth considering as a default. ### 4. Card buffer cap on 12 GB cards `shadow.rs` `default_card_limits_mb` caps 12 GB cards at 512 MB. With `VICTORY_CARD_BUFFERS_MB=1536` the card held 801 MB of copies (591 MB before) and snapshot time went from 11.4 to 0 ms. The 12 GB boundary may be too strict. ### 5. Wineserver view-tree patch on GE-Proton `linux/wineserver-view-tree.patch` applied to GE-Proton11-14 crashed the title (access violation reading 0x5c), because GE adds views without an overlap check, so views sharing a base or overlapping were lost from the tree. Counting such views per process and falling back to the original list scans while any exist made it stable: 381 → 109 ms at 1080p. I can share the modified patch. ### Not helpful here - `VICTORY_THIN_THREADS=14`: per-call time 19 → 35 µs, frames slower. - `VICTORY_INPLACE=2`: 520 ms (guards thrash). - vkd3d-proton built from master (`71cae091`): 145 ms vs 117 ms, dropped draws unchanged. ### What limits it next (from the profile) The list translation threads are only ~43% busy each, so they mostly wait. Their own top costs are the `BTreeMap` range iteration in the shadow lookup (`btree::map::...::next` over `(u64,u64) -> (Arc<Shadow>, u64)`), `descriptor::view_at` and `draw::State::bind`.
Slaktarn700 commented 2026-11-29 11:17:41 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Slaktarn700/SlaktarnVI. Originally posted by Slaktarn700 on 2026-11-29T11:17:41Z.


Thank you, the profile is very useful. VICTORY_PORT_CONSTANTS is now overridable in my working copy. On my RX 9070 XT, one pair of runs gave 47.9 ms off against 50.4 on, which is too close to call, and one run with it off hung, so I keep it on. VICTORY_FILL_TITLE=1 I have not tried yet. I would like to see the modified wineserver patch if you can share it as text.

<!-- greyfinch-sync:Slaktarn700/SlaktarnVI:comment:7255012755 --> Imported from [Slaktarn700/SlaktarnVI](https://github.com/Slaktarn700/SlaktarnVI/issues/12#issuecomment-7255012755). Originally posted by [Slaktarn700](https://github.com/Slaktarn700) on 2026-11-29T11:17:41Z. --- Thank you, the profile is very useful. `VICTORY_PORT_CONSTANTS` is now overridable in my working copy. On my RX 9070 XT, one pair of runs gave 47.9 ms off against 50.4 on, which is too close to call, and one run with it off hung, so I keep it on. `VICTORY_FILL_TITLE=1` I have not tried yet. I would like to see the modified wineserver patch if you can share it as text.
lyricalfrog3 commented 2026-11-29 12:00:33 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Slaktarn700/SlaktarnVI. Originally posted by lyricalfrog3 on 2026-11-29T12:00:33Z.


Here's the patch, against GE-Proton11-14 with GE's own patches applied. It only touches server/mapping.c, process.c, process.h and file.h.

The one functional change from your version is about views that share a base address or overlap the view below them. In the original, rb_put failing on a duplicate base just leaves the view out of the tree, so find_mapped_view / find_mapped_addr can miss it. I count those views per process (odd_views), and while any exist, lookups and the free-range check use the old linear list, which still has every view. When they're unmapped, lookups go back to the tree. The first 20 times a view goes on the list path, a line is printed to stderr (wineserver: view ... shares a base or overlaps another), if you want to check how often it happens on your side.

Results on RX 6700 XT / 32 GB: 2.6 → 8–9 fps in the same scene, and wineserver went from about 70% of a core to a minor part of the profile.

Thanks for making VICTORY_PORT_CONSTANTS overridable. 47.9 vs 50.4 ms does look like noise, and I'll keep it on too. I'll try VICTORY_FILL_TITLE=1 and report back.

wineserver-view-tree-on-ge.patch
diff --git a/server/file.h b/server/file.h
--- a/server/file.h
+++ b/server/file.h
@@ -190,6 +190,7 @@
 extern const struct pe_image_info *get_view_image_info( const struct memory_view *view, client_ptr_t *base );
 extern int get_view_nt_name( const struct memory_view *view, struct unicode_str *name );
 extern void free_mapped_views( struct process *process );
+extern void init_view_tree( struct process *process );
 extern size_t get_page_size(void);
 extern struct mapping *create_fd_mapping( struct object *root, const struct unicode_str *name, struct fd *fd,
                                           unsigned int attr, const struct security_descriptor *sd );
diff --git a/server/mapping.c b/server/mapping.c
--- a/server/mapping.c
+++ b/server/mapping.c
@@ -46,6 +46,7 @@
 #include "process.h"
 #include "request.h"
 #include "security.h"
+#include "wine/rbtree.h"
 
 /* list of memory ranges, used to store committed info */
 struct ranges
@@ -131,6 +132,10 @@
 struct memory_view
 {
     struct list     entry;           /* entry in per-process view list */
+    struct rb_entry tree_entry;      /* entry in per-process view tree, by base */
+    struct rb_tree *tree;            /* the tree it is in, NULL if none */
+    int             odd;             /* counted in process->odd_views */
+    struct process *odd_process;     /* the process whose count it is in */
     struct fd      *fd;              /* fd for mapped file */
     struct ranges  *committed;       /* list of committed ranges in this mapping */
     struct shared_map *shared;       /* temp file for shared PE mapping */
@@ -431,14 +436,62 @@
     return fd;
 }
 
+/* Views are also kept in a tree by base address (process->view_tree), beside
+ * the list that keeps their order: a process with 100,000 views (a title that
+ * maps its memory a 64 KiB page at a time) made every map and unmap walk the
+ * whole list, 0.3-0.5 ms a call. */
+
+static int compare_view_base( const void *key, const struct rb_entry *entry )
+{
+    client_ptr_t base = *(const client_ptr_t *)key;
+    const struct memory_view *view = RB_ENTRY_VALUE( entry, const struct memory_view, tree_entry );
+
+    if (base < view->base) return -1;
+    if (base > view->base) return 1;
+    return 0;
+}
+
+void init_view_tree( struct process *process )
+{
+    rb_init( &process->view_tree, compare_view_base );
+    process->odd_views = 0;
+}
+
+/* the view with the highest base not above addr, if any */
+static struct memory_view *find_view_at_or_below( struct process *process, client_ptr_t addr )
+{
+    struct rb_entry *entry = process->view_tree.root;
+    struct memory_view *best = NULL;
+
+    while (entry)
+    {
+        struct memory_view *view = RB_ENTRY_VALUE( entry, struct memory_view, tree_entry );
+        if (view->base <= addr)
+        {
+            best = view;
+            entry = entry->right;
+        }
+        else entry = entry->left;
+    }
+    return best;
+}
+
 /* find a memory view from its base address */
 struct memory_view *find_mapped_view( struct process *process, client_ptr_t base )
 {
+    struct rb_entry *entry;
     struct memory_view *view;
 
-    LIST_FOR_EACH_ENTRY( view, &process->views, struct memory_view, entry )
-        if (view->base == base) return view;
-
+    /* views sharing a base or overlapping: the list, as before the tree */
+    if (process->odd_views)
+    {
+        LIST_FOR_EACH_ENTRY( view, &process->views, struct memory_view, entry )
+            if (view->base == base) return view;
+        set_error( STATUS_NOT_MAPPED_VIEW );
+        return NULL;
+    }
+    entry = rb_get( &process->view_tree, &base );
+    if (entry) return RB_ENTRY_VALUE( entry, struct memory_view, tree_entry );
     set_error( STATUS_NOT_MAPPED_VIEW );
     return NULL;
 }
@@ -448,9 +501,15 @@
 {
     struct memory_view *view;
 
-    LIST_FOR_EACH_ENTRY( view, &process->views, struct memory_view, entry )
-        if (addr >= view->base && addr < view->base + view->size) return view;
-
+    if (process->odd_views)
+    {
+        LIST_FOR_EACH_ENTRY( view, &process->views, struct memory_view, entry )
+            if (addr >= view->base && addr < view->base + view->size) return view;
+        set_error( STATUS_NOT_MAPPED_VIEW );
+        return NULL;
+    }
+    view = find_view_at_or_below( process, addr );
+    if (view && addr < view->base + view->size) return view;
     set_error( STATUS_NOT_MAPPED_VIEW );
     return NULL;
 }
@@ -464,13 +523,19 @@
     if (addr & host_page_mask) return 0;
     if (addr + size < addr) return 0;  /* overflow */
 
-    /* check for overlapping view */
-    LIST_FOR_EACH_ENTRY( view, &process->views, struct memory_view, entry )
+    if (process->odd_views)
     {
-        if (view->base + view->size <= addr) continue;
-        if (view->base >= addr + size) continue;
-        return 0;
+        LIST_FOR_EACH_ENTRY( view, &process->views, struct memory_view, entry )
+        {
+            if (view->base + view->size <= addr) continue;
+            if (view->base >= addr + size) continue;
+            return 0;
+        }
+        return 1;
     }
+    /* views do not overlap: only the last one starting below the end can */
+    view = find_view_at_or_below( process, addr + size - 1 );
+    if (view && view->base + view->size > addr) return 0;
     return 1;
 }
 
@@ -487,6 +552,30 @@
     return 1;
 }
 
+static void add_view_to_tree( struct process *process, struct memory_view *view )
+{
+    static unsigned int reported;
+    struct memory_view *below = view->size ? find_view_at_or_below( process, view->base + view->size - 1 ) : NULL;
+
+    /* a view at the same base, or one overlapping it: lookups go back to the list
+     * (which still finds every view) until this view is gone */
+    view->odd = below && below->base + below->size > view->base;
+    if (rb_put( &process->view_tree, &view->base, &view->tree_entry ))
+    {
+        view->tree = NULL;
+        view->odd = 1;
+    }
+    else view->tree = &process->view_tree;
+    view->odd_process = process;
+    if (view->odd)
+    {
+        process->odd_views++;
+        if (reported++ < 20)
+            fprintf( stderr, "wineserver: view %#llx+%#llx shares a base or overlaps another, list lookups (%u)\n",
+                     (unsigned long long)view->base, (unsigned long long)view->size, process->odd_views );
+    }
+}
+
 /* add a view to the process list */
 /* return 1 if this is the main exe view */
 static int add_process_view( struct thread *thread, struct memory_view *view )
@@ -509,10 +598,12 @@
                 process->imagelen = name.len;
             process->image_info = view->image;
             list_add_head( &process->views, &view->entry );
+            add_view_to_tree( process, view );
             return 1;
         }
     }
     list_add_tail( &process->views, &view->entry );
+    add_view_to_tree( process, view );
     return 0;
 }
 
@@ -521,6 +612,8 @@
     if (view->fd) release_object( view->fd );
     if (view->committed) release_object( view->committed );
     if (view->shared) release_object( view->shared );
+    if (view->tree) rb_remove( view->tree, &view->tree_entry );
+    if (view->odd && view->odd_process) view->odd_process->odd_views--;
     list_remove( &view->entry );
     free( view );
 }
diff --git a/server/process.c b/server/process.c
--- a/server/process.c
+++ b/server/process.c
@@ -715,6 +715,7 @@
     list_init( &process->asyncs );
     list_init( &process->classes );
     list_init( &process->views );
+    init_view_tree( process );
 
     process->end_time = 0;
 
diff --git a/server/process.h b/server/process.h
--- a/server/process.h
+++ b/server/process.h
@@ -22,6 +22,7 @@
 #define __WINE_SERVER_PROCESS_H
 
 #include "object.h"
+#include "wine/rbtree.h"
 
 struct atom_table;
 struct handle_table;
@@ -79,6 +80,8 @@
     obj_handle_t         desktop;         /* handle to desktop to use for new threads */
     struct token        *token;           /* security token associated with this process */
     struct list          views;           /* list of memory views */
+    struct rb_tree       view_tree;       /* the same views by base address */
+    unsigned int         odd_views;       /* views sharing a base or overlapping: lookups search the list */
     client_ptr_t         peb;             /* PEB address in client address space */
     struct dir_cache    *dir_cache;       /* map of client-side directory cache */
     unsigned int         trace_data;      /* opaque data used by the process tracing mechanism */
<!-- greyfinch-sync:Slaktarn700/SlaktarnVI:comment:7255500510 --> Imported from [Slaktarn700/SlaktarnVI](https://github.com/Slaktarn700/SlaktarnVI/issues/12#issuecomment-7255500510). Originally posted by [lyricalfrog3](https://github.com/lyricalfrog3) on 2026-11-29T12:00:33Z. --- Here's the patch, against GE-Proton11-14 with GE's own patches applied. It only touches `server/mapping.c`, `process.c`, `process.h` and `file.h`. The one functional change from your version is about views that share a base address or overlap the view below them. In the original, `rb_put` failing on a duplicate base just leaves the view out of the tree, so `find_mapped_view` / `find_mapped_addr` can miss it. I count those views per process (`odd_views`), and while any exist, lookups and the free-range check use the old linear list, which still has every view. When they're unmapped, lookups go back to the tree. The first 20 times a view goes on the list path, a line is printed to stderr (`wineserver: view ... shares a base or overlaps another`), if you want to check how often it happens on your side. Results on RX 6700 XT / 32 GB: **2.6 → 8–9 fps** in the same scene, and wineserver went from about 70% of a core to a minor part of the profile. Thanks for making `VICTORY_PORT_CONSTANTS` overridable. 47.9 vs 50.4 ms does look like noise, and I'll keep it on too. I'll try `VICTORY_FILL_TITLE=1` and report back. <details><summary>wineserver-view-tree-on-ge.patch</summary> ```diff diff --git a/server/file.h b/server/file.h --- a/server/file.h +++ b/server/file.h @@ -190,6 +190,7 @@ extern const struct pe_image_info *get_view_image_info( const struct memory_view *view, client_ptr_t *base ); extern int get_view_nt_name( const struct memory_view *view, struct unicode_str *name ); extern void free_mapped_views( struct process *process ); +extern void init_view_tree( struct process *process ); extern size_t get_page_size(void); extern struct mapping *create_fd_mapping( struct object *root, const struct unicode_str *name, struct fd *fd, unsigned int attr, const struct security_descriptor *sd ); diff --git a/server/mapping.c b/server/mapping.c --- a/server/mapping.c +++ b/server/mapping.c @@ -46,6 +46,7 @@ #include "process.h" #include "request.h" #include "security.h" +#include "wine/rbtree.h" /* list of memory ranges, used to store committed info */ struct ranges @@ -131,6 +132,10 @@ struct memory_view { struct list entry; /* entry in per-process view list */ + struct rb_entry tree_entry; /* entry in per-process view tree, by base */ + struct rb_tree *tree; /* the tree it is in, NULL if none */ + int odd; /* counted in process->odd_views */ + struct process *odd_process; /* the process whose count it is in */ struct fd *fd; /* fd for mapped file */ struct ranges *committed; /* list of committed ranges in this mapping */ struct shared_map *shared; /* temp file for shared PE mapping */ @@ -431,14 +436,62 @@ return fd; } +/* Views are also kept in a tree by base address (process->view_tree), beside + * the list that keeps their order: a process with 100,000 views (a title that + * maps its memory a 64 KiB page at a time) made every map and unmap walk the + * whole list, 0.3-0.5 ms a call. */ + +static int compare_view_base( const void *key, const struct rb_entry *entry ) +{ + client_ptr_t base = *(const client_ptr_t *)key; + const struct memory_view *view = RB_ENTRY_VALUE( entry, const struct memory_view, tree_entry ); + + if (base < view->base) return -1; + if (base > view->base) return 1; + return 0; +} + +void init_view_tree( struct process *process ) +{ + rb_init( &process->view_tree, compare_view_base ); + process->odd_views = 0; +} + +/* the view with the highest base not above addr, if any */ +static struct memory_view *find_view_at_or_below( struct process *process, client_ptr_t addr ) +{ + struct rb_entry *entry = process->view_tree.root; + struct memory_view *best = NULL; + + while (entry) + { + struct memory_view *view = RB_ENTRY_VALUE( entry, struct memory_view, tree_entry ); + if (view->base <= addr) + { + best = view; + entry = entry->right; + } + else entry = entry->left; + } + return best; +} + /* find a memory view from its base address */ struct memory_view *find_mapped_view( struct process *process, client_ptr_t base ) { + struct rb_entry *entry; struct memory_view *view; - LIST_FOR_EACH_ENTRY( view, &process->views, struct memory_view, entry ) - if (view->base == base) return view; - + /* views sharing a base or overlapping: the list, as before the tree */ + if (process->odd_views) + { + LIST_FOR_EACH_ENTRY( view, &process->views, struct memory_view, entry ) + if (view->base == base) return view; + set_error( STATUS_NOT_MAPPED_VIEW ); + return NULL; + } + entry = rb_get( &process->view_tree, &base ); + if (entry) return RB_ENTRY_VALUE( entry, struct memory_view, tree_entry ); set_error( STATUS_NOT_MAPPED_VIEW ); return NULL; } @@ -448,9 +501,15 @@ { struct memory_view *view; - LIST_FOR_EACH_ENTRY( view, &process->views, struct memory_view, entry ) - if (addr >= view->base && addr < view->base + view->size) return view; - + if (process->odd_views) + { + LIST_FOR_EACH_ENTRY( view, &process->views, struct memory_view, entry ) + if (addr >= view->base && addr < view->base + view->size) return view; + set_error( STATUS_NOT_MAPPED_VIEW ); + return NULL; + } + view = find_view_at_or_below( process, addr ); + if (view && addr < view->base + view->size) return view; set_error( STATUS_NOT_MAPPED_VIEW ); return NULL; } @@ -464,13 +523,19 @@ if (addr & host_page_mask) return 0; if (addr + size < addr) return 0; /* overflow */ - /* check for overlapping view */ - LIST_FOR_EACH_ENTRY( view, &process->views, struct memory_view, entry ) + if (process->odd_views) { - if (view->base + view->size <= addr) continue; - if (view->base >= addr + size) continue; - return 0; + LIST_FOR_EACH_ENTRY( view, &process->views, struct memory_view, entry ) + { + if (view->base + view->size <= addr) continue; + if (view->base >= addr + size) continue; + return 0; + } + return 1; } + /* views do not overlap: only the last one starting below the end can */ + view = find_view_at_or_below( process, addr + size - 1 ); + if (view && view->base + view->size > addr) return 0; return 1; } @@ -487,6 +552,30 @@ return 1; } +static void add_view_to_tree( struct process *process, struct memory_view *view ) +{ + static unsigned int reported; + struct memory_view *below = view->size ? find_view_at_or_below( process, view->base + view->size - 1 ) : NULL; + + /* a view at the same base, or one overlapping it: lookups go back to the list + * (which still finds every view) until this view is gone */ + view->odd = below && below->base + below->size > view->base; + if (rb_put( &process->view_tree, &view->base, &view->tree_entry )) + { + view->tree = NULL; + view->odd = 1; + } + else view->tree = &process->view_tree; + view->odd_process = process; + if (view->odd) + { + process->odd_views++; + if (reported++ < 20) + fprintf( stderr, "wineserver: view %#llx+%#llx shares a base or overlaps another, list lookups (%u)\n", + (unsigned long long)view->base, (unsigned long long)view->size, process->odd_views ); + } +} + /* add a view to the process list */ /* return 1 if this is the main exe view */ static int add_process_view( struct thread *thread, struct memory_view *view ) @@ -509,10 +598,12 @@ process->imagelen = name.len; process->image_info = view->image; list_add_head( &process->views, &view->entry ); + add_view_to_tree( process, view ); return 1; } } list_add_tail( &process->views, &view->entry ); + add_view_to_tree( process, view ); return 0; } @@ -521,6 +612,8 @@ if (view->fd) release_object( view->fd ); if (view->committed) release_object( view->committed ); if (view->shared) release_object( view->shared ); + if (view->tree) rb_remove( view->tree, &view->tree_entry ); + if (view->odd && view->odd_process) view->odd_process->odd_views--; list_remove( &view->entry ); free( view ); } diff --git a/server/process.c b/server/process.c --- a/server/process.c +++ b/server/process.c @@ -715,6 +715,7 @@ list_init( &process->asyncs ); list_init( &process->classes ); list_init( &process->views ); + init_view_tree( process ); process->end_time = 0; diff --git a/server/process.h b/server/process.h --- a/server/process.h +++ b/server/process.h @@ -22,6 +22,7 @@ #define __WINE_SERVER_PROCESS_H #include "object.h" +#include "wine/rbtree.h" struct atom_table; struct handle_table; @@ -79,6 +80,8 @@ obj_handle_t desktop; /* handle to desktop to use for new threads */ struct token *token; /* security token associated with this process */ struct list views; /* list of memory views */ + struct rb_tree view_tree; /* the same views by base address */ + unsigned int odd_views; /* views sharing a base or overlapping: lookups search the list */ client_ptr_t peb; /* PEB address in client address space */ struct dir_cache *dir_cache; /* map of client-side directory cache */ unsigned int trace_data; /* opaque data used by the process tracing mechanism */ ``` </details>
Slaktarn700 commented 2026-11-29 22:01:04 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Slaktarn700/SlaktarnVI. Originally posted by Slaktarn700 on 2026-11-29T22:01:04Z.


Thank you, I read the whole patch and found nothing unsafe. One case: wide view A, then B inside it, then C inside A above B: C is not counted, so after B is unmapped the tree can miss A. Deciding overlap by the list while odd_views is above 0 would fix that. In the Proton Experimental I use, the callers check for overlap first, so I do not expect it there. Do you see the stderr line in your runs, and do you know which call in GE adds the overlapping view?

<!-- greyfinch-sync:Slaktarn700/SlaktarnVI:comment:7263335065 --> Imported from [Slaktarn700/SlaktarnVI](https://github.com/Slaktarn700/SlaktarnVI/issues/12#issuecomment-7263335065). Originally posted by [Slaktarn700](https://github.com/Slaktarn700) on 2026-11-29T22:01:04Z. --- Thank you, I read the whole patch and found nothing unsafe. One case: wide view A, then B inside it, then C inside A above B: C is not counted, so after B is unmapped the tree can miss A. Deciding overlap by the list while odd_views is above 0 would fix that. In the Proton Experimental I use, the callers check for overlap first, so I do not expect it there. Do you see the stderr line in your runs, and do you know which call in GE adds the overlapping view?
Slaktarn700 commented 2026-12-01 02:18:07 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Slaktarn700/SlaktarnVI. Originally posted by Slaktarn700 on 2026-12-01T02:18:07Z.


You were right about the cost: in 12 alternating starts each wait for card memory took 0.3 to 2.8 ms with port 1 on and 0.11 to 0.15 ms with it off. In play on this PC it is still the other way round (21 to 22 fps on, 18 off), so it stays on by default and overridable. The zero-page reads are fixed by the ntdll patch the new Set up Proton builds.

<!-- greyfinch-sync:Slaktarn700/SlaktarnVI:comment:7298460638 --> Imported from [Slaktarn700/SlaktarnVI](https://github.com/Slaktarn700/SlaktarnVI/issues/12#issuecomment-7298460638). Originally posted by [Slaktarn700](https://github.com/Slaktarn700) on 2026-12-01T02:18:07Z. --- You were right about the cost: in 12 alternating starts each wait for card memory took 0.3 to 2.8 ms with port 1 on and 0.11 to 0.15 ms with it off. In play on this PC it is still the other way round (21 to 22 fps on, 18 off), so it stays on by default and overridable. The zero-page reads are fixed by the ntdll patch the new **Set up Proton** builds.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Slaktarn700/SlaktarnVI#12
No description provided.