-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage_steal.c
724 lines (603 loc) · 18.6 KB
/
page_steal.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
/*
* linux/mm/page_steal.c
*
* Copyright (C)
*/
#define pr_fmt(fmt) "page_steal: " fmt
#include <linux/stddef.h>
#include <linux/mm.h>
#include <linux/mm_inline.h>
#include <linux/page-isolation.h>
#include <linux/hugetlb.h>
#include <linux/migrate.h>
#include <linux/debugfs.h>
#include <linux/mutex.h>
#include <linux/init.h>
#include <linux/freezer.h>
#include <linux/rmap.h>
#include <linux/huge_mm.h>
#include <linux/mmu_notifier.h>
#include <linux/page_owner.h>
#include <asm/tlbflush.h>
#include "internal.h"
/* copied from mm/rmap. */
#ifdef CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH
static void __set_tlb_ubc_flush_pending(struct mm_struct *mm, bool writable)
{
struct tlbflush_unmap_batch *tlb_ubc = ¤t->tlb_ubc;
arch_tlbbatch_add_mm(&tlb_ubc->arch, mm);
tlb_ubc->flush_required = true;
/*
* Ensure compiler does not re-order the setting of tlb_flush_batched
* before the PTE is cleared.
*/
barrier();
mm->tlb_flush_batched = true;
/*
* If the PTE was dirty then it's best to assume it's writable. The
* caller must use try_to_unmap_flush_dirty() or try_to_unmap_flush()
* before the page is queued for IO.
*/
if (writable)
tlb_ubc->writable = true;
}
#else
static void __set_tlb_ubc_flush_pending(struct mm_struct *mm, bool writable)
{
}
#endif
static bool migrate_anon_page_one(struct page *page, struct vm_area_struct *vma,
unsigned long address, void *arg)
{
struct mm_struct *mm = vma->vm_mm;
struct page_vma_mapped_walk pvmw = {
.page = page,
.vma = vma,
.address = address,
};
pte_t pteval, newpte;
struct page *newpage = arg;
unsigned long start = address, end;
mmu_notifier_invalidate_range_start(vma->vm_mm, start, end);
while (page_vma_mapped_walk(&pvmw)) {
/* Nuke the page table entry. */
flush_cache_page(vma, address, pte_pfn(*pvmw.pte));
if (IS_ENABLED(CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH)) {
pteval = ptep_get_and_clear(mm, address, pvmw.pte);
__set_tlb_ubc_flush_pending(mm, pte_dirty(pteval));
} else {
pteval = ptep_clear_flush(vma, address, pvmw.pte);
}
/* Move the dirty bit to the page. Now the pte is gone. */
if (pte_dirty(pteval))
set_page_dirty(page);
page_remove_rmap(page, false);
put_page(page); /* remove page count along with mapcount */
mmu_notifier_invalidate_range(mm, address,
address + PAGE_SIZE);
/* remove_migration_pte */
get_page(newpage);
newpte = pte_mkold(mk_pte(newpage,
READ_ONCE(vma->vm_page_prot)));
if (pte_soft_dirty(pteval))
newpte = pte_mksoft_dirty(newpte);
if (pte_write(pteval))
newpte = maybe_mkwrite(newpte, vma->vm_flags);
flush_dcache_page(newpage);
set_pte_at(vma->vm_mm, pvmw.address, pvmw.pte, newpte);
page_add_anon_rmap(newpage, vma, pvmw.address, false);
if (vma->vm_flags & VM_LOCKED)
mlock_vma_page(newpage);
update_mmu_cache(vma, pvmw.address, pvmw.pte);
}
mmu_notifier_invalidate_range_end(vma->vm_mm, start, end);
return true;
}
static int is_zero_page_mapcount(struct page *page)
{
return !total_mapcount(page);
}
/* copied from is_vma_temporary_stack() in mm/rmap.c */
static bool is_invalid_migration_vma(struct vm_area_struct *vma, void *arg)
{
int maybe_stack = vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP);
if (!maybe_stack)
return false;
if ((vma->vm_flags & VM_STACK_INCOMPLETE_SETUP) ==
VM_STACK_INCOMPLETE_SETUP)
return true;
return false;
}
int migrate_anon_page(struct page *page, struct page *newpage)
{
struct rmap_walk_control rwc = {
.rmap_one = migrate_anon_page_one,
.arg = newpage,
.done = is_zero_page_mapcount,
.anon_lock = page_lock_anon_vma_read,
/*
* During exec, a temporary VMA is setup and later moved.
* The VMA is moved under the anon_vma lock but not the
* page tables leading to a race where migration cannot
* find the migration ptes. Rather than increasing the
* locking requirements of exec(), migration skips
* temporary VMAs until after exec() completes.
*/
.invalid_vma = is_invalid_migration_vma,
};
int rc;
int refcount, mapcount;
/*
* We are doing irreversible anonymous page migration because we
* abandoned migration pte. Therefore we should delegate migration
* of pinned anonymous pages to try_to_unmap() that handles all
* exceptional cases.
*/
if (page_mapcount(page) != page_count(page) - 1)
return -EBUSY;
if (PageHWPoison(page) || !PageAnon(page) || PageSwapCache(page) ||
PageCompound(page) || PageHuge(page) || PageKsm(page))
return -EAGAIN;
VM_BUG_ON_PAGE(!PageLocked(page), page);
VM_BUG_ON_PAGE(!PageLocked(newpage), newpage);
refcount = page_count(page);
mapcount = page_mapcount(page);
rmap_walk(page, &rwc);
if ((refcount != page_count(newpage)) ||
(mapcount != page_mapcount(newpage))) {
pr_err("unbalanced counts(%pGp): mapcnt %d->%d, cnt %d->%d\n",
&newpage->flags, mapcount, page_mapcount(newpage),
refcount, page_count(newpage));
rc = -EBUSY;
goto revert;
}
/*
* We migrate reverse mapping after completing pte migration.
* It is safe for now iff the page is anonymous single page.
*/
rc = migrate_page(NULL, newpage, page, MIGRATE_SYNC);
if (rc != MIGRATEPAGE_SUCCESS) {
pr_err("Failed to migrate page\n");
goto revert;
}
return rc;
revert:
rwc.arg = page;
/* rervert migration */
rmap_walk(newpage, &rwc);
return rc;
}
static int isolate_movable_pages(unsigned long start_pfn, unsigned int nr_pages,
struct list_head *nonfile, struct list_head *nonlru,
struct list_head *pagecache)
{
unsigned long pfn;
unsigned long pfn_end = start_pfn + nr_pages;
LIST_HEAD(nonfiles);
LIST_HEAD(pagecaches);
int ret = 0;
int count = 0;
for (pfn = start_pfn; pfn < pfn_end; pfn++) {
struct page *page;
if (!pfn_valid(pfn))
continue;
page = pfn_to_page(pfn);
if (PageHuge(page)) {
struct page *head = compound_head(page);
pfn = page_to_pfn(head) + (1 << compound_order(head)) - 1;
if (compound_order(head) > PFN_SECTION_SHIFT) {
pr_err("too large huge page %#lx (>section)\n",
page_to_pfn(head));
ret = -EBUSY;
goto fail;
}
if (!isolate_huge_page(page, nonfile)) {
pr_err("failed to isolate hpage %#lx(odr %d)\n",
page_to_pfn(head), compound_order(head));
ret = -EBUSY;
goto fail;
}
count += 1 << compound_order(head);
continue;
} else if (thp_migration_supported() && PageTransHuge(page))
pfn = page_to_pfn(compound_head(page))
+ hpage_nr_pages(page) - 1;
/*
* HWPoison pages have elevated reference counts so the
* migration would fail on them. It also doesn't make any sense
* to migrate them in the first place. Still try to unmap such a
* page in case it is still mapped (e.g. current hwpoison
* implementation doesn't unmap KSM pages but keep the unmap as
* the catch all safety net).
*/
if (PageHWPoison(page)) {
if (WARN_ON(PageLRU(page)))
isolate_lru_page(page);
if (page_mapped(page))
try_to_unmap(page,
TTU_IGNORE_MLOCK | TTU_IGNORE_ACCESS, NULL);
continue;
}
/*
* We can skip free pages because the free pages are in the
* freelist of MIGRATE_ISOLATE.
*/
if (!get_page_unless_zero(page))
continue;
ret = PageLRU(page) ? isolate_lru_page(page)
: isolate_movable_page(page,
ISOLATE_UNEVICTABLE);
if (!ret) { /* Success */
put_page(page);
if (__PageMovable(page) || PageUnevictable(page)) {
list_add_tail(&page->lru, nonlru);
} else if (page_is_file_cache(page) &&
!PageDirty(page) && !PageUnevictable(page)) {
list_add_tail(&page->lru, pagecache);
} else {
list_add_tail(&page->lru, nonfile);
}
if (!__PageMovable(page))
inc_node_page_state(page, NR_ISOLATED_ANON +
page_is_file_cache(page));
count++;
} else {
pr_alert_ratelimited("isolation failed: "
"pfn %#lx(%pGp,cnt%d,mapcnt%d)\n",
pfn, &page->flags,
page_count(page),
page_mapcount(page));
if (IS_ENABLED(CONFIG_DEBUG_VM))
dump_page(page, "isolation failed");
put_page(page);
/* Because we don't have big zone->lock. we should
check this again here. */
if (page_count(page))
goto fail;
}
}
return count;
fail:
putback_movable_pages(nonfile);
putback_movable_pages(pagecache);
putback_movable_pages(nonlru);
return ret;
}
static struct page *get_migrate_target(struct page *page, unsigned long private)
{
gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL;
unsigned int order = 0;
struct page *new_page = NULL;
if (PageHuge(page))
return alloc_huge_page_nodemask(page_hstate(compound_head(page)),
preferred_nid, nodemask);
if (thp_migration_supported() && PageTransHuge(page)) {
order = HPAGE_PMD_ORDER;
gfp_mask |= GFP_TRANSHUGE;
}
if (PageHighMem(page))
gfp_mask |= __GFP_HIGHMEM;
new_page = alloc_pages(gfp_mask, order);
if (new_page && PageTransHuge(new_page))
prep_transhuge_page(new_page);
return new_page;
}
static int reclaim_pages_list(unsigned long start_pfn, unsigned int nr_pages,
struct list_head *nonfile,
struct list_head *nonlru,
struct list_head *pagecache,
enum migrate_reason reason)
{
if (!list_empty(pagecache)) {
struct zone *zone = page_zone(pfn_to_page(start_pfn));
enum ttu_flags flags = 0;
unsigned long freed;
if (reason == MR_MEMORY_HOTPLUG)
flags |= TTU_FORCE_BATCH_FLUSH;
freed = reclaim_clean_pages_from_list(zone, pagecache, flags);
if (!list_empty(pagecache))
list_splice(pagecache, nonfile);
mod_node_page_state(zone->zone_pgdat, NR_ISOLATED_FILE, -freed);
}
/*
* Let's migrate non-lru movable pages before migrating anonymous pages.
* It's because non-lru movable pages are more easily migrated than anon
* pages. Memory hot-plug will soon retry page migration on the same
* page block because it should migrate all pages in the victim section.
* We want to migrate more pages in the first try.
*/
if (!list_empty(nonlru)) {
migrate_pages(nonlru, get_migrate_target, NULL, 0,
MIGRATE_SYNC, reason);
/*
* give second chance to non lru/unevictable pages
* nonlru list may have freed pages but it is okay because
* migrate_pages() skips such pages.
*/
list_splice(nonlru, nonfile);
}
if (!list_empty(nonfile)) {
int ret = migrate_pages(nonfile, get_migrate_target, NULL, 0,
MIGRATE_SYNC, reason);
if (ret) {
pr_err("failed to migrate pages in [%#lx, %#lx) (%d)\n",
start_pfn, start_pfn + nr_pages, ret);
putback_movable_pages(nonfile);
return -EAGAIN;
}
}
return 0;
}
static int reclaim_page_block(unsigned long blk_start_pfn, int mode, int reason)
{
LIST_HEAD(nonfile);
LIST_HEAD(nonlru);
LIST_HEAD(pagecache);
int ret;
ret = isolate_movable_pages(blk_start_pfn, pageblock_nr_pages,
&nonfile, &nonlru, &pagecache);
if (ret < 0)
return ret;
ret = reclaim_pages_list(blk_start_pfn, pageblock_nr_pages,
&nonfile, &nonlru, &pagecache, reason);
if (ret < 0)
return ret;
return 0;
}
/*
* reclaim_pages_range - reclaim/migrate all lru/movable pages in given range
* @start_pfn: pfn of the first page to reclaim.
* should be aligned by pageblock_nr_pages.
* @count: number of pages from @start_pfn to reclaim.
* should be aligned by pageblock_nr_pages.
* @mode: options to control migration/reclamation logic.
* @reason: information for debugging purpose
*
* Return 0 if all @count pages from @start_pfn are free or reclaimed.
* -error otherwise.
*
* On success, PageBuddy() of all pages in the given range is true unless a page
* is in per-cpu freelist. If a user wants to get guaranteed the pages in the
* range free, he/she must turn the migratetype of page blocks of the pages to
* MIGRATE_ISOLATE with start_isolate_page_range().
*/
int reclaim_pages_range(unsigned long start_pfn, unsigned long count,
int mode, int reason)
{
unsigned long pfn = start_pfn;
unsigned long end_pfn = start_pfn + count;
int ret = 0;
BUG_ON(!IS_ALIGNED(start_pfn, pageblock_nr_pages));
BUG_ON(!IS_ALIGNED(end_pfn, pageblock_nr_pages));
while (pfn < end_pfn) {
ret = reclaim_page_block(pfn, mode, reason);
if (ret < 0) {
pr_err("failed to reclaim page block at %#lx (%d)\n",
pfn, ret);
goto err;
}
pfn += pageblock_nr_pages;
}
err:
try_to_unmap_flush();
return ret;
}
static bool page_steal_available(unsigned long pfn, unsigned int order)
{
unsigned long pfn_end = pfn + (1 << order);
while (pfn < pfn_end) {
struct page *page = pfn_to_page(pfn);
if (!pfn_valid_within(pfn))
return false;
if (PageBuddy(page)) {
pfn += 1 << page_order(page);
continue;
}
if (PageCompound(page) || PageReserved(page))
return false;
if (!PageLRU(page) && !__PageMovable(page))
return false;
pfn++;
}
return true;
}
int steal_pages(unsigned long pfn, unsigned int order)
{
struct page *page = pfn_to_page(pfn);
struct zone *zone = page_zone(page);
LIST_HEAD(nonfile);
LIST_HEAD(nonlru);
LIST_HEAD(file);
unsigned long flags;
int ret;
if (!IS_ALIGNED(pfn, 1 << order) || (order > pageblock_order)) {
pr_err("invalid order %d with pfn %#lx\n", order, pfn);
return -EINVAL;
}
if (!page_steal_available(pfn, order))
return -EBUSY;
ret = isolate_movable_pages(pfn, 1 << order, &nonfile, &nonlru, &file);
if (ret < 0)
return ret;
ret = reclaim_pages_list(pfn, 1 << order, &nonfile, &nonlru, &file,
MR_CONTIG_RANGE);
if (ret < 0)
return ret;
spin_lock_irqsave(&zone->lock, flags);
if (!PageBuddy(page) ||
(page_order(page) != order) || !__isolate_free_page(page, order)) {
spin_unlock_irqrestore(&zone->lock, flags);
return -EAGAIN;
}
spin_unlock_irqrestore(&zone->lock, flags);
post_alloc_hook(page, order, __GFP_MOVABLE);
return 0;
}
/*
* test procedure:
* 1. write the base pfn to debugfs/base_pfn
* 2. write the page count to debugfs/steal
* 3. notice the result
* 4. write 0 to debugfs/steal to return the stolen pages to the system.
*/
/* updated by writing to debugfs/base_pfn */
int test_reclaim_pages_range(unsigned long start_pfn, int count)
{
int ret;
unsigned long nr_pages = ALIGN(count, pageblock_nr_pages);
unsigned long base_pfn = start_pfn;
unsigned long end_pfn = start_pfn + count;
ktime_t begin, isolate, steal, end;
if (!pfn_valid(start_pfn) || !pfn_valid(end_pfn - 1)) {
pr_err("start/end [%#lx, %#lx] is not valid\n",
start_pfn, end_pfn - 1);
return -EINVAL;
}
if (page_zone(pfn_to_page(start_pfn)) !=
page_zone(pfn_to_page(end_pfn - 1))) {
pr_err("stealing pages in different zones is not allowed\n");
return -EINVAL;
}
for (base_pfn = start_pfn; base_pfn < end_pfn;
base_pfn += pageblock_nr_pages) {
if (MIGRATE_ISOLATE ==
get_pageblock_migratetype(pfn_to_page(base_pfn))) {
pr_err("found isolated pageblock at pfn %#lx\n",
base_pfn);
return -EBUSY;
}
}
freeze_processes();
begin = ktime_get();
/*
* we make all page blocks in [start_pfn, start_pfn + count)
* MIGRATE_MOVABLE when this function ends. This is okay due to the
* following reasons:
* 1. If start_isolated_pages_range() succeeds, no page in the given
* range is unmovable.
* 2. If stealing succeeds, the proper migratetype of the page blocks in
* the range is MIGRATE_MOVABLE because all pages in the page blocks
* are free.
*/
ret = start_isolate_page_range(start_pfn, end_pfn,
MIGRATE_MOVABLE, false);
if (ret < 0) {
pr_err("failed isolating pages in [%#lx, %#lx)\n",
start_pfn, end_pfn);
goto err;
}
isolate = ktime_get();
lru_add_drain_all();
drain_all_pages(page_zone(pfn_to_page(start_pfn)));
steal = ktime_get();
ret = reclaim_pages_range(start_pfn, nr_pages,
MIGRATE_SYNC, MR_MEMORY_HOTPLUG);
if (ret < 0) {
pr_err("failed stealing pages in [%#lx, %#lx)\n",
start_pfn, end_pfn);
undo_isolate_page_range(start_pfn, end_pfn, MIGRATE_MOVABLE);
}
end = ktime_get();
err:
thaw_processes();
if (ret < 0)
return ret;
pr_info("stolen %lu pages in %llu msec.(drn,islt,stel %llu %llu %llu)\n",
nr_pages, ktime_ms_delta(end, begin),
ktime_ms_delta(steal, isolate),
ktime_ms_delta(isolate, begin),
ktime_ms_delta(end, steal));
return (int)nr_pages;
}
static unsigned long page_steal_debugfs_base_pfn;
/* updated by writing to debugfs/steal, identified by reading debugfs/count */
static int page_steal_debugfs_count;
DEFINE_MUTEX(page_steal_debugfs_lock);
static int page_steal_debugfs_steal_write(void *data, u64 val)
{
unsigned long base = page_steal_debugfs_base_pfn;
int count = (int)val;
int ret;
if (base + count < base) {
pr_err("too many page count %d\n", count);
return -EINVAL;
}
ret = mutex_lock_interruptible(&page_steal_debugfs_lock);
if (ret < 0)
return ret;
if (count == 0) {
if (page_steal_debugfs_count != 0) {
unsigned long end = base + page_steal_debugfs_count;
/*
* pages are not allocated but remained in the free list
* of MIGRATE_ISOLATE.
*/
undo_isolate_page_range(base, end, MIGRATE_MOVABLE);
page_steal_debugfs_count = 0;
}
mutex_unlock(&page_steal_debugfs_lock);
return 0;
}
ret = test_reclaim_pages_range(base, count);
if (ret > 0)
page_steal_debugfs_count = ret;
mutex_unlock(&page_steal_debugfs_lock);
if (!ret)
return -EBUSY;
if (ret < 0)
return ret;
return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(page_steal_debugfs_steal_fops, NULL,
page_steal_debugfs_steal_write, "%llu\n");
static int page_steal_debugfs_base_pfn_get(void *data, u64 *val)
{
*val = page_steal_debugfs_base_pfn;
return 0;
}
static int page_steal_debugfs_base_pfn_set(void *data, u64 val)
{
unsigned long pfn = ALIGN_DOWN(val, pageblock_nr_pages);
int ret;
if (!pfn_valid(pfn)) {
pr_err("invalid pfn %#lx\n", pfn);
return -EINVAL;
}
ret = mutex_lock_interruptible(&page_steal_debugfs_lock);
if (ret < 0)
return ret;
if (page_steal_debugfs_count != 0) {
/*
* changing debugfs/base_pfn is not allowed during a page is stolen
* to return the stolen pages correctly.
*/
mutex_unlock(&page_steal_debugfs_lock);
return -EBUSY;
}
page_steal_debugfs_base_pfn = pfn;
mutex_unlock(&page_steal_debugfs_lock);
return 0;
}
DEFINE_SIMPLE_ATTRIBUTE(page_steal_debugfs_base_pfn_fops,
page_steal_debugfs_base_pfn_get,
page_steal_debugfs_base_pfn_set, "0x%016llx\n");
static struct dentry *page_steal_debugfs_root;
static int __init page_steal_debugfs_init(void)
{
page_steal_debugfs_root = debugfs_create_dir("page_steal", NULL);
if (!page_steal_debugfs_root)
return -ENOMEM;
debugfs_create_file("steal", 0200,
page_steal_debugfs_root,
NULL,
&page_steal_debugfs_steal_fops);
debugfs_create_file("base_pfn", 0600,
page_steal_debugfs_root,
NULL,
&page_steal_debugfs_base_pfn_fops);
debugfs_create_u32("count", 0400,
page_steal_debugfs_root,
&page_steal_debugfs_count);
return 0;
}
late_initcall(page_steal_debugfs_init);