From 11bf19bc0eb48735772e664d07573f916f6e3f29 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 3 Sep 2002 05:33:46 -0700 Subject: [PATCH] [PATCH] place rmap locking in rmap-locking.h The rmap locking inlines are causing some header file dependency/ordering problems - move them out of page-flags.h and into their own header file. --- include/linux/page-flags.h | 30 ------------------------------ include/linux/rmap-locking.h | 33 +++++++++++++++++++++++++++++++++ mm/rmap.c | 1 + mm/vmscan.c | 1 + 4 files changed, 35 insertions(+), 30 deletions(-) create mode 100644 include/linux/rmap-locking.h diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 5a49020e728b..2b2eb67ae7a8 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -228,36 +228,6 @@ extern void get_page_state(struct page_state *ret); #define ClearPageDirect(page) clear_bit(PG_direct, &(page)->flags) #define TestClearPageDirect(page) test_and_clear_bit(PG_direct, &(page)->flags) -/* - * inlines for acquisition and release of PG_chainlock - */ -static inline void pte_chain_lock(struct page *page) -{ - /* - * Assuming the lock is uncontended, this never enters - * the body of the outer loop. If it is contended, then - * within the inner loop a non-atomic test is used to - * busywait with less bus contention for a good time to - * attempt to acquire the lock bit. - */ - preempt_disable(); -#ifdef CONFIG_SMP - while (test_and_set_bit(PG_chainlock, &page->flags)) { - while (test_bit(PG_chainlock, &page->flags)) - cpu_relax(); - } -#endif -} - -static inline void pte_chain_unlock(struct page *page) -{ -#ifdef CONFIG_SMP - smp_mb__before_clear_bit(); - clear_bit(PG_chainlock, &page->flags); -#endif - preempt_enable(); -} - /* * The PageSwapCache predicate doesn't use a PG_flag at this time, * but it may again do so one day. diff --git a/include/linux/rmap-locking.h b/include/linux/rmap-locking.h new file mode 100644 index 000000000000..302a58f54ca3 --- /dev/null +++ b/include/linux/rmap-locking.h @@ -0,0 +1,33 @@ +/* + * include/linux/rmap-locking.h + * + * Locking primitives for exclusive access to a page's reverse-mapping + * pte chain. + */ + +static inline void pte_chain_lock(struct page *page) +{ + /* + * Assuming the lock is uncontended, this never enters + * the body of the outer loop. If it is contended, then + * within the inner loop a non-atomic test is used to + * busywait with less bus contention for a good time to + * attempt to acquire the lock bit. + */ + preempt_disable(); +#ifdef CONFIG_SMP + while (test_and_set_bit(PG_chainlock, &page->flags)) { + while (test_bit(PG_chainlock, &page->flags)) + cpu_relax(); + } +#endif +} + +static inline void pte_chain_unlock(struct page *page) +{ +#ifdef CONFIG_SMP + smp_mb__before_clear_bit(); + clear_bit(PG_chainlock, &page->flags); +#endif + preempt_enable(); +} diff --git a/mm/rmap.c b/mm/rmap.c index 727e50efca39..5c98c1758dea 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include diff --git a/mm/vmscan.c b/mm/vmscan.c index 41712a97b079..a00fe27159d9 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -25,6 +25,7 @@ #include /* for try_to_release_page() */ #include #include +#include #include #include -- 2.39.5