https://github.com/python/cpython/commit/812bd8772b3ba8de0a0c2a0bd74a287dafc27df7
commit: 812bd8772b3ba8de0a0c2a0bd74a287dafc27df7
branch: main
author: Maurycy Pawłowski-Wieroński <[email protected]>
committer: pablogsal <[email protected]>
date: 2026-11-16T12:07:10Z
summary:

gh-149584: _remote_debugging: Simplify page cache state (GH-162094)

Use page_cache_count to identify active page cache entries. Remove the 
redundant validity flag, unused next pointer, and unused size macro.

files:
M Modules/_remote_debugging/_remote_debugging.h
M Python/remote_debug.h

diff --git a/Modules/_remote_debugging/_remote_debugging.h 
b/Modules/_remote_debugging/_remote_debugging.h
index 6080dc4e381506..7bbcd8942de61f 100644
--- a/Modules/_remote_debugging/_remote_debugging.h
+++ b/Modules/_remote_debugging/_remote_debugging.h
@@ -121,7 +121,6 @@ typedef struct {
 #define SIZEOF_GEN_OBJ sizeof(PyGenObject)
 #define SIZEOF_INTERP_FRAME sizeof(_PyInterpreterFrame)
 #define SIZEOF_LLIST_NODE sizeof(struct llist_node)
-#define SIZEOF_PAGE_CACHE_ENTRY sizeof(page_cache_entry_t)
 #define SIZEOF_PYOBJECT sizeof(PyObject)
 #define SIZEOF_SET_OBJ sizeof(PySetObject)
 #define SIZEOF_TASK_OBJ 4096
diff --git a/Python/remote_debug.h b/Python/remote_debug.h
index a68e4c6102e5a7..0c55fd3a0354e3 100644
--- a/Python/remote_debug.h
+++ b/Python/remote_debug.h
@@ -155,8 +155,6 @@ get_page_size(void) {
 typedef struct page_cache_entry {
     uintptr_t page_addr; // page-aligned base address
     char *data;
-    int valid;
-    struct page_cache_entry *next;
 } page_cache_entry_t;
 
 #define MAX_PAGES 1024
@@ -211,7 +209,6 @@ _Py_RemoteDebug_FreePageCache(proc_handle_t *handle)
             PyMem_RawFree(handle->pages[i].data);
         }
         handle->pages[i].data = NULL;
-        handle->pages[i].valid = 0;
     }
     handle->page_cache_count = 0;
 }
@@ -219,9 +216,6 @@ _Py_RemoteDebug_FreePageCache(proc_handle_t *handle)
 UNUSED static void
 _Py_RemoteDebug_ClearCache(proc_handle_t *handle)
 {
-    for (int i = 0; i < handle->page_cache_count; i++) {
-        handle->pages[i].valid = 0;
-    }
     handle->page_cache_count = 0;
 }
 
@@ -244,7 +238,6 @@ _Py_RemoteDebug_InitProcHandle(proc_handle_t *handle, pid_t 
pid) {
     handle->page_cache_count = 0;
     for (int i = 0; i < MAX_PAGES; i++) {
         handle->pages[i].data = NULL;
-        handle->pages[i].valid = 0;
     }
 
     handle->pid = pid;
@@ -1539,7 +1532,7 @@ _Py_RemoteDebug_PagedReadRemoteMemory(proc_handle_t 
*handle,
     // between profiler samples, so entries are packed at the front.
     for (int i = 0; i < handle->page_cache_count; i++) {
         page_cache_entry_t *entry = &handle->pages[i];
-        if (entry->valid && entry->page_addr == page_base) {
+        if (entry->page_addr == page_base) {
             memcpy(out, entry->data + offset_in_page, size);
             return 0;
         }
@@ -1566,7 +1559,6 @@ _Py_RemoteDebug_PagedReadRemoteMemory(proc_handle_t 
*handle,
         }
 
         entry->page_addr = page_base;
-        entry->valid = 1;
         handle->page_cache_count++;
         memcpy(out, entry->data + offset_in_page, size);
         return 0;

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to