Commit 09209006 authored by Adam Wujek's avatar Adam Wujek 💬

arch-wrs: fix commit "improve locking of shmem"

The commit:
15076cb6 arch-wrs: improve locking of shmem
didn't fully apply the patch from the wr-switch repo.
This commit apply changes to arch-wrs/shmem.c that were missed
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 1edcf5c4
...@@ -210,23 +210,27 @@ void wrs_shm_write_caller(void *headptr, int flags, const char *caller) ...@@ -210,23 +210,27 @@ void wrs_shm_write_caller(void *headptr, int flags, const char *caller)
{ {
struct wrs_shm_head *head = headptr; struct wrs_shm_head *head = headptr;
head->sequence++; head->sequence += 2;
pr_debug("caller: %s\n", caller); pr_debug("caller of a function %s is %s\n", __func__, caller);
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);
head->sequence |= WRS_SHM_LOCK_MASK;
}
if (flags == WRS_SHM_WRITE_END) { if (flags == WRS_SHM_WRITE_END) {
/* At end-of-writing update the timestamp too */ /* At end-of-writing update the timestamp too */
head->stamp = get_monotonic_sec(); head->stamp = get_monotonic_sec();
if (head->sequence & 1) if (!(head->sequence & WRS_SHM_LOCK_MASK))
pr_error("On the shmem write end the sequence number " pr_error("Trying to unlock already unlocked shmem on "
"(%d) is even (should be odd). The caller of" "the write begin! Sequence number is %d. The "
" wrs_shm_write is %s\n", "caller of wrs_shm_write is %s\n",
head->sequence, caller);
} else {
if (!(head->sequence & 1))
pr_error("On the shmem write begin the sequence number"
" (%d) is odd (should be even). The caller of"
" wrs_shm_write is %s\n",
head->sequence, caller); head->sequence, caller);
head->sequence &= ~WRS_SHM_LOCK_MASK;
} }
return; return;
...@@ -244,7 +248,7 @@ int wrs_shm_seqretry(void *headptr, unsigned start) ...@@ -244,7 +248,7 @@ int wrs_shm_seqretry(void *headptr, unsigned start)
{ {
struct wrs_shm_head *head = headptr; struct wrs_shm_head *head = headptr;
if (start & 1) if (start & WRS_SHM_LOCK_MASK)
return 1; /* it was odd: retry */ return 1; /* it was odd: retry */
return head->sequence != start; return head->sequence != start;
......
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