When initializing drmkms, the kernel prints bogus things like:

[     4.193896] Zone  kernel: Available graphics memory: 9007199254113272 KiB
[     4.193896] Zone   dma32: Available graphics memory: 2097152 KiB

The reason is to be found in

sys/external/bsd/drm2/include/linux/mm.h

which fills a pseudo Linux sysinfo struct (limited to members used).

But:
        - Linux sysinfo(2) specifies that totalram is in bytes, while
        totalhigh is in pages. In mm.h, totalram is initialized in
        pages (not bytes) and totalhigh is defined with kernel_map->size,
        that is a virtual address (?), converted in pages;

        - then in:

sys/external/bsd/drm2/dist/drm/ttm/ttm_memory.c:320
        
        mem = si->totalram - si->totalhigh;

        The problem is that this is substracting oranges to apples. On
        my node I have these (added aprint_*):

[     4.224447] si_meminfo: totalram: 1756268; totalhigh: 8479211520;
memunit: 4096

        it's clear that totalram (pages) - totalhigh (changed to pages
        but virtual memory) leads to a negative result then casted
        to unsigned long long yielding the bogus number seen.

Furthermore, when setting zone->max_mem, the memory is divided by
two (>> 1)? But why? Is it to force reserving at most only half of
what is available to graphics? A comment would be welcome explaining the
reason why.

This explains the number found for dma32: since the available memory
exceeds 2^32, 2^32 is taken as the max but, once more, divided by 2.

Do somebody know the Linux guts enough to clarify what totalhigh
refers to? (certainly not a virtual address)

Isn't it dangerous to change the "units" of totalram (bytes in Linux,
but here pages) since (I have not traced the use of the pseudo structure
in the remaining code) if values are used elsewhere in the drivers,
it is likely to wreak havoc the linux code.
-- 
        Thierry Laronde <tlaronde +AT+ kergis +dot+ com>
                     http://www.kergis.com/
                    http://kertex.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C

Reply via email to