Bug 84131 - XFree86 needs a global variable for Pagesize and Pagemask
Summary: XFree86 needs a global variable for Pagesize and Pagemask
Status: CLOSED DUPLICATE of bug 90396
Alias: None
Product: Red Hat Raw Hide
Classification: Retired
Component: XFree86
Version: 1.0
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Mike A. Harris
QA Contact: David Lawrence
Depends On:
TreeView+ depends on / blocked
Reported: 2003-02-12 16:59 UTC by Mike A. Harris
Modified: 2007-03-27 04:00 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2006-02-21 18:51:45 UTC

Attachments (Terms of Use)

Description Mike A. Harris 2003-02-12 16:59:15 UTC
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:

#if defined(__alpha__)
# define DRM_PAGE_SIZE 8192
#elif defined(__ia64__)
# 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 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.

Comment 1 Mike A. Harris 2003-02-12 17:01:50 UTC
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

Comment 2 Mike A. Harris 2003-05-13 09:22:17 UTC

*** This bug has been marked as a duplicate of 90396 ***

Comment 3 Red Hat Bugzilla 2006-02-21 18:51:45 UTC
Changed to 'CLOSED' state since 'RESOLVED' has been deprecated.

Note You need to log in before you can comment on or make changes to this bug.