aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-generic
diff options
context:
space:
mode:
authorAndrea Arcangeli <aarcange@redhat.com>2012-10-03 19:50:47 -0400
committerMel Gorman <mgorman@suse.de>2012-12-11 09:42:36 -0500
commitbe3a728427a605990a7a0b6dbf9e29b68e266146 (patch)
tree878fb07cca478c4444d85fc26fc16c9f574034a3 /include/asm-generic
parentdbe4d2035a5b273c910f8f7eb0b7189ee76f63ad (diff)
mm: numa: pte_numa() and pmd_numa()
Implement pte_numa and pmd_numa. We must atomically set the numa bit and clear the present bit to define a pte_numa or pmd_numa. Once a pte or pmd has been set as pte_numa or pmd_numa, the next time a thread touches a virtual address in the corresponding virtual range, a NUMA hinting page fault will trigger. The NUMA hinting page fault will clear the NUMA bit and set the present bit again to resolve the page fault. The expectation is that a NUMA hinting page fault is used as part of a placement policy that decides if a page should remain on the current node or migrated to a different node. Acked-by: Rik van Riel <riel@redhat.com> Signed-off-by: Andrea Arcangeli <aarcange@redhat.com> Signed-off-by: Mel Gorman <mgorman@suse.de>
Diffstat (limited to 'include/asm-generic')
-rw-r--r--include/asm-generic/pgtable.h106
1 files changed, 106 insertions, 0 deletions
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index 48fc1dc1c74b..f27c83668d10 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -558,6 +558,112 @@ static inline int pmd_trans_unstable(pmd_t *pmd)
558#endif 558#endif
559} 559}
560 560
561#ifdef CONFIG_NUMA_BALANCING
562#ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
563/*
564 * _PAGE_NUMA works identical to _PAGE_PROTNONE (it's actually the
565 * same bit too). It's set only when _PAGE_PRESET is not set and it's
566 * never set if _PAGE_PRESENT is set.
567 *
568 * pte/pmd_present() returns true if pte/pmd_numa returns true. Page
569 * fault triggers on those regions if pte/pmd_numa returns true
570 * (because _PAGE_PRESENT is not set).
571 */
572#ifndef pte_numa
573static inline int pte_numa(pte_t pte)
574{
575 return (pte_flags(pte) &
576 (_PAGE_NUMA|_PAGE_PRESENT)) == _PAGE_NUMA;
577}
578#endif
579
580#ifndef pmd_numa
581static inline int pmd_numa(pmd_t pmd)
582{
583 return (pmd_flags(pmd) &
584 (_PAGE_NUMA|_PAGE_PRESENT)) == _PAGE_NUMA;
585}
586#endif
587
588/*
589 * pte/pmd_mknuma sets the _PAGE_ACCESSED bitflag automatically
590 * because they're called by the NUMA hinting minor page fault. If we
591 * wouldn't set the _PAGE_ACCESSED bitflag here, the TLB miss handler
592 * would be forced to set it later while filling the TLB after we
593 * return to userland. That would trigger a second write to memory
594 * that we optimize away by setting _PAGE_ACCESSED here.
595 */
596#ifndef pte_mknonnuma
597static inline pte_t pte_mknonnuma(pte_t pte)
598{
599 pte = pte_clear_flags(pte, _PAGE_NUMA);
600 return pte_set_flags(pte, _PAGE_PRESENT|_PAGE_ACCESSED);
601}
602#endif
603
604#ifndef pmd_mknonnuma
605static inline pmd_t pmd_mknonnuma(pmd_t pmd)
606{
607 pmd = pmd_clear_flags(pmd, _PAGE_NUMA);
608 return pmd_set_flags(pmd, _PAGE_PRESENT|_PAGE_ACCESSED);
609}
610#endif
611
612#ifndef pte_mknuma
613static inline pte_t pte_mknuma(pte_t pte)
614{
615 pte = pte_set_flags(pte, _PAGE_NUMA);
616 return pte_clear_flags(pte, _PAGE_PRESENT);
617}
618#endif
619
620#ifndef pmd_mknuma
621static inline pmd_t pmd_mknuma(pmd_t pmd)
622{
623 pmd = pmd_set_flags(pmd, _PAGE_NUMA);
624 return pmd_clear_flags(pmd, _PAGE_PRESENT);
625}
626#endif
627#else
628extern int pte_numa(pte_t pte);
629extern int pmd_numa(pmd_t pmd);
630extern pte_t pte_mknonnuma(pte_t pte);
631extern pmd_t pmd_mknonnuma(pmd_t pmd);
632extern pte_t pte_mknuma(pte_t pte);
633extern pmd_t pmd_mknuma(pmd_t pmd);
634#endif /* CONFIG_ARCH_USES_NUMA_PROT_NONE */
635#else
636static inline int pmd_numa(pmd_t pmd)
637{
638 return 0;
639}
640
641static inline int pte_numa(pte_t pte)
642{
643 return 0;
644}
645
646static inline pte_t pte_mknonnuma(pte_t pte)
647{
648 return pte;
649}
650
651static inline pmd_t pmd_mknonnuma(pmd_t pmd)
652{
653 return pmd;
654}
655
656static inline pte_t pte_mknuma(pte_t pte)
657{
658 return pte;
659}
660
661static inline pmd_t pmd_mknuma(pmd_t pmd)
662{
663 return pmd;
664}
665#endif /* CONFIG_NUMA_BALANCING */
666
561#endif /* CONFIG_MMU */ 667#endif /* CONFIG_MMU */
562 668
563#endif /* !__ASSEMBLY__ */ 669#endif /* !__ASSEMBLY__ */