Using Video memory as RAMDISK!!

38 views
Skip to first unread message

Hradec

unread,
Sep 23, 2010, 5:49:27 PM9/23/10
to atv-bootloader
As I use my appletv as a linux server, I allways runned into the "need
more memory" issue.

As upgrade the memory is a "no-no" so far, I continued to look into
ways to get a faster SWAP. Tried flash drives, harddisks, etc...
everything not as fast as more memory, evidently...

UNTIL I FOUND THIS:

http://en.gentoo-wiki.com/wiki/Using_Graphics_Card_Memory_as_Swap


and it works like a charm!!!!

my lspci -vvv -s 01:00 looks like this:


01:00.0 VGA compatible controller: nVidia Corporation G72M [Quadro NVS
110M/GeForce Go 7300] (rev a1)
Subsystem: Apple Computer Inc. Device 0081
Control: I/O- Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop-
ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort-
<TAbort- <MAbort- >SERR- <PERR- INTx-
Interrupt: pin A routed to IRQ 0
Region 0: Memory at 21000000 (32-bit, non-prefetchable)
[size=16M]
Region 1: Memory at 10000000 (64-bit, prefetchable)
[size=256M]
Region 3: Memory at 20000000 (64-bit, non-prefetchable)
[size=16M]
Expansion ROM at <ignored> [disabled]
Capabilities: [60] Power Management version 2
Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA
PME(D0-,D1-,D2-,D3hot-,D3cold-)
Status: D0 PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [68] Message Signalled Interrupts: Mask- 64bit+
Queue=0/0 Enable-
Address: 0000000000000000 Data: 0000
Capabilities: [78] Express (v1) Endpoint, MSI 00
DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s
<256ns, L1 <4us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE-
FLReset-
DevCtl: Report errors: Correctable- Non-Fatal- Fatal-
Unsupported-
RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop+
MaxPayload 128 bytes, MaxReadReq 512 bytes
DevSta: CorrErr- UncorrErr+ FatalErr- UnsuppReq+
AuxPwr- TransPend-
LnkCap: Port #0, Speed 2.5GT/s, Width x16, ASPM L0s
L1, Latency L0 <256ns, L1 <4us
ClockPM- Suprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 128 bytes Disabled-
Retrain- CommClk+
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x2, TrErr- Train- SlotClk
+ DLActive- BWMgmt- ABWMgmt-
Capabilities: [100] Virtual Channel <?>
Capabilities: [128] Power Budgeting <?>
Kernel modules: nvidiafb


Funny to see 3 memory banks... 16Mb, 256Mb and 16Mb...

Turns out the 256Mb is not actually 256... but only 64 (as everyone
knows, the geforce 7 that cames with the appletv has only 64mb)... But
I was intrigued about the other 2 16mb banks...

Anyhow, I was able to susccesfully map 64MB from bank 1 (256MB) and
also allocate another 16MB from bank 2... totaling extra 80MB that
right now I'm using as SWAP... I tried the 16mb of the first bank, but
endup with some weird behaviour... I think the first 16mb bank is a
bank used my the video board itself... as soon as I formated it all
the other banks stopped working.

As expected, the SWAP is freaking FAST that you can't even notice its
swapping!!!

So, for free, you get extra 80MB on your 256mb appletv with a little
effort...

here is my small little startup script to setup up the whole thing:

/sbin/modprobe phram phram=VRAM,0x20000000,15Mi phram=VRAM,
0x10000000,63Mi
/sbin/modprobe mtdblock
/sbin/mkswap /dev/mtdblock0
/sbin/mkswap /dev/mtdblock1
#/sbin/swapon /dev/mtdblock0 -p 10
/sbin/swapon /dev/mtdblock1 -p 1

I commented out the swap on the 16mb bank to check some crashes I
got... so far, using just the 64mb bank everything is stable...

if you're going to copy/paste my script, don't forget to run:

lspci -vvv -s `lspci | grep VGA | cut -d' ' -f1` | grep Memory


check the start address of each bank... mine is:

Region 0: Memory at 21000000 (32-bit, non-prefetchable)
[size=16M]
Region 1: Memory at 10000000 (64-bit, prefetchable)
[size=256M]
Region 3: Memory at 20000000 (64-bit, non-prefetchable)
[size=16M]

so the line:
sbin/modprobe phram phram=VRAM,0x20000000,15Mi phram=VRAM,
0x10000000,63Mi

uses memory start from Region 3 and 1, respectively... ( although
Region one reports 256, only 64mb are actually available)

Off course, only use this method if you don't care about the video
output of your appletv (like me... I only use the appletv remotely
over SSH), or else you will see some weird stuff happening on your
monitor! =P

Have fun and let me know if someone else try this! =)

PS: I'm now looking into find a cheapo mini-pci VGA board with lots of
memory... this way we can expand the appletv memory even more!! =)

Scott D. Davilla

unread,
Sep 26, 2010, 3:22:52 PM9/26/10
to atv-bootloader

Sweet, that's a nice trick. The first bank is nvidia registers and
vbios, nothing there to see, move along :)

Peter Korsgaard

unread,
Sep 27, 2010, 2:59:31 AM9/27/10
to atv-boo...@googlegroups.com
>>>>> "Scott" == Scott D Davilla <dav...@4pi.com> writes:

Hi,

>> Off course, only use this method if you don't care about the video
>> output of your appletv (like me... I only use the appletv remotely
>> over SSH), or else you will see some weird stuff happening on your
>> monitor! =P
>>
>> Have fun and let me know if someone else try this! =)
>>
>> PS: I'm now looking into find a cheapo mini-pci VGA board with lots of
>> memory... this way we can expand the appletv memory even more!! =)

Scott> Sweet, that's a nice trick. The first bank is nvidia registers and
Scott> vbios, nothing there to see, move along :)

For this kind of setup, compressed swap is imho a good match. It's now
in the kernel (staging/zram):

https://code.google.com/p/compcache/

--
Bye, Peter Korsgaard

Brian Phillips

unread,
Sep 28, 2010, 9:00:13 AM9/28/10
to atv-bootloader
I just tried it on Mythbuntu 8.04, Mythtv 0.21 and it set up exactly
like you said. Is there a way to benchmark it? Currently I can just
look at mythfrontend and hope it's faster/better...

On Sep 27, 12:59 am, Peter Korsgaard <jac...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages