From owner-svn-src-all@freebsd.org Mon Aug 3 11:19:49 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3EB789B2806; Mon, 3 Aug 2015 11:19:49 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BE2D51E7F; Mon, 3 Aug 2015 11:19:48 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id t73BJhY6029920 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Mon, 3 Aug 2015 14:19:43 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua t73BJhY6029920 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id t73BJgDn029919; Mon, 3 Aug 2015 14:19:42 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 3 Aug 2015 14:19:42 +0300 From: Konstantin Belousov To: Peter Wemm Cc: svn-src-all@freebsd.org, Steven Hartland , Slawa Olhovchenkov , svn-src-head@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r286223 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs Message-ID: <20150803111942.GB2072@kib.kiev.ua> References: <201508030934.t739YAkT026668@repo.freebsd.org> <20150803094730.GA24698@zxy.spb.ru> <55BF431E.3020601@freebsd.org> <2757800.HIDNx1G49O@overcee.wemm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2757800.HIDNx1G49O@overcee.wemm.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Aug 2015 11:19:49 -0000 On Mon, Aug 03, 2015 at 03:52:21AM -0700, Peter Wemm wrote: > On Monday, August 03, 2015 11:31:58 AM Steven Hartland wrote: > > On 03/08/2015 10:47, Slawa Olhovchenkov wrote: > > > On Mon, Aug 03, 2015 at 09:34:10AM +0000, Steven Hartland wrote: > > >> Author: smh > > >> Date: Mon Aug 3 09:34:09 2015 > > >> New Revision: 286223 > > >> URL: https://svnweb.freebsd.org/changeset/base/286223 > > >> > > >> Log: > > >> Fix KSTACK_PAGES check in ZFS module > > >> > > >> The check introduced by r285946 failed to add the dependency on > > >> opt_kstack_pages.h which meant the default value for the platform > > >> instead > > >> of the customised options KSTACK_PAGES=X was being tested. > > >> > > >> Also wrap in #ifdef __FreeBSD__ for portability. > > > > > > /usr/src/sys/kern/kern_proc.c:int kstack_pages = KSTACK_PAGES; > > > > > > May be check variable kstack_pages is best way? > > > Eliminate dependency on foreign opt_XXXX. > > > > I did think of that but as other modules such as dtrace, which is also > > cddl code, already have this dependency I went with this. > > > > I'm easy though, if there's a concusses that kstack_pages or possibly > > curthread->td_kstack_pages, which would take into account the > > possibility of varied thread stack sizes, then I can make that change. > > > > What do others think? > > The whole thing has missing the point. > > Changing the default for the entire kernel just because the zfs compat > wrappers can't be bothered requesting a suitable value is.. unfortunate.. > particularly when it is in freebsd-provided code, not upstream zfs code. > > Fix the kproc_kthread_add() calls in do_thread_create() and zvol_geom_run() > instead. Enforce a lower bound there for zfs threads instead of making the > entire rest of the kernel use more memory. > > eg: I'm thinking along these lines: > Index: cddl/compat/opensolaris/sys/proc.h > ==================================================== > --- cddl/compat/opensolaris/sys/proc.h (revision 286224) > +++ cddl/compat/opensolaris/sys/proc.h (working copy) > @@ -77,6 +77,8 @@ > ASSERT(state == TS_RUN); > ASSERT(pp == &p0); > > + if (stksize < 16384) > + stksize = 16384; /* Enforce lower bound on ZFS threads */ > error = kproc_kthread_add(proc, arg, &zfsproc, &td, RFSTOPPED, > stksize / PAGE_SIZE, "zfskern", "solthread %p", proc); > if (error == 0) { > > > Beware, some platforms have large pages (eg: ia64 in -stable has 8k, 16k or > 32k pages, from memory). Specifying an arbitrary number of pages in code > that's supposed to be portable isn't a good idea. This would not help. Issue is the size of the thread0 stack, which overflows in this case. I looked at the possibility of making default kernel stack size configurable by a loader tunable, and the issue is that thread0 gets its stack set up too early (locore for i386, hammer_time() for amd64). I.e., it is possible to make the setting effective for all threads after thread0, but not for the one which causes the issue. I do not want to modify ABI between loader and kernel to pass the parameter.