> Date: Mon, 12 Jun 2017 10:53:52 +0900 > From: Kengo NAKAHARA <k-nakah...@iij.ad.jp> > > I want to avoid detaching the encryption device while it is used by IPsec. > That is, once someone creates Security Assocatation(SA) to call > crypto_newsession(), the encryption device related the SA must not be > detached until the SA is flushed(done crypto_freesession()) and the SA > is not used(done crypto_dispatch() and cryptointr()).
Why don't you just use a global reference count first? Is the latency and scalability of crypto_newsession and crypto_freesession critical? I am not familiar with opencrypto -- maybe the answer is yes. But in crypto_newsession, crypto_freesession, and cryptointr, you're still acquiring a global lock. That defeats the purpose of using localcount, which is to make the latency and scalability of acquire/release no more than a CPU-local integer increment.