# /proc/mtrr all are uncacheable

## jhon987

```
# cat /proc/mtrr

reg00: base=0x0c0000000 ( 3072MB), size= 1024MB, count=1: uncachable

reg01: base=0x0a0000000 ( 2560MB), size=  512MB, count=1: uncachable

reg02: base=0x4000000000 (262144MB), size=262144MB, count=1: uncachable
```

kernel settings:

CONFIG_MTRR=y

CONFIG_MTRR_SANITIZER=y

CONFIG_MTRR_SANITIZER_ENABLE_DEFAULT=1

CONFIG_MTRR_SANITIZER_SPARE_REG_NR_DEFAULT=5

As I understand, making the regs (reg00, ...01, ...) write-combining would help increase performance.

But how can i get them into that mode?

----------

## eccerr0r

What hardware are you working on?

What happens if you don't have the sanitizer turned on, is it worse?

```
$ cat /proc/mtrr 

reg00: base=0x080000000 ( 2048MB), size= 2048MB, count=1: uncachable

$
```

(BTW, that's my VM server, the bare metal machine does not look like this...)

----------

## jhon987

 *eccerr0r wrote:*   

> What hardware are you working on?
> 
> What happens if you don't have the sanitizer turned on, is it worse?
> 
> ```
> ...

 

I haven't tried it with the sanitizer off completely as all guides say it should be on in order to utilize the GPU memory, however initially, I had

CONFIG_MTRR_SANITIZER_ENABLE_DEFAULT=0

CONFIG_MTRR_SANITIZER_SPARE_REG_NR_DEFAULT=1

which according to online guides should have outcome in reg uncacheable, however all guides suggests that turning 

CONFIG_MTRR_SANITIZER_ENABLE_DEFAULT=1

should result in, I think, "write-combining":

 *Quote:*   

> 
> 
> On Intel P6 family processors (Pentium Pro, Pentium II and later)
> 
>   the Memory Type Range Registers (MTRRs) may be used to control
> ...

 

check out:

https://www.kernel.org/doc/Documentation/x86/mtrr.txt

----------

## eccerr0r

BIOS should be setting up the MTRRs with PNP, before getting into Linux.  /proc/mtrr allows post BIOS (i.e. OS) changes, and the sanitizer is only useful if the BIOS does a poor job using them like overlapping regions like my server:

reg00: base=0x000000000 (    0MB), size= 8192MB, count=1: write-back

reg01: base=0x200000000 ( 8192MB), size= 1024MB, count=1: write-back

reg02: base=0x0cc000000 ( 3264MB), size=   64MB, count=1: uncachable

reg03: base=0x0d0000000 ( 3328MB), size=  256MB, count=1: uncachable

reg04: base=0x0e0000000 ( 3584MB), size=  512MB, count=1: uncachable

reg05: base=0x22c000000 ( 8896MB), size=   64MB, count=1: uncachable

reg06: base=0x230000000 ( 8960MB), size=  256MB, count=1: uncachable

As seen here I don't have the sanitizer on, and BIOS has overlapping regions.

You can always manually set them as said in the documentation, though I thought there's a hint in the PCI PNP data to indicate whether a piece of memory is safe to cache/combine.

With /proc/mtrr, individual video drivers can change them at will.  I recall playing with this over a decade ago with dumb video cards (like the S3) that don't run code like modern GPUs, and even these usually ended up with hangs...

----------

## jhon987

Yeah I'm not sure whether it's a good idea for me to set manually (I don't know the implications of simply having all the regs' memory write-back), I'd much rather the OS would handle that for me.

And also,

 *Quote:*   

> MTRR use is replaced on modern x86 hardware with PAT. Direct MTRR use by
> 
> drivers on Linux is now completely phased out

 

So I really don't know if I should mess with that at all.

That said, 

 *Quote:*   

> This can increase performance
> 
> of image write operations 2.5 times or more

 

sounds really attractive and so I'm simply not sure how to deal with this situation...

----------

## eccerr0r

If you're not comfortable overwriting them manually I'd say just don't muck with it and let the individual video drivers change them as needed.  I am especially concerned about GPUs where the GPU actually has processing power, and the potential for possible ordering issues if you change to write combining or writeback caching.

The other thing is that GPUs will handle its own memory, and basically the only thing that gets passed over PCI/AGP are textures, and those are done in big blocks anyway which caching/combining doesn't help.  In the old graphics cards that aren't completely accelerated, the CPU needs to do graphics operations and minimizing the number of transactions over the bus will speed things along.

----------

