aboutsummaryrefslogtreecommitdiff
path: root/sys/geom/eli/g_eli.c
diff options
context:
space:
mode:
authorPawel Jakub Dawidek <pjd@FreeBSD.org>2011-10-27 16:12:25 +0000
committerPawel Jakub Dawidek <pjd@FreeBSD.org>2011-10-27 16:12:25 +0000
commit0c879bd990f8825ed39669a80eec1a61723c390f (patch)
treed9c52a3ff7d86b2fe6486180e54d8b5b6800bd08 /sys/geom/eli/g_eli.c
parent14a0d246072359088058991db35c91cb86285d82 (diff)
downloadsrc-0c879bd990f8825ed39669a80eec1a61723c390f.tar.gz
src-0c879bd990f8825ed39669a80eec1a61723c390f.zip
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. Reported by: Yuri Karaban <dev@dev97.com> MFC after: 3 days
Notes
Notes: svn path=/head/; revision=226840
Diffstat (limited to 'sys/geom/eli/g_eli.c')
-rw-r--r--sys/geom/eli/g_eli.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c
index b5e4f7b6d696..874aa2689a07 100644
--- a/sys/geom/eli/g_eli.c
+++ b/sys/geom/eli/g_eli.c
@@ -443,16 +443,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);
@@ -813,11 +812,7 @@ g_eli_create(struct gctl_req *req, struct g_class *mp, struct g_provider *bpp,
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.",
@@ -857,9 +852,6 @@ g_eli_create(struct gctl_req *req, struct g_class *mp, struct g_provider *bpp,
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;
}
/*