linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jaewon Kim <jaewon31.kim@samsung.com>
To: Vlastimil Babka <vbabka@suse.cz>, "sj@kernel.org" <sj@kernel.org>,
	"minchan@kernel.org" <minchan@kernel.org>,
	"kaleshsingh@google.com" <kaleshsingh@google.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"jaewon31.kim@gmail.com" <jaewon31.kim@gmail.com>
Subject: RE: [PATCH] vmscan: add a vmscan event for reclaim_pages
Date: Fri, 11 Oct 2024 20:39:19 +0900	[thread overview]
Message-ID: <20241011113919epcms1p4d6ae59bece34d4a930a5db31a2f00173@epcms1p4> (raw)
In-Reply-To: <dd7e07ba-acaf-4f93-93e0-ec2d98a4da55@suse.cz>

>On 10/11/24 10:25 AM, Jaewon Kim wrote:
>> Hi
>> 
>> Thank you for your coment. Yes if it is allowed, I can do that way. When
>> I checked, the following functions should do the memset().
>> 
>> reclaim_clean_pages_from_list
>> shrink_inactive_list
>> reclaim_folio_list
>> evict_folios      
>> 
>> Actually I was planning to move trace_mm_vmscan_reclaim_pages into
>> reclaim_folio_list so that we don't have to sum up and we may be able
>> to print node number, too. As we will see log for each node, if we'd
>> like to know the sum, that would be the post parser's job.
>> 
>> Option 1. No change on memset, but print on each node.
>> mm_vmscan_reclaim_pages: nid=0 nr_scanned=112 nr_reclaimed=112 nr_dirty=0 nr_writeback=0 nr_congested=0 nr_immediate=0 nr_activate_anon=0 nr_activate_file=0 nr_ref_keep=0 nr_unmap_fail=0
>> mm_vmscan_reclaim_pages: nid=1 ...
>> mm_vmscan_reclaim_pages: nid=2 ...
>
>I see. Note it processes a list that might be from multiple nodes and
>will group consecutive pages from the same node, but if pages come from
>random nodes, the nodes will repeat and there might be many trace
>events, each for few pages only.
>
>Guess it depends on the workload if it has its pages from the same node.
>Maybe you can try and see how noisy it is in practice?
>

Hi

Actually my Android test device has only one node, so I cannot test several
nodes cases. But it shows quite many of mm_vmscan_reclaim_pages log when I do
the Android shmem based call to reclaim_pages. I have to do the post parsing
or make a fancy ftrace hist command.

I think madvise and damon, which are the other caller to reclaim_pages, are not
interested in showing trace log for each node.

I'm just worried changing policy, memset(0) is the caller responsibility,
could be error-prone if we forget someday. So if possible, let me take the
option 1.

To show a clean code, let me submit the v2 patch.
Thank you.

>> Option 2. Change on memset, but we don't care the stat from each node.
>> mm_vmscan_reclaim_pages: nr_scanned=35 nr_reclaimed=35 nr_dirty=0 nr_writeback=0 nr_congested=0 nr_immediate=0 nr_activate_anon=0 nr_activate_file=0 nr_ref_keep=0 nr_unmap_fail=0
>> 
>> Would you give me you preference between the two options?
>>                                                         
>> Thank you
>> Jaewon Kim
>>                                                                                                                                                      
>>>                                                                                                                                                                                          
>>> AFAICS shrink_folio_list() only cares about these fields:                                                                                                                                 
>>>                                                                                                                                                                                          
>>> pgactivate = stat->nr_activate[0] + stat->nr_activate[1];                                                                                                                                 
>>>                                                                                                                                                                                          
>>> in order to do                                                                                                                                                                            
>>>                                                                                                                                                                                          
>>> count_vm_events(PGACTIVATE, pgactivate);                                                                                                                                                  
>>>                                                                                                                                                                                          
>>> Which could be adjusted to deal with accumulating stat - i.e. take an                                                                                                                     
>>> initial sum of the fields in stat and subtract from the final sum to get                                                                                                                  
>>> the delta.                                                                                                                                                                                
>>>                                                                                                                                                                                         
>>>>  unsigned long reclaim_pages(struct list_head *folio_list)                                                                                                                              
>>>>  {                                                                                                                                                                                      
>>>>  	int nid;                                                                                                                                                                              
>>>> +	unsigned int nr_scanned = 0;                                                                                                                                                          
>>>>  	unsigned int nr_reclaimed = 0;                                                                                                                                                        
>>>>  	LIST_HEAD(node_folio_list);                                                                                                                                                           
>>>>  	unsigned int noreclaim_flag;                                                                                                                                                          
>>>> +	struct reclaim_stat stat_total, stat_one;                                                                                                                                             
>>>>                                                                                                                                                                                         
>>>>  	if (list_empty(folio_list))                                                                                                                                                           
>>>>  		return nr_reclaimed;                                                                                                                                                                
>>>>                                                                                                                                                                                         
>>>> +	memset(&stat_total, 0, sizeof(stat_total));                                                                                                                                           
>>>>  	noreclaim_flag = memalloc_noreclaim_save();                                                                                                                                           
>>>>                                                                                                                                                                                         
>>>>  	nid = folio_nid(lru_to_folio(folio_list));                                                                                                                                            
>>>> @@ -2168,14 +2192,20 @@ unsigned long reclaim_pages(struct list_head *folio_list)                                                                                                       
>>>>  		if (nid == folio_nid(folio)) {                                                                                                                                                      
>>>>  			folio_clear_active(folio);                                                                                                                                                        
>>>>  			list_move(&folio->lru, &node_folio_list);                                                                                                                                         
>>>> +			nr_scanned += folio_nr_pages(folio);                                                                                                                                              
>>>>  			continue;                                                                                                                                                                         
>>>>  		}                                                                                                                                                                                   
>>>>                                                                                                                                                                                         
>>>> -		nr_reclaimed += reclaim_folio_list(&node_folio_list, NODE_DATA(nid));                                                                                                               
>>>> +		nr_reclaimed += reclaim_folio_list(&node_folio_list,                                                                                                                                
>>>> +						   NODE_DATA(nid), &stat_one);                                                                                                                                              
>>>> +		reclaim_stat_add(&stat_one, &stat_total);                                                                                                                                           
>>>>  		nid = folio_nid(lru_to_folio(folio_list));                                                                                                                                          
>>>>  	} while (!list_empty(folio_list));                                                                                                                                                    
>>>>                                                                                                                                                                                         
>>>> -	nr_reclaimed += reclaim_folio_list(&node_folio_list, NODE_DATA(nid));                                                                                                                 
>>>> +	nr_reclaimed += reclaim_folio_list(&node_folio_list, NODE_DATA(nid),                                                                                                                  
>>>> +					   &stat_one);                                                                                                                                                                
>>>> +	reclaim_stat_add(&stat_one, &stat_total);                                                                                                                                             
>>>> +	trace_mm_vmscan_reclaim_pages(nr_scanned, nr_reclaimed, &stat_total);                                                                                                                 
>>>>                                                                                                                                                                                         
>>>>  	memalloc_noreclaim_restore(noreclaim_flag);                                                                                                                                           
>>>> 


  parent reply	other threads:[~2024-10-11 11:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20241009093133epcas1p39b770ebcc6d2d78cad2f9a522bc6f179@epcas1p3.samsung.com>
2024-10-09  9:31 ` Jaewon Kim
2024-10-09 20:49   ` Andrew Morton
     [not found]   ` <CGME20241009093133epcas1p39b770ebcc6d2d78cad2f9a522bc6f179@epcms1p6>
2024-10-09 23:53     ` Jaewon Kim
2024-10-11  8:25     ` Jaewon Kim
2024-10-11  8:55       ` Vlastimil Babka
     [not found]       ` <CGME20241009093133epcas1p39b770ebcc6d2d78cad2f9a522bc6f179@epcms1p4>
2024-10-11 11:39         ` Jaewon Kim [this message]
2024-10-10  8:28   ` Vlastimil Babka
     [not found]   ` <CGME20241009093133epcas1p39b770ebcc6d2d78cad2f9a522bc6f179@epcms1p1>
2024-10-11  8:22     ` 김재원

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241011113919epcms1p4d6ae59bece34d4a930a5db31a2f00173@epcms1p4 \
    --to=jaewon31.kim@samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=jaewon31.kim@gmail.com \
    --cc=kaleshsingh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=sj@kernel.org \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox