Skip to contentSkip to conversation

doc/RCU/listRCU: fix an example code snippets

PATCH In review Wei Yang 3 participants 10 messages Jan 1, 2025 – Feb 18, 2025

Subsystems (2)
lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 doc/RCU/listRCU: fix an example code snippets

The example code for "Eliminating Stale Data" looks not correct:

* rcu_read_unlock() should put after kstrdup()
* spin_unlock() should be called before return

---
Hope my understanding is correct.

---
 Documentation/RCU/listRCU.rst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/RCU/listRCU.rst +2 -1
index ed5c9d8c9afe..8df50fcd69fd 100644
@@ -348,9 +348,10 @@ to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to
 					rcu_read_unlock();
 					return AUDIT_BUILD_CONTEXT;
 				}
-				rcu_read_unlock();
 				if (state == AUDIT_STATE_RECORD)
 					*key = kstrdup(e->rule.filterkey, GFP_ATOMIC);
+				spin_unlock(&e->lock);
+				rcu_read_unlock();
 				return state;
 			}
 		}
Signature · 1 line
2.34.1
author
#1 lore raw

Ping

Quoted 31 lines · Wei Yang

The example code for "Eliminating Stale Data" looks not correct:

* rcu_read_unlock() should put after kstrdup()
* spin_unlock() should be called before return

---
Hope my understanding is correct.
---
Documentation/RCU/listRCU.rst | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/RCU/listRCU.rst +2 -1
index ed5c9d8c9afe..8df50fcd69fd 100644
@@ -348,9 +348,10 @@ to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to
 					rcu_read_unlock();
 					return AUDIT_BUILD_CONTEXT;
 				}
-				rcu_read_unlock();
 				if (state == AUDIT_STATE_RECORD)
 					*key = kstrdup(e->rule.filterkey, GFP_ATOMIC);
+				spin_unlock(&e->lock);
+				rcu_read_unlock();
 				return state;
 			}
 		}
Signature · 1 line
2.34.1
Signature · 2 lines
Wei Yang
Help you, Help me
#2 lore raw
In reply to Wei Yang

Hi Wei,

The change loosk good to me, thanks!

I queued the patch for futher reviews and tests with some changes in the commit log (for title formating and a bit more explanation), please see below.

Regards,
Boqun

Quoted 6 lines · Wei Yang

The example code for "Eliminating Stale Data" looks not correct:

* rcu_read_unlock() should put after kstrdup()
* spin_unlock() should be called before return

[...]

------------------>8
Subject: [PATCH] doc/RCU/listRCU: Fix an example code snippets

The example code for "Eliminating Stale Data" looks not correct:

* rcu_read_unlock() should put after kstrdup(), because otherwise
entry may get freed while kstrdup() is being called.

* spin_unlock() should be called before return, otherwise the
function would return with the lock of the entry held.

Hence fix these.

---
 Documentation/RCU/listRCU.rst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/RCU/listRCU.rst +2 -1
index ed5c9d8c9afe..8df50fcd69fd 100644
@@ -348,9 +348,10 @@ to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to
 					rcu_read_unlock();
 					return AUDIT_BUILD_CONTEXT;
 				}
-				rcu_read_unlock();
 				if (state == AUDIT_STATE_RECORD)
 					*key = kstrdup(e->rule.filterkey, GFP_ATOMIC);
+				spin_unlock(&e->lock);
+				rcu_read_unlock();
 				return state;
 			}
 		}
#3 lore raw
Quoted 47 lines · Boqun Feng

Hi Wei,

The change loosk good to me, thanks!

I queued the patch for futher reviews and tests with some changes in the commit log (for title formating and a bit more explanation), please see below.

Regards,
Boqun

Quoted 6 lines · Wei Yang

The example code for "Eliminating Stale Data" looks not correct:

* rcu_read_unlock() should put after kstrdup()
* spin_unlock() should be called before return

[...]

------------------>8
Subject: [PATCH] doc/RCU/listRCU: Fix an example code snippets

The example code for "Eliminating Stale Data" looks not correct:

* rcu_read_unlock() should put after kstrdup(), because otherwise entry may get freed while kstrdup() is being called.

* spin_unlock() should be called before return, otherwise the function would return with the lock of the entry held.

Hence fix these.

---
Documentation/RCU/listRCU.rst | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/RCU/listRCU.rst +0 -0
index ed5c9d8c9afe..8df50fcd69fd 100644

Documentation/RCU/listRCU.rst to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to · line 353

Quoted 7 lines
Documentation/RCU/listRCU.rst +1 -1
@@ -348,9 +348,10 @@ to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to
 rcu_read_unlock();
 return AUDIT_BUILD_CONTEXT;
 }
- rcu_read_unlock();
 if (state == AUDIT_STATE_RECORD)
 *key = kstrdup(e->rule.filterkey, GFP_ATOMIC);
+ spin_unlock(&e->lock);

According to the above quick quiz, we should return with the lock held.

Quoted 6 lines
Documentation/RCU/listRCU.rst +1 -0
+ rcu_read_unlock();
 return state;
 }
 }
#4 lore raw
Quoted 43 lines · Alan Huang
Quoted 42 lines · Boqun Feng

Hi Wei,

The change loosk good to me, thanks!

I queued the patch for futher reviews and tests with some changes in the commit log (for title formating and a bit more explanation), please see below.

Regards,
Boqun

Quoted 6 lines · Wei Yang

The example code for "Eliminating Stale Data" looks not correct:

* rcu_read_unlock() should put after kstrdup()
* spin_unlock() should be called before return

[...]

------------------>8
Subject: [PATCH] doc/RCU/listRCU: Fix an example code snippets

The example code for "Eliminating Stale Data" looks not correct:

* rcu_read_unlock() should put after kstrdup(), because otherwise entry may get freed while kstrdup() is being called.

* spin_unlock() should be called before return, otherwise the function would return with the lock of the entry held.

Hence fix these.

---
Documentation/RCU/listRCU.rst | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 15 lines

Documentation/RCU/listRCU.rst to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to · line 353

Quoted 12 lines
Documentation/RCU/listRCU.rst +1 -1
index ed5c9d8c9afe..8df50fcd69fd 100644
@@ -348,9 +348,10 @@ to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to
 rcu_read_unlock();
 return AUDIT_BUILD_CONTEXT;
 }
- rcu_read_unlock();
 if (state == AUDIT_STATE_RECORD)
 *key = kstrdup(e->rule.filterkey, GFP_ATOMIC);
+ spin_unlock(&e->lock);

According to the above quick quiz, we should return with the lock held.

Good catch! I think we then don't need this patch? Wei, are you able to confirm Alan's reasoning here?

Regards,
Boqun

Quoted 7 lines
Quoted 6 lines
Documentation/RCU/listRCU.rst +1 -0
+ rcu_read_unlock();
 return state;
 }
 }
author
#5 lore raw
In reply to Alan Huang
Quoted 43 lines · Alan Huang
Quoted 42 lines · Boqun Feng

Hi Wei,

The change loosk good to me, thanks!

I queued the patch for futher reviews and tests with some changes in the commit log (for title formating and a bit more explanation), please see below.

Regards,
Boqun

Quoted 6 lines · Wei Yang

The example code for "Eliminating Stale Data" looks not correct:

* rcu_read_unlock() should put after kstrdup()
* spin_unlock() should be called before return

[...]

------------------>8
Subject: [PATCH] doc/RCU/listRCU: Fix an example code snippets

The example code for "Eliminating Stale Data" looks not correct:

* rcu_read_unlock() should put after kstrdup(), because otherwise entry may get freed while kstrdup() is being called.

* spin_unlock() should be called before return, otherwise the function would return with the lock of the entry held.

Hence fix these.

---
Documentation/RCU/listRCU.rst | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 15 lines

Documentation/RCU/listRCU.rst to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to · line 353

Quoted 12 lines
Documentation/RCU/listRCU.rst +1 -1
index ed5c9d8c9afe..8df50fcd69fd 100644
@@ -348,9 +348,10 @@ to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to
 rcu_read_unlock();
 return AUDIT_BUILD_CONTEXT;
 }
- rcu_read_unlock();
 if (state == AUDIT_STATE_RECORD)
 *key = kstrdup(e->rule.filterkey, GFP_ATOMIC);
+ spin_unlock(&e->lock);

According to the above quick quiz, we should return with the lock held.

Thanks, I think you have some reason.

If my understanding is correct, the example here is to emphasize we could still access the value out of critical section but with spinlock held.

In current example, we don't return e(struct audit_entry) from audit_filter_task(). So no one suppose to release the spinlock again. This looks to be a mistake.

My suggestion is to release the lock after kstrdup() to make the example more intact. But with a comment to explain the purpose here.

Also I found we miss the second parameter key here.

Documentation/RCU/listRCU.rst +4 -1
index ed5c9d8c9afe..a3e7f8ff3a81 100644
@@ -334,7 +334,7 @@ If the system-call audit module were to ever need to reject stale data, one way
 to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to the
 ``audit_entry`` structure, and modify audit_filter_task() as follows::
 
-	static enum audit_state audit_filter_task(struct task_struct *tsk)
+	static enum audit_state audit_filter_task(struct task_struct *tsk, char **key)
 	{
 		struct audit_entry *e;
 		enum audit_state   state;
@@ -349,8 +349,11 @@ to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to
 					return AUDIT_BUILD_CONTEXT;
 				}
 				rcu_read_unlock();
+				/* With spinlock held, it is ok to access 'e' out
+                                 * of critial section */
 				if (state == AUDIT_STATE_RECORD)
 					*key = kstrdup(e->rule.filterkey, GFP_ATOMIC);
+				spin_unlock(&e->lock);
 				return state;
 			}
 		}

Does it make sense to you?

Signature · 2 lines
Wei Yang
Help you, Help me
#6 lore raw
Quoted 61 lines · Wei Yang
Quoted 43 lines · Alan Huang
Quoted 42 lines · Boqun Feng

Hi Wei,

The change loosk good to me, thanks!

I queued the patch for futher reviews and tests with some changes in the commit log (for title formating and a bit more explanation), please see below.

Regards,
Boqun

Quoted 6 lines · Wei Yang

The example code for "Eliminating Stale Data" looks not correct:

* rcu_read_unlock() should put after kstrdup()
* spin_unlock() should be called before return

[...]

------------------>8
Subject: [PATCH] doc/RCU/listRCU: Fix an example code snippets

The example code for "Eliminating Stale Data" looks not correct:

* rcu_read_unlock() should put after kstrdup(), because otherwise entry may get freed while kstrdup() is being called.

* spin_unlock() should be called before return, otherwise the function would return with the lock of the entry held.

Hence fix these.

---
Documentation/RCU/listRCU.rst | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 15 lines

Documentation/RCU/listRCU.rst to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to · line 353

Quoted 12 lines
Documentation/RCU/listRCU.rst +1 -1
index ed5c9d8c9afe..8df50fcd69fd 100644
@@ -348,9 +348,10 @@ to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to
 rcu_read_unlock();
 return AUDIT_BUILD_CONTEXT;
 }
- rcu_read_unlock();
 if (state == AUDIT_STATE_RECORD)
 *key = kstrdup(e->rule.filterkey, GFP_ATOMIC);
+ spin_unlock(&e->lock);

According to the above quick quiz, we should return with the lock held.

Quoted 4 lines

Thanks, I think you have some reason.

If my understanding is correct, the example here is to emphasize we could still access the value out of critical section but with spinlock held.

This example is intended to highlight how we can eliminate stale data.

Quoted 4 lines

In current example, we don't return e(struct audit_entry) from audit_filter_task(). So no one suppose to release the spinlock again. This looks to be a mistake.

Then the example code should return e instead. ( *key is also undefined)

If you have some time, I’d recommend [1]

[1] Using Read-Copy-Update Techniques for System V IPC in the Linux 2.5 Kernel

Quoted 38 lines

My suggestion is to release the lock after kstrdup() to make the example more intact. But with a comment to explain the purpose here.

Also I found we miss the second parameter key here.

Documentation/RCU/listRCU.rst +0 -0
index ed5c9d8c9afe..a3e7f8ff3a81 100644
@@ -334,7 +334,7 @@ If the system-call audit module were to ever need to reject stale data, one way

to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to the ``audit_entry`` structure, and modify audit_filter_task() as follows::

- static enum audit_state audit_filter_task(struct task_struct *tsk)
+ static enum audit_state audit_filter_task(struct task_struct *tsk, char **key) {
struct audit_entry *e;
enum audit_state state;

Documentation/RCU/listRCU.rst +3 -0
@@ -349,8 +349,11 @@ to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to
 return AUDIT_BUILD_CONTEXT;
 }
 rcu_read_unlock();
+ /* With spinlock held, it is ok to access 'e' out
+                                 * of critial section */
 if (state == AUDIT_STATE_RECORD)
 *key = kstrdup(e->rule.filterkey, GFP_ATOMIC);
+ spin_unlock(&e->lock);
 return state;
 }
 }

Does it make sense to you?

Signature · 2 lines
Wei Yang
Help you, Help me
author
#7 lore raw
Quoted 62 lines · Alan Huang
Quoted 61 lines · Wei Yang
Quoted 58 lines · Alan Huang
Quoted 47 lines · Boqun Feng

Hi Wei,

The change loosk good to me, thanks!

I queued the patch for futher reviews and tests with some changes in the commit log (for title formating and a bit more explanation), please see below.

Regards,
Boqun

Quoted 6 lines · Wei Yang

The example code for "Eliminating Stale Data" looks not correct:

* rcu_read_unlock() should put after kstrdup()
* spin_unlock() should be called before return

[...]

------------------>8
Subject: [PATCH] doc/RCU/listRCU: Fix an example code snippets

The example code for "Eliminating Stale Data" looks not correct:

* rcu_read_unlock() should put after kstrdup(), because otherwise entry may get freed while kstrdup() is being called.

* spin_unlock() should be called before return, otherwise the function would return with the lock of the entry held.

Hence fix these.

---
Documentation/RCU/listRCU.rst | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/RCU/listRCU.rst +0 -0
index ed5c9d8c9afe..8df50fcd69fd 100644

Documentation/RCU/listRCU.rst to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to · line 353

Quoted 7 lines
Documentation/RCU/listRCU.rst +1 -1
@@ -348,9 +348,10 @@ to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to
 rcu_read_unlock();
 return AUDIT_BUILD_CONTEXT;
 }
- rcu_read_unlock();
 if (state == AUDIT_STATE_RECORD)
 *key = kstrdup(e->rule.filterkey, GFP_ATOMIC);
+ spin_unlock(&e->lock);

According to the above quick quiz, we should return with the lock held.

Quoted 7 lines
Quoted 4 lines

Thanks, I think you have some reason.

If my understanding is correct, the example here is to emphasize we could still access the value out of critical section but with spinlock held.

This example is intended to highlight how we can eliminate stale data.

Yes, you are more accurate.

Quoted 7 lines
Quoted 4 lines

In current example, we don't return e(struct audit_entry) from audit_filter_task(). So no one suppose to release the spinlock again. This looks to be a mistake.

Then the example code should return e instead. ( *key is also undefined)

So you prefer a version with e returned?

Boqun

What's your preference?

Quoted 5 lines

If you have some time, I’d recommend [1]

[1] Using Read-Copy-Update Techniques for System V IPC in the Linux 2.5 Kernel

Thanks, would take a look.

Quoted 39 lines
Quoted 38 lines

My suggestion is to release the lock after kstrdup() to make the example more intact. But with a comment to explain the purpose here.

Also I found we miss the second parameter key here.

Documentation/RCU/listRCU.rst +0 -0
index ed5c9d8c9afe..a3e7f8ff3a81 100644
@@ -334,7 +334,7 @@ If the system-call audit module were to ever need to reject stale data, one way

to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to the ``audit_entry`` structure, and modify audit_filter_task() as follows::

- static enum audit_state audit_filter_task(struct task_struct *tsk)
+ static enum audit_state audit_filter_task(struct task_struct *tsk, char **key) {
struct audit_entry *e;
enum audit_state state;

Documentation/RCU/listRCU.rst +3 -0
@@ -349,8 +349,11 @@ to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to
 return AUDIT_BUILD_CONTEXT;
 }
 rcu_read_unlock();
+ /* With spinlock held, it is ok to access 'e' out
+                                 * of critial section */
 if (state == AUDIT_STATE_RECORD)
 *key = kstrdup(e->rule.filterkey, GFP_ATOMIC);
+ spin_unlock(&e->lock);
 return state;
 }
 }

Does it make sense to you?

Signature · 2 lines
Wei Yang
Help you, Help me
Signature · 2 lines
Wei Yang
Help you, Help me
#8 lore raw
Quoted 78 lines · Wei Yang
Quoted 62 lines · Alan Huang
Quoted 61 lines · Wei Yang
Quoted 58 lines · Alan Huang
Quoted 47 lines · Boqun Feng

Hi Wei,

The change loosk good to me, thanks!

I queued the patch for futher reviews and tests with some changes in the commit log (for title formating and a bit more explanation), please see below.

Regards,
Boqun

Quoted 6 lines · Wei Yang

The example code for "Eliminating Stale Data" looks not correct:

* rcu_read_unlock() should put after kstrdup()
* spin_unlock() should be called before return

[...]

------------------>8
Subject: [PATCH] doc/RCU/listRCU: Fix an example code snippets

The example code for "Eliminating Stale Data" looks not correct:

* rcu_read_unlock() should put after kstrdup(), because otherwise entry may get freed while kstrdup() is being called.

* spin_unlock() should be called before return, otherwise the function would return with the lock of the entry held.

Hence fix these.

---
Documentation/RCU/listRCU.rst | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/RCU/listRCU.rst +0 -0
index ed5c9d8c9afe..8df50fcd69fd 100644

Documentation/RCU/listRCU.rst to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to · line 353

Quoted 7 lines
Documentation/RCU/listRCU.rst +1 -1
@@ -348,9 +348,10 @@ to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to
 rcu_read_unlock();
 return AUDIT_BUILD_CONTEXT;
 }
- rcu_read_unlock();
 if (state == AUDIT_STATE_RECORD)
 *key = kstrdup(e->rule.filterkey, GFP_ATOMIC);
+ spin_unlock(&e->lock);

According to the above quick quiz, we should return with the lock held.

Quoted 7 lines
Quoted 4 lines

Thanks, I think you have some reason.

If my understanding is correct, the example here is to emphasize we could still access the value out of critical section but with spinlock held.

This example is intended to highlight how we can eliminate stale data.

Yes, you are more accurate.

Quoted 5 lines
Quoted 4 lines

In current example, we don't return e(struct audit_entry) from audit_filter_task(). So no one suppose to release the spinlock again. This looks to be a mistake.

Quoted 9 lines
Quoted 2 lines

Then the example code should return e instead. ( *key is also undefined)

So you prefer a version with e returned?

Boqun

What's your preference?

Yeah, I think it make more sense with e returned, and you can add some comments at the return statement like:

return e; // as long as the lock of e is held, e is valid.

, but feel free to use whatever you see fit.

Regards,
Boqun

Quoted 51 lines
Quoted 5 lines

If you have some time, I´d recommend [1]

[1] Using Read-Copy-Update Techniques for System V IPC in the Linux 2.5 Kernel

Thanks, would take a look.

Quoted 39 lines
Quoted 38 lines

My suggestion is to release the lock after kstrdup() to make the example more intact. But with a comment to explain the purpose here.

Also I found we miss the second parameter key here.

Documentation/RCU/listRCU.rst +0 -0
index ed5c9d8c9afe..a3e7f8ff3a81 100644
@@ -334,7 +334,7 @@ If the system-call audit module were to ever need to reject stale data, one way

to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to the ``audit_entry`` structure, and modify audit_filter_task() as follows::

- static enum audit_state audit_filter_task(struct task_struct *tsk)
+ static enum audit_state audit_filter_task(struct task_struct *tsk, char **key) {
struct audit_entry *e;
enum audit_state state;

Documentation/RCU/listRCU.rst +3 -0
@@ -349,8 +349,11 @@ to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to
 return AUDIT_BUILD_CONTEXT;
 }
 rcu_read_unlock();
+ /* With spinlock held, it is ok to access 'e' out
+                                 * of critial section */
 if (state == AUDIT_STATE_RECORD)
 *key = kstrdup(e->rule.filterkey, GFP_ATOMIC);
+ spin_unlock(&e->lock);
 return state;
 }
 }

Does it make sense to you?

Signature · 2 lines
Wei Yang
Help you, Help me
Signature · 2 lines
Wei Yang
Help you, Help me
author
#9 lore raw
Quoted 89 lines · Boqun Feng
Quoted 78 lines · Wei Yang
Quoted 62 lines · Alan Huang
Quoted 61 lines · Wei Yang
Quoted 58 lines · Alan Huang
Quoted 47 lines · Boqun Feng

Hi Wei,

The change loosk good to me, thanks!

I queued the patch for futher reviews and tests with some changes in the commit log (for title formating and a bit more explanation), please see below.

Regards,
Boqun

Quoted 6 lines · Wei Yang

The example code for "Eliminating Stale Data" looks not correct:

* rcu_read_unlock() should put after kstrdup()
* spin_unlock() should be called before return

[...]

------------------>8
Subject: [PATCH] doc/RCU/listRCU: Fix an example code snippets

The example code for "Eliminating Stale Data" looks not correct:

* rcu_read_unlock() should put after kstrdup(), because otherwise entry may get freed while kstrdup() is being called.

* spin_unlock() should be called before return, otherwise the function would return with the lock of the entry held.

Hence fix these.

---
Documentation/RCU/listRCU.rst | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
Documentation/RCU/listRCU.rst +0 -0
index ed5c9d8c9afe..8df50fcd69fd 100644

Documentation/RCU/listRCU.rst to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to · line 353

Quoted 7 lines
Documentation/RCU/listRCU.rst +1 -1
@@ -348,9 +348,10 @@ to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to
 rcu_read_unlock();
 return AUDIT_BUILD_CONTEXT;
 }
- rcu_read_unlock();
 if (state == AUDIT_STATE_RECORD)
 *key = kstrdup(e->rule.filterkey, GFP_ATOMIC);
+ spin_unlock(&e->lock);

According to the above quick quiz, we should return with the lock held.

Quoted 7 lines
Quoted 4 lines

Thanks, I think you have some reason.

If my understanding is correct, the example here is to emphasize we could still access the value out of critical section but with spinlock held.

This example is intended to highlight how we can eliminate stale data.

Yes, you are more accurate.

Quoted 5 lines
Quoted 4 lines

In current example, we don't return e(struct audit_entry) from audit_filter_task(). So no one suppose to release the spinlock again. This looks to be a mistake.

Quoted 9 lines
Quoted 2 lines

Then the example code should return e instead. ( *key is also undefined)

So you prefer a version with e returned?

Boqun

What's your preference?

Quoted 7 lines

Yeah, I think it make more sense with e returned, and you can add some comments at the return statement like:

return e; // as long as the lock of e is held, e is valid.

, but feel free to use whatever you see fit.

Thanks, let me prepare one.

Quoted 2 lines

Regards,
Boqun

Signature · 2 lines
Wei Yang
Help you, Help me