# Kmem_map too small panic with big file copies on  ZFS and 8.0



## levinas69 (Jun 14, 2010)

Hi All,

A wee problem with a kernel panic: kmem_map too small.  The panic occurs on a largish network file copies (>8G) from a Windows 7 box to FreeBSD 8.0-RELEASE-p3 running ZFS v13.  Interestingly, no such panic occurred when the system was running FreeBSD 7.2.  

The panic occurs regardless of whether the file copy is done by samba or, say, scp.  ZFS prefetch is turned off by default, and sysctl confirms that it is, in fact, turned off.

Now, the system is running on an Intel Atom 230 with 2G of RAM, so my reading suggests that something has changed in 8.0 and now some tuning is necessary.  However, all my attempts at tuning are not making the problem go away.

Here are my variables from loader.conf, tuned according to readings on a variety of sites, including this one.


```
vfs.zfs.arc_min="128M"
vfs.zfs.arc_max="512M"
vm.kmem_size="768M"
vm.kmem_size_max="1024M"
```

This particular config creates a panic at 533815796 bytes.  As a general rule, the panic always seems to occur at about the threshold of zfs.arc_max.  The problem over successive panics (sorry but I don't have a written record) seems to be that ZFS runs across its defined arc_max threshold.  

I have tried a variety of settings for these variables to no effect. Advice across the web is scattered and contradictory. I have tried a variety of settings for zfs.arc_max and zfs.arc_min to no avail.  Some people (not of this site) have suggested (counter-intuitively) to set kmem_size_max to 1.5x physical memory.  I did try that to no effect.  Others have suggested (intuitively), that kmem_size_max should not be greater than the total system memory is a better option.  But, even then there is a panic.  

Any suggestions?  Thanks for any help you can offer because I am running out of ideas.

Best,
Jay.


----------



## phoenix (Jun 14, 2010)

Guessing this is a 32-bit install?

Try the following (try from a boot loader prompt first, so that the old values are used if it locks up and you have to reboot):

```
vm.kmem_size=2G
vfs.zfs.arc_max=1G
```

vm.kmem_size_max is over 5G by default on 7.3+, so you don't have to worry about that.

You can also try setting kmem_size to 4G, but be sure to keep arc_max at or under 1G.  With only 2G of RAM, you may need to push arc_max down as far as 512M.


----------



## levinas69 (Jun 14, 2010)

Thanks Freddie ... I'll try that and get back to you.

Cheers,
Jay.

PS. Should I think about reinstalling the 64 bit version?


----------



## phoenix (Jun 14, 2010)

If possible, use the 64-bit version of FreeBSD when using ZFS.  A lot of auto-tuning happens on amd64 that can't happen on i386.  Whether or not it helps or is useful with Atom CPUs ... <shrug>


----------



## olav (Jun 14, 2010)

I set vfs.zfs.arc_max to half of vm.kmem_size_max + additional - 32M
This has worked flawless on both my i386 and amd64 system.


----------



## danbi (Jun 16, 2010)

I have been beating my head on this with a new server, (8GB RAM, 64-bit) that randomly crashed every day or so with this error message.

Solved the issue by adding

```
vm.kmem_size="12G"
```
to /boot/loader.conf

Yes, I do have only 8GB of RAM, but various threads suggested that new code works better this way. The most suggested value of vm.kmem_size was 1.5 your amount of RAM. It should be less than 2 times the amount of RAM.

You definitely should install the 64 bit version of FreeBSD.


----------



## olav (Jun 17, 2010)

Interesting, I have to try that.


----------

