tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: pserialize-safe queue(3) alternative
Hi,
Thank you for quick update!
On 2016/04/08 1:09, Taylor R Campbell wrote:
> Date: Thu, 7 Apr 2016 18:22:08 +0900
> From: Kengo NAKAHARA <k-nakahara%iij.ad.jp@localhost>
>
> Sorry, I found one more question. _pslist_writer_next_container() does
> not use "next" variable. I think the following patch is required.
>
> Thanks! Here's a new draft with this fix, the insert_after fix, and a
> note on write ordering to justify the placement of membar_producer.
I apply pslist to my gif(4) implementation. Furthermore, ozaki-r@n.o
apply pslist to bridge(4) and check by ATF. In consequence, we think
the following patch might be required. Is the patch appropriate?
====================
diff --git a/sys/sys/pslist.h b/sys/sys/pslist.h
index 2aef4b3..a59713e 100644
--- a/sys/sys/pslist.h
+++ b/sys/sys/pslist.h
@@ -73,6 +73,8 @@ static inline void
pslist_writer_insert_head(struct pslist_head *head, struct pslist_entry *new)
{
+ if (head->plh_first != NULL)
+ head->plh_first->ple_prevp = &new->ple_next;
new->ple_prevp = &head->plh_first;
new->ple_next = head->plh_first;
membar_producer();
@@ -107,6 +109,8 @@ static inline void
pslist_writer_remove(struct pslist_entry *entry)
{
+ if (entry->ple_next != NULL)
+ entry->ple_next->ple_prevp = entry->ple_prevp;
*entry->ple_prevp = entry->ple_next;
entry->ple_prevp = NULL; /* poison */
}
@@ -187,7 +191,7 @@ _pslist_reader_next_container(struct pslist_entry *entry, ptrdiff_t offset)
{
struct pslist_entry *next = entry->ple_next;
- if (entry == NULL)
+ if (next == NULL)
return NULL;
membar_datadep_consumer();
@@ -224,10 +228,10 @@ _pslist_reader_next_container(struct pslist_entry *entry, ptrdiff_t offset)
pslist_writer_remove(&(E)->F)
#define PSLIST_WRITER_FIRST(H, T, F) \
((T *)(_pslist_writer_first_container((H), offsetof(T, F))) + \
- _PSLIST_VALIDATE_CONTAINER(pslist_first(H), T, F))
+ _PSLIST_VALIDATE_CONTAINER(pslist_writer_first(H), T, F))
#define PSLIST_WRITER_NEXT(V, T, F) \
((T *)(_pslist_writer_next_container(&(V)->F, offsetof(T, F))) + \
- _PSLIST_VALIDATE_CONTAINER(pslist_next(&(V)->F), T, F))
+ _PSLIST_VALIDATE_CONTAINER(pslist_writer_next(&(V)->F), T, F))
#define PSLIST_WRITER_FOREACH(V, H, T, F) \
for ((V) = PSLIST_WRITER_FIRST((H), T, F); \
(V) != NULL; \
@@ -235,10 +239,10 @@ _pslist_reader_next_container(struct pslist_entry *entry, ptrdiff_t offset)
#define PSLIST_READER_FIRST(H, T, F) \
((T *)(_pslist_reader_first_container((H), offsetof(T, F))) + \
- _PSLIST_VALIDATE_CONTAINER(pslist_first(H), T, F))
+ _PSLIST_VALIDATE_CONTAINER(pslist_reader_first(H), T, F))
#define PSLIST_READER_NEXT(V, T, F) \
((T *)(_pslist_reader_next_container(&(V)->F, offsetof(T, F))) + \
- _PSLIST_VALIDATE_CONTAINER(pslist_next(&(V)->F), T, F))
+ _PSLIST_VALIDATE_CONTAINER(pslist_reader_next(&(V)->F), T, F))
#define PSLIST_READER_FOREACH(V, H, T, F) \
for ((V) = PSLIST_READER_FIRST((H), T, F); \
(V) != NULL; \
====================
Thanks,
--
//////////////////////////////////////////////////////////////////////
Internet Initiative Japan Inc.
Device Engineering Section,
IoT Platform Development Department,
Network Division,
Technology Unit
Kengo NAKAHARA <k-nakahara%iij.ad.jp@localhost>
Home |
Main Index |
Thread Index |
Old Index