You are not logged in.

#1 2012-11-21 07:43:41

abutanaev
Member
From: Russia, Novosibirsk
Registered: 2011-03-29
Posts: 94

Video card memory as swap or ramdisk

Hi,

I have two video crads, one integrated and another external. I use integrated card and not to waste external card completely, I decided to use its memory as swap and it worked. I did as written in wiki, the main part is in /etc/modprobe.d/phram.conf :

options phram phram=swap,0xd0000000,256Mi

This corresponds with (lspci -vvv):

02:00.0 VGA compatible controller: NVIDIA Corporation G72 [GeForce 7300 SE/7200 GS] (rev a1) (prog-if 00 [VGA controller])
...
        Region 0: Memory at fd000000 (32-bit, non-prefetchable) [size=16M]
        Region 1: Memory at d0000000 (64-bit, prefetchable) [size=256M]
        Region 3: Memory at fc000000 (64-bit, non-prefetchable) [size=16M]
...

But Region 3 is still unused. No big deal (16M), but, anyway how to create another phram area for that? In source code we read:

http://tomoyo.sourceforge.jp/cgi-bin/lx … es/phram.c

  5  * Usage:
  6  *
  7  * one commend line parameter per device, each in the form:
  8  *   phram=<name>,<start>,<len>
  9  * <name> may be up to 63 characters.
 10  * <start> and <len> can be octal, decimal or hexadecimal.  If followed
 11  * by "ki", "Mi" or "Gi", the numbers will be interpreted as kilo, mega or
 12  * gigabytes.
 13  *
 14  * Example:
 15  *      phram=swap,64Mi,128Mi phram=test,900Mi,1Mi

But all I tried leaved me with just one area. For example, when I write in /etc/modprobe.d/phram.conf

options phram phram=swap,0xd0000000,256Mi phram=swap2,0xfc000000,16Mi

Then I left only with 16M, last item. Tried to load module twice, but couldn't do that, there is no -o option in Arch's modprobe and kernel refuses load module twice.

Anton

Offline

#2 2012-11-21 16:29:07

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,467

Re: Video card memory as swap or ramdisk

I don't know why, but you cannot use the non-prefetchable areas.

And as a side note, do you get decent read speed from that areas? video memory is usually fast when you write to it, but very slow (<10MBps) to read by design.


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

#3 2012-11-22 02:35:39

abutanaev
Member
From: Russia, Novosibirsk
Registered: 2011-03-29
Posts: 94

Re: Video card memory as swap or ramdisk

How can I reasonably test the speed? Caching will skew results. The area is small and I cannot use large files to negate caching effect.

Tried hdparm, and here are results:

$ sudo hdparm -tT /dev/mtdblock0

/dev/mtdblock0:
 Timing cached reads:   8544 MB in  2.00 seconds = 4273.97 MB/sec
 Timing buffered disk reads:  18 MB in  3.22 seconds =   5.59 MB/sec
$ sudo hdparm -tT /dev/mtdblock0

/dev/mtdblock0:
 Timing cached reads:   8198 MB in  2.00 seconds = 4100.67 MB/sec
 Timing buffered disk reads:  34 MB in  3.24 seconds =  10.50 MB/sec
$ sudo hdparm -tT /dev/mtdblock0

/dev/mtdblock0:
 Timing cached reads:   8308 MB in  2.00 seconds = 4156.24 MB/sec
 Timing buffered disk reads:  50 MB in  3.23 seconds =  15.47 MB/sec
$ sudo hdparm -tT /dev/mtdblock0

/dev/mtdblock0:
 Timing cached reads:   8238 MB in  2.00 seconds = 4120.81 MB/sec
 Timing buffered disk reads:  66 MB in  3.24 seconds =  20.38 MB/sec
$ sudo hdparm -tT /dev/mtdblock0

/dev/mtdblock0:
 Timing cached reads:   8314 MB in  2.00 seconds = 4158.74 MB/sec
 Timing buffered disk reads:  82 MB in  3.25 seconds =  25.27 MB/sec

Strangely, every next run buffered disk reads speed increased by 5 MB/sec. But anyway you seem to be right: read speed slower than HDD. What a disappointment...

Last edited by abutanaev (2012-11-22 02:43:35)

Offline

#4 2012-11-22 07:17:28

abutanaev
Member
From: Russia, Novosibirsk
Registered: 2011-03-29
Posts: 94

Re: Video card memory as swap or ramdisk

After calling swapoff (unmounting /dev/mtdblock0) sudo hdparm -t /dev/mtdblock0 started showing consistently about 5 MB/sec read speed, which is ridiculously slow for swap or anything else. So the whole idea lost sense because even HDD is much faster than that. It may be that such swap area could be enabled with lowest priority and used when swap on disk is full, but it's only 256M and I think it's not worth it loading kernel modules and supporting all that.

Offline

#5 2012-11-22 08:24:19

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,467

Re: Video card memory as swap or ramdisk

To test you could:

mkfs.ext2 /dev/mtdblock0
mkdir /mnt/gpu
mount /dev/mtdblock0 /mnt/gpu
dd if=/dev/zero of=/mnt/gpu/zero.dd bs=1M count=100 conv=sync #gives write speed
sync ; echo 3 > /proc/sys/vm/drop_caches ; sync #ensure that we read data from the block device and not from fs cache
dd if=/mnt/gpu/zero.dd of=/dev/null bs=1M count=100 conv=sync #gives read speed
umount /mnt/gpu

Anyway, your findings are consistent if not better that my experience
By design, the system needs to write fast to the gpu to upload textures, but there is no need to transfer data TO the cpu in a fast way.

That said, if you really get 25MB/s in read speed, swapping there could make sense as it will swap (write) really fast and reading could benefit from an (hopefully) fast seek time.


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

#6 2012-11-22 09:00:21

abutanaev
Member
From: Russia, Novosibirsk
Registered: 2011-03-29
Posts: 94

Re: Video card memory as swap or ramdisk

I actually got 5MB/s.

Thanks for the idea how to test read speed without caching! But I already dismounted all the stuff, and slow reads confirmed from several sources.

I read somewhere that despite slow reads video ram may have low latency, so for example, making a ramdisk from it and placing there many small files may give some benefits. But it's only 256M, what to use it for?

Last edited by abutanaev (2012-11-22 09:02:15)

Offline

Board footer

Powered by FluxBB