From owner-svn-src-projects@FreeBSD.ORG Sun Aug 25 17:26:06 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id A636EC03; Sun, 25 Aug 2013 17:26:06 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 927B92867; Sun, 25 Aug 2013 17:26:06 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7PHQ67V030997; Sun, 25 Aug 2013 17:26:06 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7PHQ6nZ030990; Sun, 25 Aug 2013 17:26:06 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201308251726.r7PHQ6nZ030990@svn.freebsd.org> From: Alexander Motin Date: Sun, 25 Aug 2013 17:26:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r254881 - projects/camlock/sys/geom X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Aug 2013 17:26:06 -0000 Author: mav Date: Sun Aug 25 17:26:05 2013 New Revision: 254881 URL: http://svnweb.freebsd.org/changeset/base/254881 Log: Add more conditions when GEOM direct dispatch should not be used: - on down path when BIO is unmapped and we can't sleep (mapping may sleep); - when we are already in one of GEOM threads (direct call won't save much); - when more then half of thread stack size is already used (use the same mechanism as used by netgraph -- GET_STACK_USAGE() macro). Modified: projects/camlock/sys/geom/geom_io.c projects/camlock/sys/geom/geom_kern.c Modified: projects/camlock/sys/geom/geom_io.c ============================================================================== --- projects/camlock/sys/geom/geom_io.c Sun Aug 25 15:38:16 2013 (r254880) +++ projects/camlock/sys/geom/geom_io.c Sun Aug 25 17:26:05 2013 (r254881) @@ -83,6 +83,10 @@ static uma_zone_t biozone; static TAILQ_HEAD(g_classifier_tailq, g_classifier_hook) g_classifier_tailq = TAILQ_HEAD_INITIALIZER(g_classifier_tailq); +extern struct thread *g_up_td; +extern struct thread *g_down_td; +extern struct thread *g_event_td; + #include static void @@ -460,6 +464,7 @@ void g_io_request(struct bio *bp, struct g_consumer *cp) { struct g_provider *pp; + struct thread *td; int direct, error, first; KASSERT(cp != NULL, ("NULL cp in g_io_request")); @@ -515,8 +520,23 @@ g_io_request(struct bio *bp, struct g_co else getbinuptime(&bp->bio_t0); +#ifdef GET_STACK_USAGE + td = curthread; direct = (cp->flags & G_CF_DIRECT_SEND) && - (pp->flags & G_PF_DIRECT_RECEIVE); + (pp->flags & G_PF_DIRECT_RECEIVE) && + ((bp->bio_flags & BIO_UNMAPPED) == 0 || + td->td_no_sleeping == 0) && + td != g_up_td && td != g_down_td && td != g_event_td; + if (direct) { + /* Block direct execution if less then half of stack left. */ + size_t st, su; + GET_STACK_USAGE(st, su); + if (su * 2 > st) + direct = 0; + } +#else + direct = 0; +#endif /* * The statistics collection is lockless, as such, but we @@ -565,6 +585,7 @@ g_io_deliver(struct bio *bp, int error) { struct g_consumer *cp; struct g_provider *pp; + struct thread *td; int direct, first; KASSERT(bp != NULL, ("NULL bp in g_io_deliver")); @@ -611,8 +632,21 @@ g_io_deliver(struct bio *bp, int error) bp->bio_bcount = bp->bio_length; bp->bio_resid = bp->bio_bcount - bp->bio_completed; +#ifdef GET_STACK_USAGE + td = curthread; direct = (pp->flags & G_PF_DIRECT_SEND) && - (cp->flags & G_CF_DIRECT_RECEIVE); + (cp->flags & G_CF_DIRECT_RECEIVE) && + td != g_up_td && td != g_down_td && td != g_event_td; + if (direct) { + /* Block direct execution if less then half of stack left. */ + size_t st, su; + GET_STACK_USAGE(st, su); + if (su * 2 > st) + direct = 0; + } +#else + direct = 0; +#endif /* * The statistics collection is lockless, as such, but we Modified: projects/camlock/sys/geom/geom_kern.c ============================================================================== --- projects/camlock/sys/geom/geom_kern.c Sun Aug 25 15:38:16 2013 (r254880) +++ projects/camlock/sys/geom/geom_kern.c Sun Aug 25 17:26:05 2013 (r254881) @@ -59,9 +59,9 @@ MALLOC_DEFINE(M_GEOM, "GEOM", "Geom data struct sx topology_lock; static struct proc *g_proc; -static struct thread *g_up_td; -static struct thread *g_down_td; -static struct thread *g_event_td; +struct thread *g_up_td; +struct thread *g_down_td; +struct thread *g_event_td; int g_debugflags; int g_collectstats = 1;