* [PATCH -next] mm: make use of the helper macro LIST_HEAD()
@ 2024-08-27 1:57 Hongbo Li
2024-08-27 19:22 ` Uladzislau Rezki
0 siblings, 1 reply; 3+ messages in thread
From: Hongbo Li @ 2024-08-27 1:57 UTC (permalink / raw)
To: akpm, urezki, hch; +Cc: linux-mm, lihongbo22
list_head can be initialized automatically with LIST_HEAD()
instead of calling INIT_LIST_HEAD(). Here we can simplify
the code.
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
mm/vmalloc.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 3f9b6bd707d2..3f7b38481fcc 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2141,13 +2141,11 @@ decay_va_pool_node(struct vmap_node *vn, bool full_decay)
INIT_LIST_HEAD(&decay_list);
for (i = 0; i < MAX_VA_SIZE_PAGES; i++) {
- struct list_head tmp_list;
+ LIST_HEAD(tmp_list);
if (list_empty(&vn->pool[i].head))
continue;
- INIT_LIST_HEAD(&tmp_list);
-
/* Detach the pool, so no-one can access it. */
spin_lock(&vn->pool_lock);
list_replace_init(&vn->pool[i].head, &tmp_list);
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -next] mm: make use of the helper macro LIST_HEAD()
2024-08-27 1:57 [PATCH -next] mm: make use of the helper macro LIST_HEAD() Hongbo Li
@ 2024-08-27 19:22 ` Uladzislau Rezki
2024-08-28 1:27 ` Hongbo Li
0 siblings, 1 reply; 3+ messages in thread
From: Uladzislau Rezki @ 2024-08-27 19:22 UTC (permalink / raw)
To: Hongbo Li; +Cc: akpm, urezki, hch, linux-mm
On Tue, Aug 27, 2024 at 09:57:24AM +0800, Hongbo Li wrote:
> list_head can be initialized automatically with LIST_HEAD()
> instead of calling INIT_LIST_HEAD(). Here we can simplify
> the code.
>
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> ---
> mm/vmalloc.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 3f9b6bd707d2..3f7b38481fcc 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -2141,13 +2141,11 @@ decay_va_pool_node(struct vmap_node *vn, bool full_decay)
> INIT_LIST_HEAD(&decay_list);
>
> for (i = 0; i < MAX_VA_SIZE_PAGES; i++) {
> - struct list_head tmp_list;
> + LIST_HEAD(tmp_list);
>
> if (list_empty(&vn->pool[i].head))
> continue;
>
> - INIT_LIST_HEAD(&tmp_list);
> -
> /* Detach the pool, so no-one can access it. */
> spin_lock(&vn->pool_lock);
> list_replace_init(&vn->pool[i].head, &tmp_list);
> --
> 2.34.1
>
Maybe extend it to:
<snip>
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 57862865e808..e9c6f29a46ad 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2131,23 +2131,18 @@ reclaim_list_global(struct list_head *head)
static void
decay_va_pool_node(struct vmap_node *vn, bool full_decay)
{
+ struct rb_root decay_root = RB_ROOT;
+ LIST_HEAD(decay_list);
struct vmap_area *va, *nva;
- struct list_head decay_list;
- struct rb_root decay_root;
unsigned long n_decay;
int i;
- decay_root = RB_ROOT;
- INIT_LIST_HEAD(&decay_list);
-
for (i = 0; i < MAX_VA_SIZE_PAGES; i++) {
- struct list_head tmp_list;
+ LIST_HEAD(tmp_list);
if (list_empty(&vn->pool[i].head))
continue;
- INIT_LIST_HEAD(&tmp_list);
-
/* Detach the pool, so no-one can access it. */
spin_lock(&vn->pool_lock);
list_replace_init(&vn->pool[i].head, &tmp_list);
<snip>
?
--
Uladzislau Rezki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -next] mm: make use of the helper macro LIST_HEAD()
2024-08-27 19:22 ` Uladzislau Rezki
@ 2024-08-28 1:27 ` Hongbo Li
0 siblings, 0 replies; 3+ messages in thread
From: Hongbo Li @ 2024-08-28 1:27 UTC (permalink / raw)
To: Uladzislau Rezki; +Cc: akpm, hch, linux-mm
On 2024/8/28 3:22, Uladzislau Rezki wrote:
> On Tue, Aug 27, 2024 at 09:57:24AM +0800, Hongbo Li wrote:
>> list_head can be initialized automatically with LIST_HEAD()
>> instead of calling INIT_LIST_HEAD(). Here we can simplify
>> the code.
>>
>> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
>> ---
>> mm/vmalloc.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
>> index 3f9b6bd707d2..3f7b38481fcc 100644
>> --- a/mm/vmalloc.c
>> +++ b/mm/vmalloc.c
>> @@ -2141,13 +2141,11 @@ decay_va_pool_node(struct vmap_node *vn, bool full_decay)
>> INIT_LIST_HEAD(&decay_list);
>>
>> for (i = 0; i < MAX_VA_SIZE_PAGES; i++) {
>> - struct list_head tmp_list;
>> + LIST_HEAD(tmp_list);
>>
>> if (list_empty(&vn->pool[i].head))
>> continue;
>>
>> - INIT_LIST_HEAD(&tmp_list);
>> -
>> /* Detach the pool, so no-one can access it. */
>> spin_lock(&vn->pool_lock);
>> list_replace_init(&vn->pool[i].head, &tmp_list);
>> --
>> 2.34.1
>>
> Maybe extend it to:
>
> <snip>
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 57862865e808..e9c6f29a46ad 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -2131,23 +2131,18 @@ reclaim_list_global(struct list_head *head)
> static void
> decay_va_pool_node(struct vmap_node *vn, bool full_decay)
> {
> + struct rb_root decay_root = RB_ROOT;
> + LIST_HEAD(decay_list);
yeah, seems reasonable, and thank you!
Thanks,
Hongbo
> struct vmap_area *va, *nva;
> - struct list_head decay_list;
> - struct rb_root decay_root;
> unsigned long n_decay;
> int i;
>
> - decay_root = RB_ROOT;
> - INIT_LIST_HEAD(&decay_list);
> -
> for (i = 0; i < MAX_VA_SIZE_PAGES; i++) {
> - struct list_head tmp_list;
> + LIST_HEAD(tmp_list);
>
> if (list_empty(&vn->pool[i].head))
> continue;
>
> - INIT_LIST_HEAD(&tmp_list);
> -
> /* Detach the pool, so no-one can access it. */
> spin_lock(&vn->pool_lock);
> list_replace_init(&vn->pool[i].head, &tmp_list);
> <snip>
>
> ?
>
> --
> Uladzislau Rezki
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-08-28 1:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-27 1:57 [PATCH -next] mm: make use of the helper macro LIST_HEAD() Hongbo Li
2024-08-27 19:22 ` Uladzislau Rezki
2024-08-28 1:27 ` Hongbo Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox