[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-rt-users
Subject:    kernel_fpu_begin and spinlocks
From:       "Jason A. Donenfeld" <Jason () zx2c4 ! com>
Date:       2018-06-15 13:00:51
Message-ID: CAHmME9p1TZV9i6EBuFR+Pqf+8yg-sjM0f=uYzqdYKMxxUiHuRw () mail ! gmail ! com
[Download RAW message or body]

Hello,

In order to do fast crypto, people like to use vector instructions,
which make use of the FPU registers. Typically things resemble this
pattern:

kernel_fpu_begin();
encrypt();
kernel_fpu_end();

If there are multiple things to encrypt, one pattern is:

for (thing) {
  kernel_fpu_begin();
  encrypt(thing);
  kernel_fpu_end();
}

But it turns out this is slow, so instead it's better to:

kernel_fpu_begin();
for (thing)
  encrypt(thing);
kernel_fpu_end();

However, what if that innerloop has some spinlocks?

kernel_fpu_begin();
for (thing) {
  encrypt(thing);
  spin_lock(queue_lock);
  add_to_queue(queue, thing);
  spin_unlock(queue_lock);
}
kernel_fpu_end();

On normal kernels, that's certainly okay. But on rt kernels, spinlocks
call schedule(), and kernel_fpu_begin() explicitly disables
preemption, so everything explodes.

I'm wondering if -rt has any ideas about not having a strict
preemption requirement for kernel_fpu_begin/end, so that the ordinary
pattern can work on -rt kernels without exploding.

Regards,
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic