[issue43131] MMAP duplicate reads and writes on ARM64 platform

Paul Swirhun report at bugs.python.org
Thu Feb 4 18:02:15 EST 2021


Paul Swirhun <paulswirhun at gmail.com> added the comment:

A workaround is using memoryview (as reported here: https://stackoverflow.com/questions/53492716/python-writing-to-memory-in-a-single-operation). This results in only 1 transaction on the bus for some reason.

import os, mmap
fd = os.open("/dev/mem", os.O_RDWR | os.O_SYNC)
mapping = mmap.mmap(fd, 4096, flags=mmap.MAP_SHARED, prot=(mmap.PROT_READ | mmap.PROT_WRITE), offset=0x80000000)
mv = memoryview(mapping)
mv_as_int32 = mv.cast('I')  # Note "I" works as intended, "L" still results in duplicate writes; "LL" is not an option
mv_as_int32[0x0 // 4] = 0xDEADBEEF  # this works; results in 1 write issued on the AXI bus

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43131>
_______________________________________


More information about the Python-bugs-list mailing list