powerpc: Add kdump support to Collaborative Memory Manager
authorBrian King <brking@linux.vnet.ibm.com>
Mon, 19 Oct 2009 05:51:34 +0000 (05:51 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Fri, 30 Oct 2009 06:20:56 +0000 (17:20 +1100)
When running Active Memory Sharing, the Collaborative Memory Manager (CMM)
may mark some pages as "loaned" with the hypervisor. Periodically, the
CMM will query the hypervisor for a loan request, which is a single signed
value. When kexec'ing into a kdump kernel, the CMM driver in the kdump
kernel is not aware of the pages the previous kernel had marked as "loaned",
so the hypervisor and the CMM driver are out of sync. Fix the CMM driver
to handle this scenario by ignoring requests to decrease the number of loaned
pages if we don't think we have any pages loaned. Pages that are marked as
"loaned" which are not in the balloon will automatically get switched to "active"
the next time we touch the page. This also fixes the case where totalram_pages
is smaller than min_mem_mb, which can occur during kdump.

Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/platforms/pseries/Kconfig
arch/powerpc/platforms/pseries/cmm.c

index 26a24bd926233c7cea09336d4820bf5e4a5adc52..27554c807fd503ffea29fb966438ce2f6e229052 100644 (file)
@@ -60,7 +60,7 @@ config PPC_SMLPAR
 
 config CMM
        tristate "Collaborative memory management"
-       depends on PPC_SMLPAR && !CRASH_DUMP
+       depends on PPC_SMLPAR
        default y
        help
          Select this option, if you want to enable the kernel interface
index 6567439fe78dda4512e0524332255df66b5816a1..bcdcf0ccc8d799ffde04e138e1b6fa2736d968e2 100644 (file)
@@ -229,8 +229,9 @@ static void cmm_get_mpp(void)
 {
        int rc;
        struct hvcall_mpp_data mpp_data;
-       unsigned long active_pages_target;
-       signed long page_loan_request;
+       signed long active_pages_target, page_loan_request, target;
+       signed long total_pages = totalram_pages + loaned_pages;
+       signed long min_mem_pages = (min_mem_mb * 1024 * 1024) / PAGE_SIZE;
 
        rc = h_get_mpp(&mpp_data);
 
@@ -238,17 +239,25 @@ static void cmm_get_mpp(void)
                return;
 
        page_loan_request = div_s64((s64)mpp_data.loan_request, PAGE_SIZE);
-       loaned_pages_target = page_loan_request + loaned_pages;
-       if (loaned_pages_target > oom_freed_pages)
-               loaned_pages_target -= oom_freed_pages;
+       target = page_loan_request + (signed long)loaned_pages;
+
+       if (target < 0 || total_pages < min_mem_pages)
+               target = 0;
+
+       if (target > oom_freed_pages)
+               target -= oom_freed_pages;
        else
-               loaned_pages_target = 0;
+               target = 0;
+
+       active_pages_target = total_pages - target;
+
+       if (min_mem_pages > active_pages_target)
+               target = total_pages - min_mem_pages;
 
-       active_pages_target = totalram_pages + loaned_pages - loaned_pages_target;
+       if (target < 0)
+               target = 0;
 
-       if ((min_mem_mb * 1024 * 1024) > (active_pages_target * PAGE_SIZE))
-               loaned_pages_target = totalram_pages + loaned_pages -
-                       ((min_mem_mb * 1024 * 1024) / PAGE_SIZE);
+       loaned_pages_target = target;
 
        cmm_dbg("delta = %ld, loaned = %lu, target = %lu, oom = %lu, totalram = %lu\n",
                page_loan_request, loaned_pages, loaned_pages_target,