From owner-svn-src-stable@FreeBSD.ORG Sun Aug 25 14:29:48 2013 Return-Path: Delivered-To: svn-src-stable@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 F31C1CF8; Sun, 25 Aug 2013 14:29:47 +0000 (UTC) (envelope-from roberto@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 CFC012066; Sun, 25 Aug 2013 14:29:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7PETl86035522; Sun, 25 Aug 2013 14:29:47 GMT (envelope-from roberto@svn.freebsd.org) Received: (from roberto@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7PETlY7035520; Sun, 25 Aug 2013 14:29:47 GMT (envelope-from roberto@svn.freebsd.org) Message-Id: <201308251429.r7PETlY7035520@svn.freebsd.org> From: Ollivier Robert Date: Sun, 25 Aug 2013 14:29:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r254859 - stable/9/sys/geom/eli X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Aug 2013 14:29:48 -0000 Author: roberto Date: Sun Aug 25 14:29:47 2013 New Revision: 254859 URL: http://svnweb.freebsd.org/changeset/base/254859 Log: MFC r226840: AESNI-related commit, from a long time ago: Before this change when GELI detected hardware crypto acceleration it will start only one worker thread. For software crypto it will start by default N worker threads where N is the number of available CPUs. This is not optimal if hardware crypto is AES-NI, which uses CPU for AES calculations. Change that to always start one worker thread for every available CPU. Number of worker threads per GELI provider can be easly reduced with kern.geom.eli.threads sysctl/tunable and even for software crypto it should be reduced when using more providers. While here, when number of threads exceeds number of CPUs avilable don't reduce this number, assume the user knows what he is doing. Submitted by: Michael Moll Modified: stable/9/sys/geom/eli/g_eli.c stable/9/sys/geom/eli/g_eli.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/geom/eli/g_eli.c ============================================================================== --- stable/9/sys/geom/eli/g_eli.c Sun Aug 25 14:27:14 2013 (r254858) +++ stable/9/sys/geom/eli/g_eli.c Sun Aug 25 14:29:47 2013 (r254859) @@ -444,16 +444,15 @@ g_eli_worker(void *arg) sc = wr->w_softc; #ifdef SMP /* Before sched_bind() to a CPU, wait for all CPUs to go on-line. */ - if (mp_ncpus > 1 && sc->sc_crypto == G_ELI_CRYPTO_SW && - g_eli_threads == 0) { + if (sc->sc_cpubind) { while (!smp_started) tsleep(wr, 0, "geli:smp", hz / 4); } #endif thread_lock(curthread); sched_prio(curthread, PUSER); - if (sc->sc_crypto == G_ELI_CRYPTO_SW && g_eli_threads == 0) - sched_bind(curthread, wr->w_number); + if (sc->sc_cpubind) + sched_bind(curthread, wr->w_number % mp_ncpus); thread_unlock(curthread); G_ELI_DEBUG(1, "Thread %s started.", curthread->td_proc->p_comm); @@ -810,11 +809,7 @@ g_eli_create(struct gctl_req *req, struc threads = g_eli_threads; if (threads == 0) threads = mp_ncpus; - else if (threads > mp_ncpus) { - /* There is really no need for too many worker threads. */ - threads = mp_ncpus; - G_ELI_DEBUG(0, "Reducing number of threads to %u.", threads); - } + sc->sc_cpubind = (mp_ncpus > 1 && threads == mp_ncpus); for (i = 0; i < threads; i++) { if (g_eli_cpu_is_disabled(i)) { G_ELI_DEBUG(1, "%s: CPU %u disabled, skipping.", @@ -854,9 +849,6 @@ g_eli_create(struct gctl_req *req, struc goto failed; } LIST_INSERT_HEAD(&sc->sc_workers, wr, w_next); - /* If we have hardware support, one thread is enough. */ - if (sc->sc_crypto == G_ELI_CRYPTO_HW) - break; } /* Modified: stable/9/sys/geom/eli/g_eli.h ============================================================================== --- stable/9/sys/geom/eli/g_eli.h Sun Aug 25 14:27:14 2013 (r254858) +++ stable/9/sys/geom/eli/g_eli.h Sun Aug 25 14:29:47 2013 (r254859) @@ -190,6 +190,7 @@ struct g_eli_softc { size_t sc_sectorsize; u_int sc_bytes_per_sector; u_int sc_data_per_sector; + boolean_t sc_cpubind; /* Only for software cryptography. */ struct bio_queue_head sc_queue;