Skip to contentSkip to conversation

Add comment to memory barrier

PATCH In review Evan Chime 4 participants 13 messages Nov 3, 2019 – Nov 6, 2019

Subsystems (2)
lore
Share & tools
lore

Evan Chime

author
#0 lore raw

v2 cover Add comment to memory barrier

Include outreachy mailing list in "cc" list. No change

Evan Chime (3):
Staging: media: omap4iss: Add comment to memory barrier
Staging: media: omap4iss: Add comment to memory barrier
Staging: media: omap4iss: Add comment to memory barrier

 drivers/staging/media/omap4iss/iss.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v2 1/3 Staging: media: omap4iss: Add comment to memory barrier

Fix "WARNING: memory barrier without comment" from checkpath. Add comment to memory barrier smp_wmb() on line 635

---
 drivers/staging/media/omap4iss/iss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/omap4iss/iss.c +1 -1
index 1a966cb2f3a6..5156ad8e4b96 100644
@@ -632,7 +632,7 @@ int omap4iss_module_sync_idle(struct media_entity *me, wait_queue_head_t *wait,
 	 * scenario. We'll call it here to avoid race conditions.
 	 */
 	atomic_set(stopping, 1);
-	smp_wmb();
+	smp_wmb(); /* Prevents stores from being reordered across the barrier */
 
 	/*
 	 * If module is the last one, it's writing to memory. In this case,
Signature · 1 line
2.17.1
author
#4 lore raw

PATCH v2 2/3 Staging: media: omap4iss: Add comment to memory barrier

In reply to Evan Chime

Fix "WARNING: memory barrier without comment" from checkpath. Add comment to memory barrier smp_wmb() on line 653

---
 drivers/staging/media/omap4iss/iss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/omap4iss/iss.c +1 -1
index 5156ad8e4b96..ce34c19874c7 100644
@@ -650,7 +650,7 @@ int omap4iss_module_sync_idle(struct media_entity *me, wait_queue_head_t *wait,
 	if (video->dmaqueue_flags & ISS_VIDEO_DMAQUEUE_UNDERRUN) {
 		spin_unlock_irqrestore(&video->qlock, flags);
 		atomic_set(stopping, 0);
-		smp_wmb();
+		smp_wmb(); /* Prevent stores reordering across the barrier */
 		return 0;
 	}
 	spin_unlock_irqrestore(&video->qlock, flags);
Signature · 1 line
2.17.1
author
#5 lore raw

PATCH v2 3/3 Staging: media: omap4iss: Add comment to memory barrier

In reply to Evan Chime

Fix "WARNING: memory barrier without comment" from checkpath. Add comment to memory barrier smp_wmb() on line 660

---
 drivers/staging/media/omap4iss/iss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/omap4iss/iss.c +1 -1
index ce34c19874c7..85b0d9cbaa14 100644
@@ -657,7 +657,7 @@ int omap4iss_module_sync_idle(struct media_entity *me, wait_queue_head_t *wait,
 	if (!wait_event_timeout(*wait, !atomic_read(stopping),
 				msecs_to_jiffies(1000))) {
 		atomic_set(stopping, 0);
-		smp_wmb();
+		smp_wmb(); /* Prevent stores reordering across the barrier */
 		return -ETIMEDOUT;
 	}
 
Signature · 1 line
2.17.1
#6 lore raw

Re: [Outreachy kernel] [PATCH v2 3/3] Staging: media: omap4iss: Add comment to memory barrier

Quoted 13 lines · Evan Chime

Fix "WARNING: memory barrier without comment" from checkpath. Add comment to memory barrier smp_wmb() on line 660

---
 drivers/staging/media/omap4iss/iss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/omap4iss/iss.c +0 -0
index ce34c19874c7..85b0d9cbaa14 100644

drivers/staging/media/omap4iss/iss.c int omap4iss_module_sync_idle(struct media_entity *me, wait_queue_head_t *wait, · line 660

Quoted 5 lines
drivers/staging/media/omap4iss/iss.c +1 -1
@@ -657,7 +657,7 @@ int omap4iss_module_sync_idle(struct media_entity *me, wait_queue_head_t *wait,
 	if (!wait_event_timeout(*wait, !atomic_read(stopping),
 				msecs_to_jiffies(1000))) {
 		atomic_set(stopping, 0);
-		smp_wmb();
+		smp_wmb(); /* Prevent stores reordering across the barrier */

Which stores?

julia

Quoted 11 lines
drivers/staging/media/omap4iss/iss.c +0 -1
 		return -ETIMEDOUT;
 	}
 
--

2.17.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/62b034d416bc0b0f2fc2a10c225bcf1441b4eecc.1572797322.git.chime.evan.dri.devel%40gmail.com.

#8 lore raw
In reply to Evan Chime
Quoted 6 lines · Evan Chime

Include outreachy mailing list in "cc" list. No change

Evan Chime (3):
Staging: media: omap4iss: Add comment to memory barrier
Staging: media: omap4iss: Add comment to memory barrier
Staging: media: omap4iss: Add comment to memory barrier

Each patch should have a different subject. If you end up with patches with the same subject, you should make the subjects more specific or merge them.

In this case, though, I think that this is an issue that only someone with a deep knowledge of the code could really address. The question is not what a memory barrier does, but why one is needed at a particular place in the code.

julia

Quoted 12 lines
 drivers/staging/media/omap4iss/iss.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--
2.17.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/cover.1572797322.git.chime.evan.dri.devel%40gmail.com.

author
#7 lore raw

Re: [Outreachy kernel] [PATCH v2 3/3] Staging: media: omap4iss: Add comment to memory barrier

In reply to Julia Lawall
Quoted 24 lines · Julia Lawall

Review

Quoted 9 lines · Evan Chime

Fix "WARNING: memory barrier without comment" from checkpath. Add comment to memory barrier smp_wmb() on line 660

---
 drivers/staging/media/omap4iss/iss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/staging/media/omap4iss/iss.c

drivers/staging/media/omap4iss/iss.c int omap4iss_module_sync_idle(struct media_entity

Quoted 4 lines

index ce34c19874c7..85b0d9cbaa14 100644

drivers/staging/media/omap4iss/iss.c +0 -0
@@ -657,7 +657,7 @@ int omap4iss_module_sync_idle(struct media_entity

*me, wait_queue_head_t *wait,

drivers/staging/media/omap4iss/iss.c int omap4iss_module_sync_idle(struct media_entity *me, wait_queue_head_t *wait,

Quoted 5 lines
drivers/staging/media/omap4iss/iss.c +1 -1
      if (!wait_event_timeout(*wait, !atomic_read(stopping),
                              msecs_to_jiffies(1000))) {
              atomic_set(stopping, 0);
-             smp_wmb();
+             smp_wmb(); /* Prevent stores reordering across the barrier
Quoted 6 lines

*/

Which stores?

julia

Memory writes

Kind regards
Evan

Quoted 25 lines
Quoted 8 lines
drivers/staging/media/omap4iss/iss.c +0 -1
              return -ETIMEDOUT;
      }
 
--

2.17.1

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected].

Quoted 1 line

To view this discussion on the web visit

https://groups.google.com/d/msgid/outreachy-kernel/62b034d416bc0b0f2fc2a10c225bcf1441b4eecc.1572797322.git.chime.evan.dri.devel%40gmail.com
.

Quoted 1 line

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.21.1911031716020.2557%40hadrien
.

author
#9 lore raw
In reply to Julia Lawall
Quoted 15 lines · Julia Lawall
Quoted 6 lines · Evan Chime

Include outreachy mailing list in "cc" list. No change

Evan Chime (3):
Staging: media: omap4iss: Add comment to memory barrier
Staging: media: omap4iss: Add comment to memory barrier
Staging: media: omap4iss: Add comment to memory barrier

Each patch should have a different subject. If you end up with patches with the same subject, you should make the subjects more specific or merge them.

Quoted 6 lines

In this case, though, I think that this is an issue that only someone with a deep knowledge of the code could really address. The question is not what a memory barrier does, but why one is needed at a particular place in the code.

julia

Thanks for the feedback Julia

Kind Regards
Evan

Quoted 27 lines
Quoted 10 lines

 drivers/staging/media/omap4iss/iss.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--
2.17.1

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected].

Quoted 1 line

To view this discussion on the web visit

https://groups.google.com/d/msgid/outreachy-kernel/cover.1572797322.git.chime.evan.dri.devel%40gmail.com
.

Quoted 1 line

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.21.1911031716390.2557%40hadrien
.

maintainer
#2 lore raw

Re: [PATCH v2 1/3] Staging: media: omap4iss: Add comment to memory barrier

In reply to Evan Chime
Quoted 13 lines · Evan Chime

Fix "WARNING: memory barrier without comment" from checkpath. Add comment to memory barrier smp_wmb() on line 635

---
 drivers/staging/media/omap4iss/iss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/omap4iss/iss.c +0 -0
index 1a966cb2f3a6..5156ad8e4b96 100644

drivers/staging/media/omap4iss/iss.c int omap4iss_module_sync_idle(struct media_entity *me, wait_queue_head_t *wait, · line 635

Quoted 5 lines
drivers/staging/media/omap4iss/iss.c +1 -1
@@ -632,7 +632,7 @@ int omap4iss_module_sync_idle(struct media_entity *me, wait_queue_head_t *wait,
 	 * scenario. We'll call it here to avoid race conditions.
 	 */
 	atomic_set(stopping, 1);
-	smp_wmb();
+	smp_wmb(); /* Prevents stores from being reordered across the barrier */

We all know what smp_wmb() does, what you need to document is what exactly it is here for. What is it preventing from happening to what data that is being touched elsewhere where?

If you don't know the code, solving something like this might be very difficult, sorry.

greg k-h

author
#3 lore raw

Re: [PATCH v2 1/3] Staging: media: omap4iss: Add comment to memory barrier

Quoted 23 lines · Greg KH

Review

Quoted 9 lines · Evan Chime

Fix "WARNING: memory barrier without comment" from checkpath. Add comment to memory barrier smp_wmb() on line 635

---
 drivers/staging/media/omap4iss/iss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/staging/media/omap4iss/iss.c

drivers/staging/media/omap4iss/iss.c int omap4iss_module_sync_idle(struct media_entity

Quoted 4 lines

index 1a966cb2f3a6..5156ad8e4b96 100644

drivers/staging/media/omap4iss/iss.c +0 -0
@@ -632,7 +632,7 @@ int omap4iss_module_sync_idle(struct media_entity

*me, wait_queue_head_t *wait,

drivers/staging/media/omap4iss/iss.c int omap4iss_module_sync_idle(struct media_entity *me, wait_queue_head_t *wait,

Quoted 5 lines
drivers/staging/media/omap4iss/iss.c +1 -1
       * scenario. We'll call it here to avoid race conditions.
       */
      atomic_set(stopping, 1);
-     smp_wmb();
+     smp_wmb(); /* Prevents stores from being reordered across the

barrier */

Quoted 8 lines

We all know what smp_wmb() does, what you need to document is what exactly it is here for. What is it preventing from happening to what data that is being touched elsewhere where?

If you don't know the code, solving something like this might be very difficult, sorry.

greg k-h

Thanks for your feedback Greg. I will have a look at the code

Kind regards
Evan

Quoted 1 line
author
#10 lore raw
In reply to evan chime
Quoted 23 lines · evan chime
Quoted 20 lines · Julia Lawall
Quoted 6 lines · Evan Chime

Include outreachy mailing list in "cc" list. No change

Evan Chime (3):
Staging: media: omap4iss: Add comment to memory barrier
Staging: media: omap4iss: Add comment to memory barrier
Staging: media: omap4iss: Add comment to memory barrier

Each patch should have a different subject. If you end up with patches with the same subject, you should make the subjects more specific or merge them.

In this case, though, I think that this is an issue that only someone with a deep knowledge of the code could really address. The question is not what a memory barrier does, but why one is needed at a particular place in the code.

Quoted 8 lines
Quoted 1 line

julia

Thanks for the feedback Julia

Kind Regards
Evan

Please I have studied the function. From what I understand, the function checks if ISS submodule needs to wait for next interrupt. If yes, makes the caller to sleep while waiting for such event.

The atomic_set(stopping, 1) indicates whether the submodule needs to wait, where stopping is the flag, and atomic_set(stopping, 0) indicates no need to wait

According to the comment before the first atomic_set() call and the smp_wmb() call that follows which says:

/* Atomic set() doesn’t include memory barrier on ARM platform for SMP scenario. We’ll call it here to avoid race conditions */, the smp_wmb() call is I think, to avoid reordering of the atomic_set() operation

So can I use one of the following, as the comment

A) prevent reordering of atomic_set()

B) sync module with it’s idle state(from the comment that introduced the function)

C) ensures *stopping is persistent

D) none of the above :)

Quoted 30 lines
Quoted 29 lines
Quoted 4 lines
Quoted 8 lines
 drivers/staging/media/omap4iss/iss.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--
2.17.1

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected].

Quoted 1 line

To view this discussion on the web visit

https://groups.google.com/d/msgid/outreachy-kernel/cover.1572797322.git.chime.evan.dri.devel%40gmail.com
.

Quoted 1 line

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.21.1911031716390.2557%40hadrien
.

author
#11 lore raw
Quoted 64 lines · evan chime
Quoted 26 lines · evan chime
Quoted 23 lines · Julia Lawall
Quoted 6 lines · Evan Chime

Include outreachy mailing list in "cc" list. No change

Evan Chime (3):
Staging: media: omap4iss: Add comment to memory barrier
Staging: media: omap4iss: Add comment to memory barrier
Staging: media: omap4iss: Add comment to memory barrier

Each patch should have a different subject. If you end up with patches with the same subject, you should make the subjects more specific or merge
them.

In this case, though, I think that this is an issue that only someone with
a deep knowledge of the code could really address. The question is not what a memory barrier does, but why one is needed at a particular place in
the code.

Quoted 8 lines
Quoted 1 line

julia

Thanks for the feedback Julia

Kind Regards
Evan

Please I have studied the function. From what I understand, the function checks if ISS submodule needs to wait for next interrupt. If yes, makes the caller to sleep while waiting for such event.

The atomic_set(stopping, 1) indicates whether the submodule needs to wait, where stopping is the flag, and atomic_set(stopping, 0) indicates no need to wait

According to the comment before the first atomic_set() call and the smp_wmb() call that follows which says:

/* Atomic set() doesn’t include memory barrier on ARM platform for SMP scenario. We’ll call it here to avoid race conditions */, the smp_wmb() call is I think, to avoid reordering of the atomic_set() operation

So can I use one of the following, as the comment

A) prevent reordering of atomic_set()

Quoted 9 lines

B) sync module with it’s idle state(from the comment that introduced the function)

C) ensures *stopping is persistent

D) none of the above :)

Please forgive me for the first email, just noticed I didn’t say who it was coming from at the end.

I have studied the function. From what I understand, the function checks if ISS submodule needs to wait for next interrupt. If yes, makes the caller to sleep while waiting for such event.

The atomic_set(stopping, 1) indicates whether the submodule needs to wait, where stopping is the flag, and atomic_set(stopping, 0) indicates no need to wait

According to the comment before the first atomic_set() call and the smp_wmb() call that follows which says:

/* Atomic set() doesn’t include memory barrier on ARM platform for SMP scenario. We’ll call it here to avoid race conditions */, the smp_wmb() call is I think, to avoid reordering of the atomic_set() operation

So can I use one of the following, as the comment

A) prevent reordering of atomic_set()

B) sync module with it’s idle state(from the comment that introduced the function)

C) ensures *stopping is persistent

D) none of the above :)

Kind regards

Evan

Quoted 32 lines
Quoted 32 lines
Quoted 31 lines
Quoted 6 lines
Quoted 8 lines
 drivers/staging/media/omap4iss/iss.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--
2.17.1

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected].

Quoted 1 line

To view this discussion on the web visit

https://groups.google.com/d/msgid/outreachy-kernel/cover.1572797322.git.chime.evan.dri.devel%40gmail.com
.

Quoted 1 line

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit
https://groups.google.com/d/msgid/outreachy-kernel/alpine.DEB.2.21.1911031716390.2557%40hadrien
.