ZFS kstack_pages not in effect?

ralphbsz

Daemon

Reaction score: 1,269
Messages: 2,033

Or perhaps it is?

Just upgraded to 11.3-RELEASE, and I run ZFS on a rather small machine (32-bit Atom with 3GB memory). Just discovered that we now have a kern.kstack_pages tunable, so I can reduce the risk of running out of kernel stack memory (which has never happened to me, but better safe than sorry).

No problem: I edit /boot/loader.conf to add:
Code:
> fgrep kstack_pages /boot/loader.conf
kern.kstack_pages=4
... and reboot. After booting, it seems to have taken effect nicely:
Code:
> sysctl kern.kstack_pages
kern.kstack_pages: 4
The only funny thing is: the kernel is still whining about the tunable being too small; here is a snippet from the output of dmesg:
Code:
ZFS NOTICE: KSTACK_PAGES is 2 which could result in stack overflow panic!
Please consider adding 'options KSTACK_PAGES=4' to your kernel config
ZFS filesystem version: 5
ZFS storage pool version: features support (5000)
...
And in theory, the new value should have taken effect right at the beginning, when the kernel starts, long before ZFS starts up.

So, is the new value in effect or not? At the minimum, I have found a bug, because either it is in effect (in which case the kernel shouldn't complain about it), or it is not in effect (in which case my setting was ignored).
 

PMc

Aspiring Daemon

Reaction score: 180
Messages: 513

At the minimum, I have found a bug, because either it is in effect (in which case the kernel shouldn't complain about it), or it is not in effect (in which case my setting was ignored).
Agreed. From first impression this looks like a sloppy implementation of the new switch. Let's see...

sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
Code:
#ifdef __FreeBSD__
#define ZFS_MIN_KSTACK_PAGES 4
#endif

int
zfs__init(void)
{

#ifdef __FreeBSD__
#if KSTACK_PAGES < ZFS_MIN_KSTACK_PAGES
        printf("ZFS NOTICE: KSTACK_PAGES is %d which could result in stack "
            "overflow panic!\nPlease consider adding "
            "'options KSTACK_PAGES=%d' to your kernel config\n", KSTACK_PAGES,
            ZFS_MIN_KSTACK_PAGES);
#endif
#endif
And in theory, the new value should have taken effect right at the beginning, when the kernel starts, long before ZFS starts up.
Yeah, but this code takes effect already at compile time and ignores sysctl settings.

Could certainly be fixed, but I won't, as I'm building custom kernel anyway.
 
Top