~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/mm/page_owner.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/mm/page_owner.rst (Version linux-6.12-rc7) and /Documentation/mm/page_owner.rst (Version linux-5.9.16)


  1 ==============================================    
  2 page owner: Tracking about who allocated each     
  3 ==============================================    
  4                                                   
  5 Introduction                                      
  6 ============                                      
  7                                                   
  8 page owner is for the tracking about who alloc    
  9 It can be used to debug memory leak or to find    
 10 When allocation happens, information about all    
 11 and order of pages is stored into certain stor    
 12 When we need to know about status of all pages    
 13 this information.                                 
 14                                                   
 15 Although we already have tracepoint for tracin    
 16 using it for analyzing who allocate each page     
 17 to enlarge the trace buffer for preventing ove    
 18 program launched. And, launched program contin    
 19 buffer for later analysis and it would change     
 20 possibility rather than just keeping it in mem    
 21                                                   
 22 page owner can also be used for various purpos    
 23 fragmentation statistics can be obtained throu    
 24 each page. It is already implemented and activ    
 25 enabled. Other usages are more than welcome.      
 26                                                   
 27 It can also be used to show all the stacks and    
 28 allocated base pages, which gives us a quick o    
 29 is going without the need to screen through al    
 30 allocation and free operation.                    
 31                                                   
 32 page owner is disabled by default. So, if you'    
 33 to add "page_owner=on" to your boot cmdline. I    
 34 with page owner and page owner is disabled in     
 35 boot option, runtime overhead is marginal. If     
 36 doesn't require memory to store owner informat    
 37 memory overhead. And, page owner inserts just     
 38 the page allocator hotpath and if not enabled,    
 39 like as the kernel without page owner. These t    
 40 not affect to allocation performance, especial    
 41 label patching functionality is available. Fol    
 42 size change due to this facility.                 
 43                                                   
 44 Although enabling page owner increases kernel     
 45 most of this code is outside page allocator an    
 46 the kernel with page owner and turning it on i    
 47 option to debug kernel memory problem.            
 48                                                   
 49 There is one notice that is caused by implemen    
 50 stores information into the memory from struct    
 51 is initialized some time later than that page     
 52 memory system, so, until initialization, many     
 53 they would have no owner information. To fix i    
 54 pages are investigated and marked as allocated    
 55 Although it doesn't mean that they have the ri    
 56 at least, we can tell whether the page is allo    
 57 more accurately. On 2GB memory x86-64 VM box,     
 58 are caught and marked, although they are mostl    
 59 page extension feature. Anyway, after that, no    
 60 un-tracking state.                                
 61                                                   
 62 Usage                                             
 63 =====                                             
 64                                                   
 65 1) Build user-space helper::                      
 66                                                   
 67         cd tools/mm                               
 68         make page_owner_sort                      
 69                                                   
 70 2) Enable page owner: add "page_owner=on" to b    
 71                                                   
 72 3) Do the job that you want to debug.             
 73                                                   
 74 4) Analyze information from page owner::          
 75                                                   
 76         cat /sys/kernel/debug/page_owner_stack    
 77         cat stacks.txt                            
 78          post_alloc_hook+0x177/0x1a0              
 79          get_page_from_freelist+0xd01/0xd80       
 80          __alloc_pages+0x39e/0x7e0                
 81          allocate_slab+0xbc/0x3f0                 
 82          ___slab_alloc+0x528/0x8a0                
 83          kmem_cache_alloc+0x224/0x3b0             
 84          sk_prot_alloc+0x58/0x1a0                 
 85          sk_alloc+0x32/0x4f0                      
 86          inet_create+0x427/0xb50                  
 87          __sock_create+0x2e4/0x650                
 88          inet_ctl_sock_create+0x30/0x180          
 89          igmp_net_init+0xc1/0x130                 
 90          ops_init+0x167/0x410                     
 91          setup_net+0x304/0xa60                    
 92          copy_net_ns+0x29b/0x4a0                  
 93          create_new_namespaces+0x4a1/0x820        
 94         nr_base_pages: 16                         
 95         ...                                       
 96         ...                                       
 97         echo 7000 > /sys/kernel/debug/page_own    
 98         cat /sys/kernel/debug/page_owner_stack    
 99         cat stacks_7000.txt                       
100          post_alloc_hook+0x177/0x1a0              
101          get_page_from_freelist+0xd01/0xd80       
102          __alloc_pages+0x39e/0x7e0                
103          alloc_pages_mpol+0x22e/0x490             
104          folio_alloc+0xd5/0x110                   
105          filemap_alloc_folio+0x78/0x230           
106          page_cache_ra_order+0x287/0x6f0          
107          filemap_get_pages+0x517/0x1160           
108          filemap_read+0x304/0x9f0                 
109          xfs_file_buffered_read+0xe6/0x1d0 [xf    
110          xfs_file_read_iter+0x1f0/0x380 [xfs]     
111          __kernel_read+0x3b9/0x730                
112          kernel_read_file+0x309/0x4d0             
113          __do_sys_finit_module+0x381/0x730        
114          do_syscall_64+0x8d/0x150                 
115          entry_SYSCALL_64_after_hwframe+0x62/0    
116         nr_base_pages: 20824                      
117         ...                                       
118                                                   
119         cat /sys/kernel/debug/page_owner > pag    
120         ./page_owner_sort page_owner_full.txt     
121                                                   
122    The general output of ``page_owner_full.txt    
123                                                   
124         Page allocated via order XXX, ...         
125         PFN XXX ...                               
126         // Detailed stack                         
127                                                   
128         Page allocated via order XXX, ...         
129         PFN XXX ...                               
130         // Detailed stack                         
131     By default, it will do full pfn dump, to s    
132     page_owner supports fseek.                    
133                                                   
134     FILE *fp = fopen("/sys/kernel/debug/page_o    
135     fseek(fp, pfn_start, SEEK_SET);               
136                                                   
137    The ``page_owner_sort`` tool ignores ``PFN`    
138    in buf, uses regexp to extract the page ord    
139    and pages of buf, and finally sorts them ac    
140                                                   
141    See the result about who allocated each pag    
142    in the ``sorted_page_owner.txt``. General o    
143                                                   
144         XXX times, XXX pages:                     
145         Page allocated via order XXX, ...         
146         // Detailed stack                         
147                                                   
148    By default, ``page_owner_sort`` is sorted a    
149    If you want to sort by the page nums of buf    
150    The detailed parameters are:                   
151                                                   
152    fundamental function::                         
153                                                   
154         Sort:                                     
155                 -a              Sort by memory    
156                 -m              Sort by total     
157                 -p              Sort by pid.      
158                 -P              Sort by tgid.     
159                 -n              Sort by task c    
160                 -r              Sort by memory    
161                 -s              Sort by stack     
162                 -t              Sort by times     
163                 --sort <order>  Specify sortin    
164                                 Choose a key f    
165                                 optional since    
166                                 order. Mixed u    
167                                                   
168                 Examples:                         
169                                 ./page_owner_s    
170                                 ./page_owner_s    
171                                                   
172    additional function::                          
173                                                   
174         Cull:                                     
175                 --cull <rules>                    
176                                 Specify cullin    
177                                 multi-letter k    
178                                                   
179                 <rules> is a single argument i    
180                 which offers a way to specify     
181                 keywords are described in the     
182                 <rules> can be specified by th    
183                 the STANDARD SORT KEYS section    
184                 complete-form of keys is allow    
185                                                   
186                 Examples:                         
187                                 ./page_owner_s    
188                                 ./page_owner_s    
189                                 ./page_owner_s    
190                                                   
191         Filter:                                   
192                 -f              Filter out the    
193                                                   
194         Select:                                   
195                 --pid <pidlist>         Select    
196                                         number    
197                 --tgid <tgidlist>       Select    
198                                         group     
199                 --name <cmdlist>        Select    
200                                         task c    
201                                                   
202                 <pidlist>, <tgidlist>, <cmdlis    
203                 which offers a way to specify     
204                                                   
205                                                   
206                 Examples:                         
207                                 ./page_owner_s    
208                                 ./page_owner_s    
209                                 ./page_owner_s    
210                                                   
211 STANDARD FORMAT SPECIFIERS                        
212 ==========================                        
213 ::                                                
214                                                   
215   For --sort option:                              
216                                                   
217         KEY             LONG            DESCRI    
218         p               pid             proces    
219         tg              tgid            thread    
220         n               name            task c    
221         st              stacktrace      stack     
222         T               txt             full t    
223         ft              free_ts         timest    
224         at              alloc_ts        timest    
225         ator            allocator       memory    
226                                                   
227   For --cull option:                              
228                                                   
229         KEY             LONG            DESCRI    
230         p               pid             proces    
231         tg              tgid            thread    
232         n               name            task c    
233         f               free            whethe    
234         st              stacktrace      stack     
235         ator            allocator       memory    
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php