add debug trace in vxrcu.c (#71)
Reviewed-on: http://13.234.246.121:3000/Neominds/ossl35vx69/pulls/71 Co-authored-by: siddhant <siddhant.singh@neominds.in> Co-committed-by: siddhant <siddhant.singh@neominds.in>
This commit is contained in:
@@ -1,6 +1,10 @@
|
|||||||
|
#include <string.h>
|
||||||
|
#include <taskLibCommon.h>
|
||||||
#include <openssl/crypto.h>
|
#include <openssl/crypto.h>
|
||||||
#include <openssl/vxrcu.h>
|
#include <openssl/vxrcu.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
|
#include <openssl/trace.h>
|
||||||
|
|
||||||
|
|
||||||
static CRYPTO_RWLOCK_VX *local_rcu_rwlock = NULL;
|
static CRYPTO_RWLOCK_VX *local_rcu_rwlock = NULL;
|
||||||
static int is_rwlock_init = 0;
|
static int is_rwlock_init = 0;
|
||||||
@@ -57,6 +61,7 @@ CRYPTO_RCU_LOCK *ossl_rcu_lock_new(int num_writers, OSSL_LIB_CTX *ctx)
|
|||||||
ERR_print_errors_fp(stderr);
|
ERR_print_errors_fp(stderr);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_lock_new:: allocated memory for lock.\n", taskIdSelf());
|
||||||
|
|
||||||
lock->writer_lock = semMCreate (SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE);
|
lock->writer_lock = semMCreate (SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE);
|
||||||
if (!(lock->writer_lock))
|
if (!(lock->writer_lock))
|
||||||
@@ -65,6 +70,7 @@ CRYPTO_RCU_LOCK *ossl_rcu_lock_new(int num_writers, OSSL_LIB_CTX *ctx)
|
|||||||
ERR_add_error_data(1, "ossl_rcu_lock_new:: semMCreate failed for writer_lock\n");
|
ERR_add_error_data(1, "ossl_rcu_lock_new:: semMCreate failed for writer_lock\n");
|
||||||
ERR_print_errors_fp(stderr);
|
ERR_print_errors_fp(stderr);
|
||||||
}
|
}
|
||||||
|
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_lock_new:: created semaphore for writer_lock.\n", taskIdSelf());
|
||||||
|
|
||||||
lock->active_readers = 0;
|
lock->active_readers = 0;
|
||||||
|
|
||||||
@@ -78,6 +84,7 @@ CRYPTO_RCU_LOCK *ossl_rcu_lock_new(int num_writers, OSSL_LIB_CTX *ctx)
|
|||||||
ERR_print_errors_fp(stderr);
|
ERR_print_errors_fp(stderr);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_lock_new:: allocated memory for local_rcu_rwlock.\n", taskIdSelf());
|
||||||
|
|
||||||
memset (local_rcu_rwlock, sizeof (CRYPTO_RWLOCK_VX), 0);
|
memset (local_rcu_rwlock, sizeof (CRYPTO_RWLOCK_VX), 0);
|
||||||
|
|
||||||
@@ -90,8 +97,11 @@ CRYPTO_RCU_LOCK *ossl_rcu_lock_new(int num_writers, OSSL_LIB_CTX *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
is_rwlock_init = 1;
|
is_rwlock_init = 1;
|
||||||
|
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_lock_new:: created semaphore for local_rcu_rwlock and set is_rwlock_init=1.\n",
|
||||||
|
taskIdSelf());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_lock_new:: done.\n", taskIdSelf());
|
||||||
return lock;
|
return lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,6 +114,7 @@ void ossl_rcu_lock_free(CRYPTO_RCU_LOCK *lock)
|
|||||||
local_rcu_rwlock = NULL;
|
local_rcu_rwlock = NULL;
|
||||||
is_rwlock_init = 0;
|
is_rwlock_init = 0;
|
||||||
}
|
}
|
||||||
|
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_lock_free:: freed local_rcu_rwlock.\n", taskIdSelf());
|
||||||
|
|
||||||
if (!lock)
|
if (!lock)
|
||||||
{
|
{
|
||||||
@@ -113,33 +124,41 @@ void ossl_rcu_lock_free(CRYPTO_RCU_LOCK *lock)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_lock_free:: deleting writer_lock and freeing lock.\n", taskIdSelf());
|
||||||
semDelete (lock->writer_lock);
|
semDelete (lock->writer_lock);
|
||||||
free(lock);
|
free(lock);
|
||||||
|
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_lock_free:: done.\n", taskIdSelf());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ossl_rcu_read_lock(CRYPTO_RCU_LOCK *lock)
|
void ossl_rcu_read_lock(CRYPTO_RCU_LOCK *lock)
|
||||||
{
|
{
|
||||||
vxAtomicInc (&(lock->active_readers));
|
vxAtomicInc (&(lock->active_readers));
|
||||||
|
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_read_lock:: done.\n", taskIdSelf());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ossl_rcu_read_unlock(CRYPTO_RCU_LOCK *lock)
|
void ossl_rcu_read_unlock(CRYPTO_RCU_LOCK *lock)
|
||||||
{
|
{
|
||||||
vxAtomicDec (&(lock->active_readers));
|
vxAtomicDec (&(lock->active_readers));
|
||||||
|
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_read_unlock:: done.\n", taskIdSelf());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ossl_rcu_write_lock(CRYPTO_RCU_LOCK *lock)
|
void ossl_rcu_write_lock(CRYPTO_RCU_LOCK *lock)
|
||||||
{
|
{
|
||||||
semMTake (lock->writer_lock, WAIT_FOREVER);
|
semMTake (lock->writer_lock, WAIT_FOREVER);
|
||||||
|
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_write_lock:: done.\n", taskIdSelf());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ossl_rcu_write_unlock(CRYPTO_RCU_LOCK *lock)
|
void ossl_rcu_write_unlock(CRYPTO_RCU_LOCK *lock)
|
||||||
{
|
{
|
||||||
semMGive (lock->writer_lock);
|
semMGive (lock->writer_lock);
|
||||||
|
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_write_unlock:: done.\n", taskIdSelf());
|
||||||
}
|
}
|
||||||
|
|
||||||
void *ossl_rcu_uptr_deref(void **p)
|
void *ossl_rcu_uptr_deref(void **p)
|
||||||
{
|
{
|
||||||
/* readers just dereference safely */
|
/* readers just dereference safely */
|
||||||
|
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_uptr_deref:: returning dereferenced pointer.\n",
|
||||||
|
taskIdSelf());
|
||||||
return *p;
|
return *p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,6 +171,7 @@ void ossl_rcu_assign_uptr(void **p, void **v)
|
|||||||
|
|
||||||
/* publish new pointer immediately */
|
/* publish new pointer immediately */
|
||||||
CRYPTO_atomic_load_int(val, ret, local_rcu_rwlock);
|
CRYPTO_atomic_load_int(val, ret, local_rcu_rwlock);
|
||||||
|
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_assign_uptr:: done.\n", taskIdSelf());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ossl_synchronize_rcu(CRYPTO_RCU_LOCK *lock)
|
void ossl_synchronize_rcu(CRYPTO_RCU_LOCK *lock)
|
||||||
@@ -179,6 +199,8 @@ void ossl_synchronize_rcu(CRYPTO_RCU_LOCK *lock)
|
|||||||
tmpcb->fn(tmpcb->data);
|
tmpcb->fn(tmpcb->data);
|
||||||
OPENSSL_free(tmpcb);
|
OPENSSL_free(tmpcb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OSSL_TRACE1 (RCU, "[%08x] ossl_synchronize_rcu:: done.\n", taskIdSelf());
|
||||||
}
|
}
|
||||||
|
|
||||||
int ossl_rcu_call(CRYPTO_RCU_LOCK *lock, rcu_cb_fn cb, void *data)
|
int ossl_rcu_call(CRYPTO_RCU_LOCK *lock, rcu_cb_fn cb, void *data)
|
||||||
@@ -206,6 +228,7 @@ int ossl_rcu_call(CRYPTO_RCU_LOCK *lock, rcu_cb_fn cb, void *data)
|
|||||||
new->next = lock->cb_items;
|
new->next = lock->cb_items;
|
||||||
lock->cb_items = new;
|
lock->cb_items = new;
|
||||||
|
|
||||||
|
OSSL_TRACE1 (RCU, "[%08x] ossl_rcu_call:: done.\n", taskIdSelf());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user