Call for testers: FPU changes
Kostik Belousov
kostikbel at gmail.com
Wed Nov 17 16:35:57 UTC 2010
On Tue, Nov 16, 2010 at 08:46:23PM -0500, Mike Tancsa wrote:
> On 11/16/2010 5:19 PM, Kostik Belousov wrote:
> > Would your conclusion be that the patch seems to increase the throughput
> > of the aesni(4) ?
> >
> > I think that on small-sized blocks, when using aesni(4), the dominating
> > factor is the copying/copyout of the data to/from the kernel address
> > space. Still would be interesting to compare the full output
> > of "openssl speed" on aesni(4) with and without the patch I posted.
>
> Hi,
> There does seem to be some improvement on large blocks. But there are
> some freakishly fast times. On other sizes, there is no difference in
> speed it would seem
>
> I did 20 runs. Updated stats at http://www.tancsa.com/fpu.html
Thank you. Indeed, I think that the test units are too small so that
random system events can cause the variation. Nonetheless, patch seems
to help, so I committed it.
Meantime, the similar change may be beneficial for padlock(4) too.
f you are going to test it, please note that most likely, openssl padlock
engine does not use padlock(4), I do not know for sure.
diff --git a/sys/crypto/via/padlock.c b/sys/crypto/via/padlock.c
index 77e059b..ba63093 100644
--- a/sys/crypto/via/padlock.c
+++ b/sys/crypto/via/padlock.c
@@ -170,7 +170,7 @@ padlock_newsession(device_t dev, uint32_t *sidp, struct cryptoini *cri)
struct padlock_session *ses = NULL;
struct cryptoini *encini, *macini;
struct thread *td;
- int error;
+ int error, saved_ctx;
if (sidp == NULL || cri == NULL)
return (EINVAL);
@@ -238,10 +238,18 @@ padlock_newsession(device_t dev, uint32_t *sidp, struct cryptoini *cri)
if (macini != NULL) {
td = curthread;
- error = fpu_kern_enter(td, &ses->ses_fpu_ctx, FPU_KERN_NORMAL);
+ if (!is_fpu_kern_thread(0)) {
+ error = fpu_kern_enter(td, &ses->ses_fpu_ctx,
+ FPU_KERN_NORMAL);
+ saved_ctx = 1;
+ } else {
+ error = 0;
+ saved_ctx = 0;
+ }
if (error == 0) {
error = padlock_hash_setup(ses, macini);
- fpu_kern_leave(td, &ses->ses_fpu_ctx);
+ if (saved_ctx)
+ fpu_kern_leave(td, &ses->ses_fpu_ctx);
}
if (error != 0) {
padlock_freesession_one(sc, ses, 0);
diff --git a/sys/crypto/via/padlock_cipher.c b/sys/crypto/via/padlock_cipher.c
index 0ae26c8..1456ddf 100644
--- a/sys/crypto/via/padlock_cipher.c
+++ b/sys/crypto/via/padlock_cipher.c
@@ -205,7 +205,7 @@ padlock_cipher_process(struct padlock_session *ses, struct cryptodesc *enccrd,
struct thread *td;
u_char *buf, *abuf;
uint32_t *key;
- int allocated, error;
+ int allocated, error, saved_ctx;
buf = padlock_cipher_alloc(enccrd, crp, &allocated);
if (buf == NULL)
@@ -250,14 +250,21 @@ padlock_cipher_process(struct padlock_session *ses, struct cryptodesc *enccrd,
}
td = curthread;
- error = fpu_kern_enter(td, &ses->ses_fpu_ctx, FPU_KERN_NORMAL);
+ if (!is_fpu_kern_thread(0)) {
+ error = fpu_kern_enter(td, &ses->ses_fpu_ctx, FPU_KERN_NORMAL);
+ saved_ctx = 1;
+ } else {
+ error = 0;
+ saved_ctx = 0;
+ }
if (error != 0)
goto out;
padlock_cbc(abuf, abuf, enccrd->crd_len / AES_BLOCK_LEN, key, cw,
ses->ses_iv);
- fpu_kern_leave(td, &ses->ses_fpu_ctx);
+ if (saved_ctx)
+ fpu_kern_leave(td, &ses->ses_fpu_ctx);
if (allocated) {
crypto_copyback(crp->crp_flags, crp->crp_buf, enccrd->crd_skip,
diff --git a/sys/crypto/via/padlock_hash.c b/sys/crypto/via/padlock_hash.c
index 58c58b2..0fe182b 100644
--- a/sys/crypto/via/padlock_hash.c
+++ b/sys/crypto/via/padlock_hash.c
@@ -366,17 +366,24 @@ padlock_hash_process(struct padlock_session *ses, struct cryptodesc *maccrd,
struct cryptop *crp)
{
struct thread *td;
- int error;
+ int error, saved_ctx;
td = curthread;
- error = fpu_kern_enter(td, &ses->ses_fpu_ctx, FPU_KERN_NORMAL);
+ if (!is_fpu_kern_thread(0)) {
+ error = fpu_kern_enter(td, &ses->ses_fpu_ctx, FPU_KERN_NORMAL);
+ saved_ctx = 1;
+ } else {
+ error = 0;
+ saved_ctx = 0;
+ }
if (error != 0)
return (error);
if ((maccrd->crd_flags & CRD_F_KEY_EXPLICIT) != 0)
padlock_hash_key_setup(ses, maccrd->crd_key, maccrd->crd_klen);
error = padlock_authcompute(ses, maccrd, crp->crp_buf, crp->crp_flags);
- fpu_kern_leave(td, &ses->ses_fpu_ctx);
+ if (saved_ctx)
+ fpu_kern_leave(td, &ses->ses_fpu_ctx);
return (error);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20101117/85e24276/attachment.pgp
More information about the freebsd-stable
mailing list