Red Hat Bugzilla – Bug 84131
XFree86 needs a global variable for Pagesize and Pagemask
Last modified: 2007-03-27 00:00:49 EDT
The X server has various places where compile-time pagesize is hard
coded per architecture, which is a broken design because many architectures
can have their native pagesize changed by a kernel recompile. Also, parts
of the code contain a hard coded 4k pagesize for all non explicitly
specified architectures. An example from radeon_dri.c:
# define DRM_PAGE_SIZE 8192
# define DRM_PAGE_SIZE getpagesize()
# define DRM_PAGE_SIZE 4096
The above code is totally bogus, because alpha doesn't necessarily have an
8Kb pagesize. ia64 is somewhat correct, but replaces a constant macro with
a function call, which may have unnecessary overhead in some areas perhaps.
The final else clause though is the ugly one. It assumes any non-alpha,
non-ia64 uses 4Kb pagesize.
I've patched current 126.96.36.1991 sources with a Debian patch to fix the
Radeon and R128 DRI code to runtime detect pagesize, however there are
various places in the X server code which make similar broken pagesize
assumptions in the code. IMHO this would be best handled by 2 global
variables in the X server - one for pagesize, and another for pagemask.
The immediate thought would be adding to common/xf86Globals.c 2 new video
driver visible variables:
long xf86Pagesize, xf86Pagemask;
Then using setconf(_SC_PAGESIZE) to get the native pagesize at runtime.
setconf() is conforming to POSIX and SuSv2, however some platforms might
not have it. In those cases, getpagesize() might be able to be used on
such platforms, however it is labeled as "legacy" on the manpage, and
some platforms might not have it.
I think the safest/sanest approach is to 'assume' that setconf(_SC_PAGESIZE)
will work on all platforms, and simply fix bugs that come up when an
architecture is found that does not support setconf(), either by using
an alternative runtime method, or worst case would be to special case such
OS/arch combinations with hard coded pagesize.
This approach would certainly be no worse than the ugly hard coded pagesize
assumptions scattered here and there in the DRM/DRI and possibly elsewhere.
Note: this is a personal TODO item that I am tracking in bugzilla for
XFree86 development. It is not a Red Hat specific defect, pertains
mostly to DRI/DRM only, and is not something to be tracked as a defect
specific to our final release. It is for future XFree86 development
*** This bug has been marked as a duplicate of 90396 ***
Changed to 'CLOSED' state since 'RESOLVED' has been deprecated.