task_mmu.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283
  1. #include <linux/mm.h>
  2. #include <linux/hugetlb.h>
  3. #include <linux/huge_mm.h>
  4. #include <linux/mount.h>
  5. #include <linux/seq_file.h>
  6. #include <linux/highmem.h>
  7. #include <linux/ptrace.h>
  8. #include <linux/slab.h>
  9. #include <linux/pagemap.h>
  10. #include <linux/mempolicy.h>
  11. #include <linux/rmap.h>
  12. #include <linux/swap.h>
  13. #include <linux/swapops.h>
  14. #include <asm/elf.h>
  15. #include <asm/uaccess.h>
  16. #include <asm/tlbflush.h>
  17. #include "internal.h"
  18. void task_mem(struct seq_file *m, struct mm_struct *mm)
  19. {
  20. unsigned long data, text, lib, swap;
  21. unsigned long hiwater_vm, total_vm, hiwater_rss, total_rss;
  22. /*
  23. * Note: to minimize their overhead, mm maintains hiwater_vm and
  24. * hiwater_rss only when about to *lower* total_vm or rss. Any
  25. * collector of these hiwater stats must therefore get total_vm
  26. * and rss too, which will usually be the higher. Barriers? not
  27. * worth the effort, such snapshots can always be inconsistent.
  28. */
  29. hiwater_vm = total_vm = mm->total_vm;
  30. if (hiwater_vm < mm->hiwater_vm)
  31. hiwater_vm = mm->hiwater_vm;
  32. hiwater_rss = total_rss = get_mm_rss(mm);
  33. if (hiwater_rss < mm->hiwater_rss)
  34. hiwater_rss = mm->hiwater_rss;
  35. data = mm->total_vm - mm->shared_vm - mm->stack_vm;
  36. text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK)) >> 10;
  37. lib = (mm->exec_vm << (PAGE_SHIFT-10)) - text;
  38. swap = get_mm_counter(mm, MM_SWAPENTS);
  39. seq_printf(m,
  40. "VmPeak:\t%8lu kB\n"
  41. "VmSize:\t%8lu kB\n"
  42. "VmLck:\t%8lu kB\n"
  43. "VmPin:\t%8lu kB\n"
  44. "VmHWM:\t%8lu kB\n"
  45. "VmRSS:\t%8lu kB\n"
  46. "VmData:\t%8lu kB\n"
  47. "VmStk:\t%8lu kB\n"
  48. "VmExe:\t%8lu kB\n"
  49. "VmLib:\t%8lu kB\n"
  50. "VmPTE:\t%8lu kB\n"
  51. "VmSwap:\t%8lu kB\n",
  52. hiwater_vm << (PAGE_SHIFT-10),
  53. (total_vm - mm->reserved_vm) << (PAGE_SHIFT-10),
  54. mm->locked_vm << (PAGE_SHIFT-10),
  55. mm->pinned_vm << (PAGE_SHIFT-10),
  56. hiwater_rss << (PAGE_SHIFT-10),
  57. total_rss << (PAGE_SHIFT-10),
  58. data << (PAGE_SHIFT-10),
  59. mm->stack_vm << (PAGE_SHIFT-10), text, lib,
  60. (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
  61. swap << (PAGE_SHIFT-10));
  62. }
  63. unsigned long task_vsize(struct mm_struct *mm)
  64. {
  65. return PAGE_SIZE * mm->total_vm;
  66. }
  67. unsigned long task_statm(struct mm_struct *mm,
  68. unsigned long *shared, unsigned long *text,
  69. unsigned long *data, unsigned long *resident)
  70. {
  71. *shared = get_mm_counter(mm, MM_FILEPAGES);
  72. *text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK))
  73. >> PAGE_SHIFT;
  74. *data = mm->total_vm - mm->shared_vm;
  75. *resident = *shared + get_mm_counter(mm, MM_ANONPAGES);
  76. return mm->total_vm;
  77. }
  78. static void pad_len_spaces(struct seq_file *m, int len)
  79. {
  80. len = 25 + sizeof(void*) * 6 - len;
  81. if (len < 1)
  82. len = 1;
  83. seq_printf(m, "%*c", len, ' ');
  84. }
  85. static void vma_stop(struct proc_maps_private *priv, struct vm_area_struct *vma)
  86. {
  87. if (vma && vma != priv->tail_vma) {
  88. struct mm_struct *mm = vma->vm_mm;
  89. up_read(&mm->mmap_sem);
  90. mmput(mm);
  91. }
  92. }
  93. static void *m_start(struct seq_file *m, loff_t *pos)
  94. {
  95. struct proc_maps_private *priv = m->private;
  96. unsigned long last_addr = m->version;
  97. struct mm_struct *mm;
  98. struct vm_area_struct *vma, *tail_vma = NULL;
  99. loff_t l = *pos;
  100. /* Clear the per syscall fields in priv */
  101. priv->task = NULL;
  102. priv->tail_vma = NULL;
  103. /*
  104. * We remember last_addr rather than next_addr to hit with
  105. * mmap_cache most of the time. We have zero last_addr at
  106. * the beginning and also after lseek. We will have -1 last_addr
  107. * after the end of the vmas.
  108. */
  109. if (last_addr == -1UL)
  110. return NULL;
  111. priv->task = get_pid_task(priv->pid, PIDTYPE_PID);
  112. if (!priv->task)
  113. return ERR_PTR(-ESRCH);
  114. mm = mm_for_maps(priv->task);
  115. if (!mm || IS_ERR(mm))
  116. return mm;
  117. down_read(&mm->mmap_sem);
  118. tail_vma = get_gate_vma(priv->task->mm);
  119. priv->tail_vma = tail_vma;
  120. /* Start with last addr hint */
  121. vma = find_vma(mm, last_addr);
  122. if (last_addr && vma) {
  123. vma = vma->vm_next;
  124. goto out;
  125. }
  126. /*
  127. * Check the vma index is within the range and do
  128. * sequential scan until m_index.
  129. */
  130. vma = NULL;
  131. if ((unsigned long)l < mm->map_count) {
  132. vma = mm->mmap;
  133. while (l-- && vma)
  134. vma = vma->vm_next;
  135. goto out;
  136. }
  137. if (l != mm->map_count)
  138. tail_vma = NULL; /* After gate vma */
  139. out:
  140. if (vma)
  141. return vma;
  142. /* End of vmas has been reached */
  143. m->version = (tail_vma != NULL)? 0: -1UL;
  144. up_read(&mm->mmap_sem);
  145. mmput(mm);
  146. return tail_vma;
  147. }
  148. static void *m_next(struct seq_file *m, void *v, loff_t *pos)
  149. {
  150. struct proc_maps_private *priv = m->private;
  151. struct vm_area_struct *vma = v;
  152. struct vm_area_struct *tail_vma = priv->tail_vma;
  153. (*pos)++;
  154. if (vma && (vma != tail_vma) && vma->vm_next)
  155. return vma->vm_next;
  156. vma_stop(priv, vma);
  157. return (vma != tail_vma)? tail_vma: NULL;
  158. }
  159. static void m_stop(struct seq_file *m, void *v)
  160. {
  161. struct proc_maps_private *priv = m->private;
  162. struct vm_area_struct *vma = v;
  163. if (!IS_ERR(vma))
  164. vma_stop(priv, vma);
  165. if (priv->task)
  166. put_task_struct(priv->task);
  167. }
  168. static int do_maps_open(struct inode *inode, struct file *file,
  169. const struct seq_operations *ops)
  170. {
  171. struct proc_maps_private *priv;
  172. int ret = -ENOMEM;
  173. priv = kzalloc(sizeof(*priv), GFP_KERNEL);
  174. if (priv) {
  175. priv->pid = proc_pid(inode);
  176. ret = seq_open(file, ops);
  177. if (!ret) {
  178. struct seq_file *m = file->private_data;
  179. m->private = priv;
  180. } else {
  181. kfree(priv);
  182. }
  183. }
  184. return ret;
  185. }
  186. static void
  187. show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
  188. {
  189. struct mm_struct *mm = vma->vm_mm;
  190. struct file *file = vma->vm_file;
  191. struct proc_maps_private *priv = m->private;
  192. struct task_struct *task = priv->task;
  193. vm_flags_t flags = vma->vm_flags;
  194. unsigned long ino = 0;
  195. unsigned long long pgoff = 0;
  196. unsigned long start, end;
  197. dev_t dev = 0;
  198. int len;
  199. const char *name = NULL;
  200. if (file) {
  201. struct inode *inode = vma->vm_file->f_path.dentry->d_inode;
  202. dev = inode->i_sb->s_dev;
  203. ino = inode->i_ino;
  204. pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
  205. }
  206. /* We don't show the stack guard page in /proc/maps */
  207. start = vma->vm_start;
  208. if (stack_guard_page_start(vma, start))
  209. start += PAGE_SIZE;
  210. end = vma->vm_end;
  211. if (stack_guard_page_end(vma, end))
  212. end -= PAGE_SIZE;
  213. seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
  214. start,
  215. end,
  216. flags & VM_READ ? 'r' : '-',
  217. flags & VM_WRITE ? 'w' : '-',
  218. flags & VM_EXEC ? 'x' : '-',
  219. flags & VM_MAYSHARE ? 's' : 'p',
  220. pgoff,
  221. MAJOR(dev), MINOR(dev), ino, &len);
  222. /*
  223. * Print the dentry name for named mappings, and a
  224. * special [heap] marker for the heap:
  225. */
  226. if (file) {
  227. pad_len_spaces(m, len);
  228. seq_path(m, &file->f_path, "\n");
  229. goto done;
  230. }
  231. name = arch_vma_name(vma);
  232. if (!name) {
  233. pid_t tid;
  234. if (!mm) {
  235. name = "[vdso]";
  236. goto done;
  237. }
  238. if (vma->vm_start <= mm->brk &&
  239. vma->vm_end >= mm->start_brk) {
  240. name = "[heap]";
  241. goto done;
  242. }
  243. tid = vm_is_stack(task, vma, is_pid);
  244. if (tid != 0) {
  245. /*
  246. * Thread stack in /proc/PID/task/TID/maps or
  247. * the main process stack.
  248. */
  249. if (!is_pid || (vma->vm_start <= mm->start_stack &&
  250. vma->vm_end >= mm->start_stack)) {
  251. name = "[stack]";
  252. } else {
  253. /* Thread stack in /proc/PID/maps */
  254. pad_len_spaces(m, len);
  255. seq_printf(m, "[stack:%d]", tid);
  256. }
  257. }
  258. }
  259. done:
  260. if (name) {
  261. pad_len_spaces(m, len);
  262. seq_puts(m, name);
  263. }
  264. seq_putc(m, '\n');
  265. }
  266. static int show_map(struct seq_file *m, void *v, int is_pid)
  267. {
  268. struct vm_area_struct *vma = v;
  269. struct proc_maps_private *priv = m->private;
  270. struct task_struct *task = priv->task;
  271. show_map_vma(m, vma, is_pid);
  272. if (m->count < m->size) /* vma is copied successfully */
  273. m->version = (vma != get_gate_vma(task->mm))
  274. ? vma->vm_start : 0;
  275. return 0;
  276. }
  277. static int show_pid_map(struct seq_file *m, void *v)
  278. {
  279. return show_map(m, v, 1);
  280. }
  281. static int show_tid_map(struct seq_file *m, void *v)
  282. {
  283. return show_map(m, v, 0);
  284. }
  285. static const struct seq_operations proc_pid_maps_op = {
  286. .start = m_start,
  287. .next = m_next,
  288. .stop = m_stop,
  289. .show = show_pid_map
  290. };
  291. static const struct seq_operations proc_tid_maps_op = {
  292. .start = m_start,
  293. .next = m_next,
  294. .stop = m_stop,
  295. .show = show_tid_map
  296. };
  297. static int pid_maps_open(struct inode *inode, struct file *file)
  298. {
  299. return do_maps_open(inode, file, &proc_pid_maps_op);
  300. }
  301. static int tid_maps_open(struct inode *inode, struct file *file)
  302. {
  303. return do_maps_open(inode, file, &proc_tid_maps_op);
  304. }
  305. const struct file_operations proc_pid_maps_operations = {
  306. .open = pid_maps_open,
  307. .read = seq_read,
  308. .llseek = seq_lseek,
  309. .release = seq_release_private,
  310. };
  311. const struct file_operations proc_tid_maps_operations = {
  312. .open = tid_maps_open,
  313. .read = seq_read,
  314. .llseek = seq_lseek,
  315. .release = seq_release_private,
  316. };
  317. /*
  318. * Proportional Set Size(PSS): my share of RSS.
  319. *
  320. * PSS of a process is the count of pages it has in memory, where each
  321. * page is divided by the number of processes sharing it. So if a
  322. * process has 1000 pages all to itself, and 1000 shared with one other
  323. * process, its PSS will be 1500.
  324. *
  325. * To keep (accumulated) division errors low, we adopt a 64bit
  326. * fixed-point pss counter to minimize division errors. So (pss >>
  327. * PSS_SHIFT) would be the real byte count.
  328. *
  329. * A shift of 12 before division means (assuming 4K page size):
  330. * - 1M 3-user-pages add up to 8KB errors;
  331. * - supports mapcount up to 2^24, or 16M;
  332. * - supports PSS up to 2^52 bytes, or 4PB.
  333. */
  334. #define PSS_SHIFT 12
  335. #ifdef CONFIG_PROC_PAGE_MONITOR
  336. struct mem_size_stats {
  337. struct vm_area_struct *vma;
  338. unsigned long resident;
  339. unsigned long shared_clean;
  340. unsigned long shared_dirty;
  341. unsigned long private_clean;
  342. unsigned long private_dirty;
  343. unsigned long referenced;
  344. unsigned long anonymous;
  345. unsigned long anonymous_thp;
  346. unsigned long swap;
  347. u64 pss;
  348. };
  349. static void smaps_pte_entry(pte_t ptent, unsigned long addr,
  350. unsigned long ptent_size, struct mm_walk *walk)
  351. {
  352. struct mem_size_stats *mss = walk->private;
  353. struct vm_area_struct *vma = mss->vma;
  354. struct page *page;
  355. int mapcount;
  356. if (is_swap_pte(ptent)) {
  357. mss->swap += ptent_size;
  358. return;
  359. }
  360. if (!pte_present(ptent))
  361. return;
  362. page = vm_normal_page(vma, addr, ptent);
  363. if (!page)
  364. return;
  365. if (PageAnon(page))
  366. mss->anonymous += ptent_size;
  367. mss->resident += ptent_size;
  368. /* Accumulate the size in pages that have been accessed. */
  369. if (pte_young(ptent) || PageReferenced(page))
  370. mss->referenced += ptent_size;
  371. mapcount = page_mapcount(page);
  372. if (mapcount >= 2) {
  373. if (pte_dirty(ptent) || PageDirty(page))
  374. mss->shared_dirty += ptent_size;
  375. else
  376. mss->shared_clean += ptent_size;
  377. mss->pss += (ptent_size << PSS_SHIFT) / mapcount;
  378. } else {
  379. if (pte_dirty(ptent) || PageDirty(page))
  380. mss->private_dirty += ptent_size;
  381. else
  382. mss->private_clean += ptent_size;
  383. mss->pss += (ptent_size << PSS_SHIFT);
  384. }
  385. }
  386. static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
  387. struct mm_walk *walk)
  388. {
  389. struct mem_size_stats *mss = walk->private;
  390. struct vm_area_struct *vma = mss->vma;
  391. pte_t *pte;
  392. spinlock_t *ptl;
  393. if (pmd_trans_huge_lock(pmd, vma) == 1) {
  394. smaps_pte_entry(*(pte_t *)pmd, addr, HPAGE_PMD_SIZE, walk);
  395. spin_unlock(&walk->mm->page_table_lock);
  396. mss->anonymous_thp += HPAGE_PMD_SIZE;
  397. return 0;
  398. }
  399. if (pmd_trans_unstable(pmd))
  400. return 0;
  401. /*
  402. * The mmap_sem held all the way back in m_start() is what
  403. * keeps khugepaged out of here and from collapsing things
  404. * in here.
  405. */
  406. pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
  407. for (; addr != end; pte++, addr += PAGE_SIZE)
  408. smaps_pte_entry(*pte, addr, PAGE_SIZE, walk);
  409. pte_unmap_unlock(pte - 1, ptl);
  410. cond_resched();
  411. return 0;
  412. }
  413. static int show_smap(struct seq_file *m, void *v, int is_pid)
  414. {
  415. struct proc_maps_private *priv = m->private;
  416. struct task_struct *task = priv->task;
  417. struct vm_area_struct *vma = v;
  418. struct mem_size_stats mss;
  419. struct mm_walk smaps_walk = {
  420. .pmd_entry = smaps_pte_range,
  421. .mm = vma->vm_mm,
  422. .private = &mss,
  423. };
  424. memset(&mss, 0, sizeof mss);
  425. mss.vma = vma;
  426. /* mmap_sem is held in m_start */
  427. if (vma->vm_mm && !is_vm_hugetlb_page(vma))
  428. walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
  429. show_map_vma(m, vma, is_pid);
  430. seq_printf(m,
  431. "Size: %8lu kB\n"
  432. "Rss: %8lu kB\n"
  433. "Pss: %8lu kB\n"
  434. "Shared_Clean: %8lu kB\n"
  435. "Shared_Dirty: %8lu kB\n"
  436. "Private_Clean: %8lu kB\n"
  437. "Private_Dirty: %8lu kB\n"
  438. "Referenced: %8lu kB\n"
  439. "Anonymous: %8lu kB\n"
  440. "AnonHugePages: %8lu kB\n"
  441. "Swap: %8lu kB\n"
  442. "KernelPageSize: %8lu kB\n"
  443. "MMUPageSize: %8lu kB\n"
  444. "Locked: %8lu kB\n",
  445. (vma->vm_end - vma->vm_start) >> 10,
  446. mss.resident >> 10,
  447. (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
  448. mss.shared_clean >> 10,
  449. mss.shared_dirty >> 10,
  450. mss.private_clean >> 10,
  451. mss.private_dirty >> 10,
  452. mss.referenced >> 10,
  453. mss.anonymous >> 10,
  454. mss.anonymous_thp >> 10,
  455. mss.swap >> 10,
  456. vma_kernel_pagesize(vma) >> 10,
  457. vma_mmu_pagesize(vma) >> 10,
  458. (vma->vm_flags & VM_LOCKED) ?
  459. (unsigned long)(mss.pss >> (10 + PSS_SHIFT)) : 0);
  460. if (m->count < m->size) /* vma is copied successfully */
  461. m->version = (vma != get_gate_vma(task->mm))
  462. ? vma->vm_start : 0;
  463. return 0;
  464. }
  465. static int show_pid_smap(struct seq_file *m, void *v)
  466. {
  467. return show_smap(m, v, 1);
  468. }
  469. static int show_tid_smap(struct seq_file *m, void *v)
  470. {
  471. return show_smap(m, v, 0);
  472. }
  473. static const struct seq_operations proc_pid_smaps_op = {
  474. .start = m_start,
  475. .next = m_next,
  476. .stop = m_stop,
  477. .show = show_pid_smap
  478. };
  479. static const struct seq_operations proc_tid_smaps_op = {
  480. .start = m_start,
  481. .next = m_next,
  482. .stop = m_stop,
  483. .show = show_tid_smap
  484. };
  485. static int pid_smaps_open(struct inode *inode, struct file *file)
  486. {
  487. return do_maps_open(inode, file, &proc_pid_smaps_op);
  488. }
  489. static int tid_smaps_open(struct inode *inode, struct file *file)
  490. {
  491. return do_maps_open(inode, file, &proc_tid_smaps_op);
  492. }
  493. const struct file_operations proc_pid_smaps_operations = {
  494. .open = pid_smaps_open,
  495. .read = seq_read,
  496. .llseek = seq_lseek,
  497. .release = seq_release_private,
  498. };
  499. const struct file_operations proc_tid_smaps_operations = {
  500. .open = tid_smaps_open,
  501. .read = seq_read,
  502. .llseek = seq_lseek,
  503. .release = seq_release_private,
  504. };
  505. static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr,
  506. unsigned long end, struct mm_walk *walk)
  507. {
  508. struct vm_area_struct *vma = walk->private;
  509. pte_t *pte, ptent;
  510. spinlock_t *ptl;
  511. struct page *page;
  512. split_huge_page_pmd(walk->mm, pmd);
  513. if (pmd_trans_unstable(pmd))
  514. return 0;
  515. pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
  516. for (; addr != end; pte++, addr += PAGE_SIZE) {
  517. ptent = *pte;
  518. if (!pte_present(ptent))
  519. continue;
  520. page = vm_normal_page(vma, addr, ptent);
  521. if (!page)
  522. continue;
  523. if (PageReserved(page))
  524. continue;
  525. /* Clear accessed and referenced bits. */
  526. ptep_test_and_clear_young(vma, addr, pte);
  527. ClearPageReferenced(page);
  528. }
  529. pte_unmap_unlock(pte - 1, ptl);
  530. cond_resched();
  531. return 0;
  532. }
  533. #define CLEAR_REFS_ALL 1
  534. #define CLEAR_REFS_ANON 2
  535. #define CLEAR_REFS_MAPPED 3
  536. static ssize_t clear_refs_write(struct file *file, const char __user *buf,
  537. size_t count, loff_t *ppos)
  538. {
  539. struct task_struct *task;
  540. char buffer[PROC_NUMBUF];
  541. struct mm_struct *mm;
  542. struct vm_area_struct *vma;
  543. int type;
  544. int rv;
  545. memset(buffer, 0, sizeof(buffer));
  546. if (count > sizeof(buffer) - 1)
  547. count = sizeof(buffer) - 1;
  548. if (copy_from_user(buffer, buf, count))
  549. return -EFAULT;
  550. rv = kstrtoint(strstrip(buffer), 10, &type);
  551. if (rv < 0)
  552. return rv;
  553. if (type < CLEAR_REFS_ALL || type > CLEAR_REFS_MAPPED)
  554. return -EINVAL;
  555. task = get_proc_task(file->f_path.dentry->d_inode);
  556. if (!task)
  557. return -ESRCH;
  558. mm = get_task_mm(task);
  559. if (mm) {
  560. struct mm_walk clear_refs_walk = {
  561. .pmd_entry = clear_refs_pte_range,
  562. .mm = mm,
  563. };
  564. down_read(&mm->mmap_sem);
  565. for (vma = mm->mmap; vma; vma = vma->vm_next) {
  566. clear_refs_walk.private = vma;
  567. if (is_vm_hugetlb_page(vma))
  568. continue;
  569. /*
  570. * Writing 1 to /proc/pid/clear_refs affects all pages.
  571. *
  572. * Writing 2 to /proc/pid/clear_refs only affects
  573. * Anonymous pages.
  574. *
  575. * Writing 3 to /proc/pid/clear_refs only affects file
  576. * mapped pages.
  577. */
  578. if (type == CLEAR_REFS_ANON && vma->vm_file)
  579. continue;
  580. if (type == CLEAR_REFS_MAPPED && !vma->vm_file)
  581. continue;
  582. walk_page_range(vma->vm_start, vma->vm_end,
  583. &clear_refs_walk);
  584. }
  585. flush_tlb_mm(mm);
  586. up_read(&mm->mmap_sem);
  587. mmput(mm);
  588. }
  589. put_task_struct(task);
  590. return count;
  591. }
  592. const struct file_operations proc_clear_refs_operations = {
  593. .write = clear_refs_write,
  594. .llseek = noop_llseek,
  595. };
  596. typedef struct {
  597. u64 pme;
  598. } pagemap_entry_t;
  599. struct pagemapread {
  600. int pos, len;
  601. pagemap_entry_t *buffer;
  602. };
  603. #define PAGEMAP_WALK_SIZE (PMD_SIZE)
  604. #define PAGEMAP_WALK_MASK (PMD_MASK)
  605. #define PM_ENTRY_BYTES sizeof(u64)
  606. #define PM_STATUS_BITS 3
  607. #define PM_STATUS_OFFSET (64 - PM_STATUS_BITS)
  608. #define PM_STATUS_MASK (((1LL << PM_STATUS_BITS) - 1) << PM_STATUS_OFFSET)
  609. #define PM_STATUS(nr) (((nr) << PM_STATUS_OFFSET) & PM_STATUS_MASK)
  610. #define PM_PSHIFT_BITS 6
  611. #define PM_PSHIFT_OFFSET (PM_STATUS_OFFSET - PM_PSHIFT_BITS)
  612. #define PM_PSHIFT_MASK (((1LL << PM_PSHIFT_BITS) - 1) << PM_PSHIFT_OFFSET)
  613. #define PM_PSHIFT(x) (((u64) (x) << PM_PSHIFT_OFFSET) & PM_PSHIFT_MASK)
  614. #define PM_PFRAME_MASK ((1LL << PM_PSHIFT_OFFSET) - 1)
  615. #define PM_PFRAME(x) ((x) & PM_PFRAME_MASK)
  616. #define PM_PRESENT PM_STATUS(4LL)
  617. #define PM_SWAP PM_STATUS(2LL)
  618. #define PM_NOT_PRESENT PM_PSHIFT(PAGE_SHIFT)
  619. #define PM_END_OF_BUFFER 1
  620. static inline pagemap_entry_t make_pme(u64 val)
  621. {
  622. return (pagemap_entry_t) { .pme = val };
  623. }
  624. static int add_to_pagemap(unsigned long addr, pagemap_entry_t *pme,
  625. struct pagemapread *pm)
  626. {
  627. pm->buffer[pm->pos++] = *pme;
  628. if (pm->pos >= pm->len)
  629. return PM_END_OF_BUFFER;
  630. return 0;
  631. }
  632. static int pagemap_pte_hole(unsigned long start, unsigned long end,
  633. struct mm_walk *walk)
  634. {
  635. struct pagemapread *pm = walk->private;
  636. unsigned long addr;
  637. int err = 0;
  638. pagemap_entry_t pme = make_pme(PM_NOT_PRESENT);
  639. for (addr = start; addr < end; addr += PAGE_SIZE) {
  640. err = add_to_pagemap(addr, &pme, pm);
  641. if (err)
  642. break;
  643. }
  644. return err;
  645. }
  646. static u64 swap_pte_to_pagemap_entry(pte_t pte)
  647. {
  648. swp_entry_t e = pte_to_swp_entry(pte);
  649. return swp_type(e) | (swp_offset(e) << MAX_SWAPFILES_SHIFT);
  650. }
  651. static void pte_to_pagemap_entry(pagemap_entry_t *pme, pte_t pte)
  652. {
  653. if (is_swap_pte(pte))
  654. *pme = make_pme(PM_PFRAME(swap_pte_to_pagemap_entry(pte))
  655. | PM_PSHIFT(PAGE_SHIFT) | PM_SWAP);
  656. else if (pte_present(pte))
  657. *pme = make_pme(PM_PFRAME(pte_pfn(pte))
  658. | PM_PSHIFT(PAGE_SHIFT) | PM_PRESENT);
  659. }
  660. #ifdef CONFIG_TRANSPARENT_HUGEPAGE
  661. static void thp_pmd_to_pagemap_entry(pagemap_entry_t *pme,
  662. pmd_t pmd, int offset)
  663. {
  664. /*
  665. * Currently pmd for thp is always present because thp can not be
  666. * swapped-out, migrated, or HWPOISONed (split in such cases instead.)
  667. * This if-check is just to prepare for future implementation.
  668. */
  669. if (pmd_present(pmd))
  670. *pme = make_pme(PM_PFRAME(pmd_pfn(pmd) + offset)
  671. | PM_PSHIFT(PAGE_SHIFT) | PM_PRESENT);
  672. }
  673. #else
  674. static inline void thp_pmd_to_pagemap_entry(pagemap_entry_t *pme,
  675. pmd_t pmd, int offset)
  676. {
  677. }
  678. #endif
  679. static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
  680. struct mm_walk *walk)
  681. {
  682. struct vm_area_struct *vma;
  683. struct pagemapread *pm = walk->private;
  684. pte_t *pte;
  685. int err = 0;
  686. pagemap_entry_t pme = make_pme(PM_NOT_PRESENT);
  687. if (pmd_trans_unstable(pmd))
  688. return 0;
  689. /* find the first VMA at or above 'addr' */
  690. vma = find_vma(walk->mm, addr);
  691. spin_lock(&walk->mm->page_table_lock);
  692. if (pmd_trans_huge_lock(pmd, vma) == 1) {
  693. for (; addr != end; addr += PAGE_SIZE) {
  694. unsigned long offset;
  695. offset = (addr & ~PAGEMAP_WALK_MASK) >>
  696. PAGE_SHIFT;
  697. thp_pmd_to_pagemap_entry(&pme, *pmd, offset);
  698. err = add_to_pagemap(addr, &pme, pm);
  699. if (err)
  700. break;
  701. }
  702. spin_unlock(&walk->mm->page_table_lock);
  703. return err;
  704. }
  705. for (; addr != end; addr += PAGE_SIZE) {
  706. /* check to see if we've left 'vma' behind
  707. * and need a new, higher one */
  708. if (vma && (addr >= vma->vm_end))
  709. vma = find_vma(walk->mm, addr);
  710. /* check that 'vma' actually covers this address,
  711. * and that it isn't a huge page vma */
  712. if (vma && (vma->vm_start <= addr) &&
  713. !is_vm_hugetlb_page(vma)) {
  714. pte = pte_offset_map(pmd, addr);
  715. pte_to_pagemap_entry(&pme, *pte);
  716. /* unmap before userspace copy */
  717. pte_unmap(pte);
  718. }
  719. err = add_to_pagemap(addr, &pme, pm);
  720. if (err)
  721. return err;
  722. }
  723. cond_resched();
  724. return err;
  725. }
  726. #ifdef CONFIG_HUGETLB_PAGE
  727. static void huge_pte_to_pagemap_entry(pagemap_entry_t *pme,
  728. pte_t pte, int offset)
  729. {
  730. if (pte_present(pte))
  731. *pme = make_pme(PM_PFRAME(pte_pfn(pte) + offset)
  732. | PM_PSHIFT(PAGE_SHIFT) | PM_PRESENT);
  733. }
  734. /* This function walks within one hugetlb entry in the single call */
  735. static int pagemap_hugetlb_range(pte_t *pte, unsigned long hmask,
  736. unsigned long addr, unsigned long end,
  737. struct mm_walk *walk)
  738. {
  739. struct pagemapread *pm = walk->private;
  740. int err = 0;
  741. pagemap_entry_t pme = make_pme(PM_NOT_PRESENT);
  742. for (; addr != end; addr += PAGE_SIZE) {
  743. int offset = (addr & ~hmask) >> PAGE_SHIFT;
  744. huge_pte_to_pagemap_entry(&pme, *pte, offset);
  745. err = add_to_pagemap(addr, &pme, pm);
  746. if (err)
  747. return err;
  748. }
  749. cond_resched();
  750. return err;
  751. }
  752. #endif /* HUGETLB_PAGE */
  753. /*
  754. * /proc/pid/pagemap - an array mapping virtual pages to pfns
  755. *
  756. * For each page in the address space, this file contains one 64-bit entry
  757. * consisting of the following:
  758. *
  759. * Bits 0-55 page frame number (PFN) if present
  760. * Bits 0-4 swap type if swapped
  761. * Bits 5-55 swap offset if swapped
  762. * Bits 55-60 page shift (page size = 1<<page shift)
  763. * Bit 61 reserved for future use
  764. * Bit 62 page swapped
  765. * Bit 63 page present
  766. *
  767. * If the page is not present but in swap, then the PFN contains an
  768. * encoding of the swap file number and the page's offset into the
  769. * swap. Unmapped pages return a null PFN. This allows determining
  770. * precisely which pages are mapped (or in swap) and comparing mapped
  771. * pages between processes.
  772. *
  773. * Efficient users of this interface will use /proc/pid/maps to
  774. * determine which areas of memory are actually mapped and llseek to
  775. * skip over unmapped regions.
  776. */
  777. static ssize_t pagemap_read(struct file *file, char __user *buf,
  778. size_t count, loff_t *ppos)
  779. {
  780. struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
  781. struct mm_struct *mm;
  782. struct pagemapread pm;
  783. int ret = -ESRCH;
  784. struct mm_walk pagemap_walk = {};
  785. unsigned long src;
  786. unsigned long svpfn;
  787. unsigned long start_vaddr;
  788. unsigned long end_vaddr;
  789. int copied = 0;
  790. if (!task)
  791. goto out;
  792. ret = -EINVAL;
  793. /* file position must be aligned */
  794. if ((*ppos % PM_ENTRY_BYTES) || (count % PM_ENTRY_BYTES))
  795. goto out_task;
  796. ret = 0;
  797. if (!count)
  798. goto out_task;
  799. pm.len = PM_ENTRY_BYTES * (PAGEMAP_WALK_SIZE >> PAGE_SHIFT);
  800. pm.buffer = kmalloc(pm.len, GFP_TEMPORARY);
  801. ret = -ENOMEM;
  802. if (!pm.buffer)
  803. goto out_task;
  804. mm = mm_for_maps(task);
  805. ret = PTR_ERR(mm);
  806. if (!mm || IS_ERR(mm))
  807. goto out_free;
  808. pagemap_walk.pmd_entry = pagemap_pte_range;
  809. pagemap_walk.pte_hole = pagemap_pte_hole;
  810. #ifdef CONFIG_HUGETLB_PAGE
  811. pagemap_walk.hugetlb_entry = pagemap_hugetlb_range;
  812. #endif
  813. pagemap_walk.mm = mm;
  814. pagemap_walk.private = &pm;
  815. src = *ppos;
  816. svpfn = src / PM_ENTRY_BYTES;
  817. start_vaddr = svpfn << PAGE_SHIFT;
  818. end_vaddr = TASK_SIZE_OF(task);
  819. /* watch out for wraparound */
  820. if (svpfn > TASK_SIZE_OF(task) >> PAGE_SHIFT)
  821. start_vaddr = end_vaddr;
  822. /*
  823. * The odds are that this will stop walking way
  824. * before end_vaddr, because the length of the
  825. * user buffer is tracked in "pm", and the walk
  826. * will stop when we hit the end of the buffer.
  827. */
  828. ret = 0;
  829. while (count && (start_vaddr < end_vaddr)) {
  830. int len;
  831. unsigned long end;
  832. pm.pos = 0;
  833. end = (start_vaddr + PAGEMAP_WALK_SIZE) & PAGEMAP_WALK_MASK;
  834. /* overflow ? */
  835. if (end < start_vaddr || end > end_vaddr)
  836. end = end_vaddr;
  837. down_read(&mm->mmap_sem);
  838. ret = walk_page_range(start_vaddr, end, &pagemap_walk);
  839. up_read(&mm->mmap_sem);
  840. start_vaddr = end;
  841. len = min(count, PM_ENTRY_BYTES * pm.pos);
  842. if (copy_to_user(buf, pm.buffer, len)) {
  843. ret = -EFAULT;
  844. goto out_mm;
  845. }
  846. copied += len;
  847. buf += len;
  848. count -= len;
  849. }
  850. *ppos += copied;
  851. if (!ret || ret == PM_END_OF_BUFFER)
  852. ret = copied;
  853. out_mm:
  854. mmput(mm);
  855. out_free:
  856. kfree(pm.buffer);
  857. out_task:
  858. put_task_struct(task);
  859. out:
  860. return ret;
  861. }
  862. const struct file_operations proc_pagemap_operations = {
  863. .llseek = mem_lseek, /* borrow this */
  864. .read = pagemap_read,
  865. };
  866. #endif /* CONFIG_PROC_PAGE_MONITOR */
  867. #ifdef CONFIG_NUMA
  868. struct numa_maps {
  869. struct vm_area_struct *vma;
  870. unsigned long pages;
  871. unsigned long anon;
  872. unsigned long active;
  873. unsigned long writeback;
  874. unsigned long mapcount_max;
  875. unsigned long dirty;
  876. unsigned long swapcache;
  877. unsigned long node[MAX_NUMNODES];
  878. };
  879. struct numa_maps_private {
  880. struct proc_maps_private proc_maps;
  881. struct numa_maps md;
  882. };
  883. static void gather_stats(struct page *page, struct numa_maps *md, int pte_dirty,
  884. unsigned long nr_pages)
  885. {
  886. int count = page_mapcount(page);
  887. md->pages += nr_pages;
  888. if (pte_dirty || PageDirty(page))
  889. md->dirty += nr_pages;
  890. if (PageSwapCache(page))
  891. md->swapcache += nr_pages;
  892. if (PageActive(page) || PageUnevictable(page))
  893. md->active += nr_pages;
  894. if (PageWriteback(page))
  895. md->writeback += nr_pages;
  896. if (PageAnon(page))
  897. md->anon += nr_pages;
  898. if (count > md->mapcount_max)
  899. md->mapcount_max = count;
  900. md->node[page_to_nid(page)] += nr_pages;
  901. }
  902. static struct page *can_gather_numa_stats(pte_t pte, struct vm_area_struct *vma,
  903. unsigned long addr)
  904. {
  905. struct page *page;
  906. int nid;
  907. if (!pte_present(pte))
  908. return NULL;
  909. page = vm_normal_page(vma, addr, pte);
  910. if (!page)
  911. return NULL;
  912. if (PageReserved(page))
  913. return NULL;
  914. nid = page_to_nid(page);
  915. if (!node_isset(nid, node_states[N_HIGH_MEMORY]))
  916. return NULL;
  917. return page;
  918. }
  919. static int gather_pte_stats(pmd_t *pmd, unsigned long addr,
  920. unsigned long end, struct mm_walk *walk)
  921. {
  922. struct numa_maps *md;
  923. spinlock_t *ptl;
  924. pte_t *orig_pte;
  925. pte_t *pte;
  926. md = walk->private;
  927. if (pmd_trans_huge_lock(pmd, md->vma) == 1) {
  928. pte_t huge_pte = *(pte_t *)pmd;
  929. struct page *page;
  930. page = can_gather_numa_stats(huge_pte, md->vma, addr);
  931. if (page)
  932. gather_stats(page, md, pte_dirty(huge_pte),
  933. HPAGE_PMD_SIZE/PAGE_SIZE);
  934. spin_unlock(&walk->mm->page_table_lock);
  935. return 0;
  936. }
  937. if (pmd_trans_unstable(pmd))
  938. return 0;
  939. orig_pte = pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl);
  940. do {
  941. struct page *page = can_gather_numa_stats(*pte, md->vma, addr);
  942. if (!page)
  943. continue;
  944. gather_stats(page, md, pte_dirty(*pte), 1);
  945. } while (pte++, addr += PAGE_SIZE, addr != end);
  946. pte_unmap_unlock(orig_pte, ptl);
  947. return 0;
  948. }
  949. #ifdef CONFIG_HUGETLB_PAGE
  950. static int gather_hugetbl_stats(pte_t *pte, unsigned long hmask,
  951. unsigned long addr, unsigned long end, struct mm_walk *walk)
  952. {
  953. struct numa_maps *md;
  954. struct page *page;
  955. if (pte_none(*pte))
  956. return 0;
  957. page = pte_page(*pte);
  958. if (!page)
  959. return 0;
  960. md = walk->private;
  961. gather_stats(page, md, pte_dirty(*pte), 1);
  962. return 0;
  963. }
  964. #else
  965. static int gather_hugetbl_stats(pte_t *pte, unsigned long hmask,
  966. unsigned long addr, unsigned long end, struct mm_walk *walk)
  967. {
  968. return 0;
  969. }
  970. #endif
  971. /*
  972. * Display pages allocated per node and memory policy via /proc.
  973. */
  974. static int show_numa_map(struct seq_file *m, void *v, int is_pid)
  975. {
  976. struct numa_maps_private *numa_priv = m->private;
  977. struct proc_maps_private *proc_priv = &numa_priv->proc_maps;
  978. struct vm_area_struct *vma = v;
  979. struct numa_maps *md = &numa_priv->md;
  980. struct file *file = vma->vm_file;
  981. struct mm_struct *mm = vma->vm_mm;
  982. struct mm_walk walk = {};
  983. struct mempolicy *pol;
  984. int n;
  985. char buffer[50];
  986. if (!mm)
  987. return 0;
  988. /* Ensure we start with an empty set of numa_maps statistics. */
  989. memset(md, 0, sizeof(*md));
  990. md->vma = vma;
  991. walk.hugetlb_entry = gather_hugetbl_stats;
  992. walk.pmd_entry = gather_pte_stats;
  993. walk.private = md;
  994. walk.mm = mm;
  995. pol = get_vma_policy(proc_priv->task, vma, vma->vm_start);
  996. mpol_to_str(buffer, sizeof(buffer), pol, 0);
  997. mpol_cond_put(pol);
  998. seq_printf(m, "%08lx %s", vma->vm_start, buffer);
  999. if (file) {
  1000. seq_printf(m, " file=");
  1001. seq_path(m, &file->f_path, "\n\t= ");
  1002. } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
  1003. seq_printf(m, " heap");
  1004. } else {
  1005. pid_t tid = vm_is_stack(proc_priv->task, vma, is_pid);
  1006. if (tid != 0) {
  1007. /*
  1008. * Thread stack in /proc/PID/task/TID/maps or
  1009. * the main process stack.
  1010. */
  1011. if (!is_pid || (vma->vm_start <= mm->start_stack &&
  1012. vma->vm_end >= mm->start_stack))
  1013. seq_printf(m, " stack");
  1014. else
  1015. seq_printf(m, " stack:%d", tid);
  1016. }
  1017. }
  1018. if (is_vm_hugetlb_page(vma))
  1019. seq_printf(m, " huge");
  1020. walk_page_range(vma->vm_start, vma->vm_end, &walk);
  1021. if (!md->pages)
  1022. goto out;
  1023. if (md->anon)
  1024. seq_printf(m, " anon=%lu", md->anon);
  1025. if (md->dirty)
  1026. seq_printf(m, " dirty=%lu", md->dirty);
  1027. if (md->pages != md->anon && md->pages != md->dirty)
  1028. seq_printf(m, " mapped=%lu", md->pages);
  1029. if (md->mapcount_max > 1)
  1030. seq_printf(m, " mapmax=%lu", md->mapcount_max);
  1031. if (md->swapcache)
  1032. seq_printf(m, " swapcache=%lu", md->swapcache);
  1033. if (md->active < md->pages && !is_vm_hugetlb_page(vma))
  1034. seq_printf(m, " active=%lu", md->active);
  1035. if (md->writeback)
  1036. seq_printf(m, " writeback=%lu", md->writeback);
  1037. for_each_node_state(n, N_HIGH_MEMORY)
  1038. if (md->node[n])
  1039. seq_printf(m, " N%d=%lu", n, md->node[n]);
  1040. out:
  1041. seq_putc(m, '\n');
  1042. if (m->count < m->size)
  1043. m->version = (vma != proc_priv->tail_vma) ? vma->vm_start : 0;
  1044. return 0;
  1045. }
  1046. static int show_pid_numa_map(struct seq_file *m, void *v)
  1047. {
  1048. return show_numa_map(m, v, 1);
  1049. }
  1050. static int show_tid_numa_map(struct seq_file *m, void *v)
  1051. {
  1052. return show_numa_map(m, v, 0);
  1053. }
  1054. static const struct seq_operations proc_pid_numa_maps_op = {
  1055. .start = m_start,
  1056. .next = m_next,
  1057. .stop = m_stop,
  1058. .show = show_pid_numa_map,
  1059. };
  1060. static const struct seq_operations proc_tid_numa_maps_op = {
  1061. .start = m_start,
  1062. .next = m_next,
  1063. .stop = m_stop,
  1064. .show = show_tid_numa_map,
  1065. };
  1066. static int numa_maps_open(struct inode *inode, struct file *file,
  1067. const struct seq_operations *ops)
  1068. {
  1069. struct numa_maps_private *priv;
  1070. int ret = -ENOMEM;
  1071. priv = kzalloc(sizeof(*priv), GFP_KERNEL);
  1072. if (priv) {
  1073. priv->proc_maps.pid = proc_pid(inode);
  1074. ret = seq_open(file, ops);
  1075. if (!ret) {
  1076. struct seq_file *m = file->private_data;
  1077. m->private = priv;
  1078. } else {
  1079. kfree(priv);
  1080. }
  1081. }
  1082. return ret;
  1083. }
  1084. static int pid_numa_maps_open(struct inode *inode, struct file *file)
  1085. {
  1086. return numa_maps_open(inode, file, &proc_pid_numa_maps_op);
  1087. }
  1088. static int tid_numa_maps_open(struct inode *inode, struct file *file)
  1089. {
  1090. return numa_maps_open(inode, file, &proc_tid_numa_maps_op);
  1091. }
  1092. const struct file_operations proc_pid_numa_maps_operations = {
  1093. .open = pid_numa_maps_open,
  1094. .read = seq_read,
  1095. .llseek = seq_lseek,
  1096. .release = seq_release_private,
  1097. };
  1098. const struct file_operations proc_tid_numa_maps_operations = {
  1099. .open = tid_numa_maps_open,
  1100. .read = seq_read,
  1101. .llseek = seq_lseek,
  1102. .release = seq_release_private,
  1103. };
  1104. #endif /* CONFIG_NUMA */