From owner-svn-src-head@freebsd.org Mon Aug 3 11:50:15 2015 Return-Path: Delivered-To: svn-src-head@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 576749B2DD3 for ; Mon, 3 Aug 2015 11:50:15 +0000 (UTC) (envelope-from steven@multiplay.co.uk) Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com [209.85.212.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E8D73E70 for ; Mon, 3 Aug 2015 11:50:14 +0000 (UTC) (envelope-from steven@multiplay.co.uk) Received: by wicgj17 with SMTP id gj17so101573483wic.1 for ; Mon, 03 Aug 2015 04:50:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=sRCs9aRhn6wpNk1fXwcnq2Z2k5kclH72G6PBDJr4RqM=; b=Uc+1UAHd1pQBxnH/M/JY1Q4p8BIejiqhsa30ONDfQcRQIxVfqIjS8v8znns18+4Q1i VV3Q5E18rwvrNysxGoEgyHXS1G7sK86OfME63lsaLGfFokkushQiIro+MFwl+3ZeP/y0 3prf5H+fHeN1kBOaNDIIE+d+80hep5/IJalerpz8LtqVbPlmqECHc/pxAGNeO2/8C+bX vVKzsLctZuaqex/YzqAEJ0yLmbUieBU2lwCYM1bXD0Cjz234zD2rebOk52eeZwdqF5ss NDfkHnP9LoIDLW39KL7hXmGulW7ZUPS+e/UQgdh1IcMFsVXL0MKyCEjFWOM/P0n2iggh HB7Q== X-Gm-Message-State: ALoCoQkvpQvbgJ+fcdtgZG9Lz4CwNf8kIJiUs/fTy1iyr/rdMme0zj2ZA8YlsmEH/yVg2SRUuj0U X-Received: by 10.194.112.3 with SMTP id im3mr32955778wjb.54.1438602612681; Mon, 03 Aug 2015 04:50:12 -0700 (PDT) Received: from [10.10.1.68] (82-69-141-170.dsl.in-addr.zen.co.uk. [82.69.141.170]) by smtp.gmail.com with ESMTPSA id u7sm13222417wif.3.2015.08.03.04.50.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Aug 2015 04:50:11 -0700 (PDT) Subject: Re: svn commit: r286223 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs To: Konstantin Belousov , Peter Wemm References: <201508030934.t739YAkT026668@repo.freebsd.org> <20150803094730.GA24698@zxy.spb.ru> <55BF431E.3020601@freebsd.org> <2757800.HIDNx1G49O@overcee.wemm.org> <20150803111942.GB2072@kib.kiev.ua> Cc: svn-src-all@freebsd.org, Slawa Olhovchenkov , svn-src-head@freebsd.org, src-committers@freebsd.org From: Steven Hartland Message-ID: <55BF557B.60009@multiplay.co.uk> Date: Mon, 3 Aug 2015 12:50:19 +0100 User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20150803111942.GB2072@kib.kiev.ua> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Aug 2015 11:50:15 -0000 On 03/08/2015 12:19, Konstantin Belousov wrote: > 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. I've created a review for the current proposed change to look at the kernel var kstack_pages vs the compile time define KSTACK_PAGES. For this change I don't want to get into fixing the thread0 stack size, which can be done later, just to provide a reasonable warning to the user that smaller values could cause a panic. @slw I've added peter and kib as reviewers if you phabricator account then feel free to add yourself. Regards Steve