Skip to content

Commit 79ea7f4

Browse files
RichardWeiYangJoel Fernandes
authored andcommitted
doc/RCU/listRCU: refine example code for eliminating stale data
This patch adjust the example code with following two purpose: * reduce the confusion on not releasing e->lock * emphasize e is valid and not stale with e->lock held Signed-off-by: Wei Yang <[email protected]> CC: Boqun Feng <[email protected]> CC: Alan Huang <[email protected]> Reviewed-by: Alan Huang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Boqun Feng <[email protected]> Signed-off-by: Joel Fernandes <[email protected]>
1 parent 1708bf2 commit 79ea7f4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Documentation/RCU/listRCU.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ If the system-call audit module were to ever need to reject stale data, one way
334334
to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to the
335335
``audit_entry`` structure, and modify audit_filter_task() as follows::
336336

337-
static enum audit_state audit_filter_task(struct task_struct *tsk)
337+
static struct audit_entry *audit_filter_task(struct task_struct *tsk, char **key)
338338
{
339339
struct audit_entry *e;
340340
enum audit_state state;
@@ -346,16 +346,18 @@ to accomplish this would be to add a ``deleted`` flag and a ``lock`` spinlock to
346346
if (e->deleted) {
347347
spin_unlock(&e->lock);
348348
rcu_read_unlock();
349-
return AUDIT_BUILD_CONTEXT;
349+
return NULL;
350350
}
351351
rcu_read_unlock();
352352
if (state == AUDIT_STATE_RECORD)
353353
*key = kstrdup(e->rule.filterkey, GFP_ATOMIC);
354-
return state;
354+
/* As long as e->lock is held, e is valid and
355+
* its value is not stale */
356+
return e;
355357
}
356358
}
357359
rcu_read_unlock();
358-
return AUDIT_BUILD_CONTEXT;
360+
return NULL;
359361
}
360362

361363
The ``audit_del_rule()`` function would need to set the ``deleted`` flag under the

0 commit comments

Comments
 (0)