linux-audit.redhat.com archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] audit: Use list_move instead of list_del/list_add
@ 2021-06-08  3:11 Baokun Li
  2021-06-08 15:02 ` Richard Guy Briggs
  2021-06-09  2:19 ` Paul Moore
  0 siblings, 2 replies; 3+ messages in thread
From: Baokun Li @ 2021-06-08  3:11 UTC (permalink / raw)
  To: linux-kernel, Paul Moore, Eric Paris
  Cc: Hulk Robot, kernel-janitors, yuehaibing, yangjihong1,
	linux-audit, libaokun1, yukuai3, weiyongjun1

Using list_move() instead of list_del() + list_add().

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Baokun Li <libaokun1@huawei.com>
---
 kernel/audit_tree.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
index 6c91902f4f45..b2be4e978ba3 100644
--- a/kernel/audit_tree.c
+++ b/kernel/audit_tree.c
@@ -689,8 +689,7 @@ void audit_trim_trees(void)
 
 		tree = container_of(cursor.next, struct audit_tree, list);
 		get_tree(tree);
-		list_del(&cursor);
-		list_add(&cursor, &tree->list);
+		list_move(&cursor, &tree->list);
 		mutex_unlock(&audit_filter_mutex);
 
 		err = kern_path(tree->pathname, 0, &path);
@@ -899,8 +898,7 @@ int audit_tag_tree(char *old, char *new)
 
 		tree = container_of(cursor.next, struct audit_tree, list);
 		get_tree(tree);
-		list_del(&cursor);
-		list_add(&cursor, &tree->list);
+		list_move(&cursor, &tree->list);
 		mutex_unlock(&audit_filter_mutex);
 
 		err = kern_path(tree->pathname, 0, &path2);
@@ -925,8 +923,7 @@ int audit_tag_tree(char *old, char *new)
 		mutex_lock(&audit_filter_mutex);
 		spin_lock(&hash_lock);
 		if (!tree->goner) {
-			list_del(&tree->list);
-			list_add(&tree->list, &tree_list);
+			list_move(&tree->list, &tree_list);
 		}
 		spin_unlock(&hash_lock);
 		put_tree(tree);
@@ -937,8 +934,7 @@ int audit_tag_tree(char *old, char *new)
 
 		tree = container_of(barrier.prev, struct audit_tree, list);
 		get_tree(tree);
-		list_del(&tree->list);
-		list_add(&tree->list, &barrier);
+		list_move(&tree->list, &barrier);
 		mutex_unlock(&audit_filter_mutex);
 
 		if (!failed) {


--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] audit: Use list_move instead of list_del/list_add
  2021-06-08  3:11 [PATCH -next] audit: Use list_move instead of list_del/list_add Baokun Li
@ 2021-06-08 15:02 ` Richard Guy Briggs
  2021-06-09  2:19 ` Paul Moore
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Guy Briggs @ 2021-06-08 15:02 UTC (permalink / raw)
  To: Baokun Li
  Cc: yangjihong1, kernel-janitors, yuehaibing, linux-kernel,
	Eric Paris, Hulk Robot, linux-audit, weiyongjun1, yukuai3

On 2021-06-08 11:11, Baokun Li wrote:
> Using list_move() instead of list_del() + list_add().

This should be slightly more efficient since there is no need to poison
the pointers.

> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Baokun Li <libaokun1@huawei.com>

Acked-by: Richard Guy Briggs <rgb@redhat.com>

> ---
>  kernel/audit_tree.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
> index 6c91902f4f45..b2be4e978ba3 100644
> --- a/kernel/audit_tree.c
> +++ b/kernel/audit_tree.c
> @@ -689,8 +689,7 @@ void audit_trim_trees(void)
>  
>  		tree = container_of(cursor.next, struct audit_tree, list);
>  		get_tree(tree);
> -		list_del(&cursor);
> -		list_add(&cursor, &tree->list);
> +		list_move(&cursor, &tree->list);
>  		mutex_unlock(&audit_filter_mutex);
>  
>  		err = kern_path(tree->pathname, 0, &path);
> @@ -899,8 +898,7 @@ int audit_tag_tree(char *old, char *new)
>  
>  		tree = container_of(cursor.next, struct audit_tree, list);
>  		get_tree(tree);
> -		list_del(&cursor);
> -		list_add(&cursor, &tree->list);
> +		list_move(&cursor, &tree->list);
>  		mutex_unlock(&audit_filter_mutex);
>  
>  		err = kern_path(tree->pathname, 0, &path2);
> @@ -925,8 +923,7 @@ int audit_tag_tree(char *old, char *new)
>  		mutex_lock(&audit_filter_mutex);
>  		spin_lock(&hash_lock);
>  		if (!tree->goner) {
> -			list_del(&tree->list);
> -			list_add(&tree->list, &tree_list);
> +			list_move(&tree->list, &tree_list);
>  		}
>  		spin_unlock(&hash_lock);
>  		put_tree(tree);
> @@ -937,8 +934,7 @@ int audit_tag_tree(char *old, char *new)
>  
>  		tree = container_of(barrier.prev, struct audit_tree, list);
>  		get_tree(tree);
> -		list_del(&tree->list);
> -		list_add(&tree->list, &barrier);
> +		list_move(&tree->list, &barrier);
>  		mutex_unlock(&audit_filter_mutex);
>  
>  		if (!failed) {
> 
> 
> --
> Linux-audit mailing list
> Linux-audit@redhat.com
> https://listman.redhat.com/mailman/listinfo/linux-audit

- RGB

--
Richard Guy Briggs <rgb@redhat.com>
Sr. S/W Engineer, Kernel Security, Base Operating Systems
Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635

--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] audit: Use list_move instead of list_del/list_add
  2021-06-08  3:11 [PATCH -next] audit: Use list_move instead of list_del/list_add Baokun Li
  2021-06-08 15:02 ` Richard Guy Briggs
@ 2021-06-09  2:19 ` Paul Moore
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Moore @ 2021-06-09  2:19 UTC (permalink / raw)
  To: Baokun Li
  Cc: Hulk Robot, kernel-janitors, yuehaibing, linux-kernel,
	Eric Paris, yangjihong1, linux-audit, weiyongjun1, yukuai3

On Mon, Jun 7, 2021 at 11:03 PM Baokun Li <libaokun1@huawei.com> wrote:
>
> Using list_move() instead of list_del() + list_add().
>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Baokun Li <libaokun1@huawei.com>
> ---
>  kernel/audit_tree.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)

Merged into audit/next, thank you.

-- 
paul moore
www.paul-moore.com

--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-09  2:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08  3:11 [PATCH -next] audit: Use list_move instead of list_del/list_add Baokun Li
2021-06-08 15:02 ` Richard Guy Briggs
2021-06-09  2:19 ` Paul Moore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).