Commit 09f7e0b5 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/libwr: add verbosity when double lock/unlock of shmem

Also increase all *_SHMEM_VERSION
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent f04969fe
......@@ -119,8 +119,7 @@ struct hal_temp_sensors {
};
/* This is the overall structure stored in shared memory */
#define HAL_SHMEM_VERSION 10 /* Version 10 because of adding sfp_dom_raw
has_sfp_diag and read_sfp_diag */
#define HAL_SHMEM_VERSION 11 /* Version 11, changed wrs_shm_head */
struct hal_shmem_header {
int nports;
......
......@@ -125,8 +125,7 @@ struct rtu_vlan_table_entry {
};
/* This is the overall structure stored in shared memory */
#define RTU_SHMEM_VERSION 2 /* Version 2, added filters_offset and
* vlans_offset */
#define RTU_SHMEM_VERSION 3 /* Version 3, changed wrs_shm_head */
struct rtu_shmem_header {
struct rtu_filtering_entry *filters;
struct rtu_vlan_table_entry *vlans;
......
......@@ -35,6 +35,9 @@ struct wrs_shm_head {
unsigned sequence; /* If we need consistency, this is it. LSB bit
* informs whether shmem is locked already */
unsigned version; /* Version of the data structure */
const char *last_write_caller; /* Function of the last wrs_shm_write
* call */
int last_write_line; /* Line of the last wrs_shm_write call */
unsigned data_size; /* Size of it (for binary dumps) */
};
......@@ -81,11 +84,11 @@ void *wrs_shm_follow(struct wrs_shm_head *head, void *ptr);
#define WRS_SHM_WRITE_BEGIN 1
#define WRS_SHM_WRITE_END 0
/* A helper to pass the name of caller function */
/* A helper to pass the name of a caller function and a line of the call */
#define wrs_shm_write(headptr, flags) wrs_shm_write_caller(headptr, flags, \
__func__)
__func__, __LINE__)
extern void wrs_shm_write_caller(struct wrs_shm_head *head, int flags,
const char *caller);
const char *caller, int line);
/* A reader can rely on the sequence number (in the <linux/seqlock.h> way) */
extern unsigned wrs_shm_seqbegin(struct wrs_shm_head *head);
......
......@@ -216,7 +216,7 @@ void *wrs_shm_follow(struct wrs_shm_head *head, void *ptr)
/* Before and after writing a chunk of data, act on sequence and stamp */
void wrs_shm_write_caller(struct wrs_shm_head *head, int flags,
const char *caller)
const char *caller, int line)
{
char *msg = "Wrong parameter";
......@@ -236,24 +236,33 @@ void wrs_shm_write_caller(struct wrs_shm_head *head, int flags,
head->sequence += 2;
if (flags == WRS_SHM_WRITE_BEGIN) {
if (head->sequence & WRS_SHM_LOCK_MASK)
pr_error("Trying to lock already locked shmem on the "
"write end! Sequence number is %d. The caller"
" of wrs_shm_write is %s\n",
head->sequence, caller);
pr_error("Trying to lock already locked shmem! "
"The sequence number is %d. The current "
"caller of wrs_shm_write is %s (line %d), "
"previous caller %s (line %d)\n",
head->sequence, caller, line,
head->last_write_caller,
head->last_write_line);
head->sequence |= WRS_SHM_LOCK_MASK;
head->last_write_caller = caller;
head->last_write_line = line;
}
if (flags == WRS_SHM_WRITE_END) {
/* At end-of-writing update the timestamp too */
head->stamp = get_monotonic_sec();
if (!(head->sequence & WRS_SHM_LOCK_MASK))
pr_error("Trying to unlock already unlocked shmem on "
"the write begin! Sequence number is %d. The "
"caller of wrs_shm_write is %s\n",
head->sequence, caller);
pr_error("Trying to unlock already unlocked shmem! "
"The sequence number is %d. The current "
"caller of wrs_shm_write is %s (line %d), "
"previous caller %s (line %d)\n",
head->sequence, caller, line,
head->last_write_caller,
head->last_write_line);
head->sequence &= ~WRS_SHM_LOCK_MASK;
head->last_write_caller = caller;
head->last_write_line = line;
}
return;
}
......
ppsi @ 73ebe33f
Subproject commit 68e640eacd5d2b8fd6800c9fab4ef9d2dd4fd9ed
Subproject commit 73ebe33f8885c104714b8b0157dc2ca274bbb690
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment