diff mbox series

[2/5] mm/huge_memory.c: use page->deferred_list

Message ID 20210427133214.2270207-3-linmiaohe@huawei.com (mailing list archive)
State New, archived
Headers show
Series Cleanup and fixup for huge_memory | expand

Commit Message

Miaohe Lin April 27, 2021, 1:32 p.m. UTC
Now that we can represent the location of ->deferred_list instead of
->mapping + ->index, make use of it to improve readability.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/huge_memory.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Yang Shi April 27, 2021, 8:46 p.m. UTC | #1
On Tue, Apr 27, 2021 at 6:32 AM Miaohe Lin <linmiaohe@huawei.com> wrote:
>
> Now that we can represent the location of ->deferred_list instead of
> ->mapping + ->index, make use of it to improve readability.

Reviewed-by: Yang Shi <shy828301@gmail.com>

>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  mm/huge_memory.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 63ed6b25deaa..76ca1eb2a223 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -2868,7 +2868,7 @@ static unsigned long deferred_split_scan(struct shrinker *shrink,
>         spin_lock_irqsave(&ds_queue->split_queue_lock, flags);
>         /* Take pin on all head pages to avoid freeing them under us */
>         list_for_each_safe(pos, next, &ds_queue->split_queue) {
> -               page = list_entry((void *)pos, struct page, mapping);
> +               page = list_entry((void *)pos, struct page, deferred_list);
>                 page = compound_head(page);
>                 if (get_page_unless_zero(page)) {
>                         list_move(page_deferred_list(page), &list);
> @@ -2883,7 +2883,7 @@ static unsigned long deferred_split_scan(struct shrinker *shrink,
>         spin_unlock_irqrestore(&ds_queue->split_queue_lock, flags);
>
>         list_for_each_safe(pos, next, &list) {
> -               page = list_entry((void *)pos, struct page, mapping);
> +               page = list_entry((void *)pos, struct page, deferred_list);
>                 if (!trylock_page(page))
>                         goto next;
>                 /* split_huge_page() removes page from list on success */
> --
> 2.23.0
>
>
Anshuman Khandual April 28, 2021, 3:07 a.m. UTC | #2
On 4/27/21 7:02 PM, Miaohe Lin wrote:
> Now that we can represent the location of ->deferred_list instead of
> ->mapping + ->index, make use of it to improve readability.

Could you please explain how page->deferred_list and page->mapping
are interchangeable here ?

> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  mm/huge_memory.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index 63ed6b25deaa..76ca1eb2a223 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -2868,7 +2868,7 @@ static unsigned long deferred_split_scan(struct shrinker *shrink,
>  	spin_lock_irqsave(&ds_queue->split_queue_lock, flags);
>  	/* Take pin on all head pages to avoid freeing them under us */
>  	list_for_each_safe(pos, next, &ds_queue->split_queue) {
> -		page = list_entry((void *)pos, struct page, mapping);
> +		page = list_entry((void *)pos, struct page, deferred_list);
>  		page = compound_head(page);
>  		if (get_page_unless_zero(page)) {
>  			list_move(page_deferred_list(page), &list);
> @@ -2883,7 +2883,7 @@ static unsigned long deferred_split_scan(struct shrinker *shrink,
>  	spin_unlock_irqrestore(&ds_queue->split_queue_lock, flags);
>  
>  	list_for_each_safe(pos, next, &list) {
> -		page = list_entry((void *)pos, struct page, mapping);
> +		page = list_entry((void *)pos, struct page, deferred_list);
>  		if (!trylock_page(page))
>  			goto next;
>  		/* split_huge_page() removes page from list on success */
>
Miaohe Lin April 28, 2021, 8:23 a.m. UTC | #3
On 2021/4/28 11:07, Anshuman Khandual wrote:
> 
> On 4/27/21 7:02 PM, Miaohe Lin wrote:
>> Now that we can represent the location of ->deferred_list instead of
>> ->mapping + ->index, make use of it to improve readability.
> 
> Could you please explain how page->deferred_list and page->mapping
> are interchangeable here ?

It's because there is a union in struct page:

union {
		struct {
			struct list_head lru;
			struct address_space *mapping;
			pgoff_t index;
			unsigned long private;
		};
		struct {
			unsigned long _compound_pad_1;
			atomic_t hpage_pinned_refcount;
			struct list_head *deferred_list*;
		};
};

And initially there is no deferred_list and it's added via commit 66a6ffd2af42 ("mm: combine first
three unions in struct page"). Also commit fa3015b7eed5 ("mm: use page->deferred_list") did the similar
cleanup. Am I expected to add these to the commit log?

Many thanks.

> 
>>
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>> ---
>>  mm/huge_memory.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>> index 63ed6b25deaa..76ca1eb2a223 100644
>> --- a/mm/huge_memory.c
>> +++ b/mm/huge_memory.c
>> @@ -2868,7 +2868,7 @@ static unsigned long deferred_split_scan(struct shrinker *shrink,
>>  	spin_lock_irqsave(&ds_queue->split_queue_lock, flags);
>>  	/* Take pin on all head pages to avoid freeing them under us */
>>  	list_for_each_safe(pos, next, &ds_queue->split_queue) {
>> -		page = list_entry((void *)pos, struct page, mapping);
>> +		page = list_entry((void *)pos, struct page, deferred_list);
>>  		page = compound_head(page);
>>  		if (get_page_unless_zero(page)) {
>>  			list_move(page_deferred_list(page), &list);
>> @@ -2883,7 +2883,7 @@ static unsigned long deferred_split_scan(struct shrinker *shrink,
>>  	spin_unlock_irqrestore(&ds_queue->split_queue_lock, flags);
>>  
>>  	list_for_each_safe(pos, next, &list) {
>> -		page = list_entry((void *)pos, struct page, mapping);
>> +		page = list_entry((void *)pos, struct page, deferred_list);
>>  		if (!trylock_page(page))
>>  			goto next;
>>  		/* split_huge_page() removes page from list on success */
>>
> .
>
diff mbox series

Patch

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 63ed6b25deaa..76ca1eb2a223 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2868,7 +2868,7 @@  static unsigned long deferred_split_scan(struct shrinker *shrink,
 	spin_lock_irqsave(&ds_queue->split_queue_lock, flags);
 	/* Take pin on all head pages to avoid freeing them under us */
 	list_for_each_safe(pos, next, &ds_queue->split_queue) {
-		page = list_entry((void *)pos, struct page, mapping);
+		page = list_entry((void *)pos, struct page, deferred_list);
 		page = compound_head(page);
 		if (get_page_unless_zero(page)) {
 			list_move(page_deferred_list(page), &list);
@@ -2883,7 +2883,7 @@  static unsigned long deferred_split_scan(struct shrinker *shrink,
 	spin_unlock_irqrestore(&ds_queue->split_queue_lock, flags);
 
 	list_for_each_safe(pos, next, &list) {
-		page = list_entry((void *)pos, struct page, mapping);
+		page = list_entry((void *)pos, struct page, deferred_list);
 		if (!trylock_page(page))
 			goto next;
 		/* split_huge_page() removes page from list on success */