]> xenbits.xensource.com Git - libvirt.git/commitdiff
nodeinfo: Get rid of nodeGetCellMemory
authorPeter Krempa <pkrempa@redhat.com>
Fri, 18 Oct 2013 10:18:56 +0000 (12:18 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 4 Nov 2013 09:50:20 +0000 (10:50 +0100)
The function was called in a single place only and was reporting errors
that were later ignored. Use the virNumaGetNodeMemory helper to get the
size of the memory in the NUMA node and remove the helper

src/nodeinfo.c

index 0c7669de4007005f776287215a7d7d955ab1b789..6e8593b4c4087416e1c9594d9afaea1c5e443123 100644 (file)
@@ -1545,8 +1545,6 @@ nodeGetFreeMemoryFake(void)
 # define MASK_CPU_ISSET(mask, cpu) \
   (((mask)[((cpu) / n_bits(*(mask)))] >> ((cpu) % n_bits(*(mask)))) & 1)
 
-static unsigned long long nodeGetCellMemory(int cell);
-
 static virBitmapPtr
 virNodeGetSiblingsList(const char *dir, int cpu_id)
 {
@@ -1637,8 +1635,9 @@ nodeCapsInitNUMA(virCapsPtr caps)
             continue;
         }
 
-        /* Detect the amount of memory in the numa cell */
-        memory = nodeGetCellMemory(n);
+        /* Detect the amount of memory in the numa cell in KiB */
+        virNumaGetNodeMemory(n, &memory, NULL);
+        memory >>= 10;
 
         for (ncpus = 0, i = 0; i < max_n_cpus; i++)
             if (MASK_CPU_ISSET(mask, i))
@@ -1736,46 +1735,6 @@ nodeGetFreeMemory(void)
     return freeMem;
 }
 
-/**
- * nodeGetCellMemory
- * @cell: The number of the numa cell to get memory info for.
- *
- * Request size of memory in a NUMA node.
- *
- * Returns 0 if unavailable, amount of memory in KiB on success.
- */
-static unsigned long long nodeGetCellMemory(int cell)
-{
-    unsigned long long mem;
-    unsigned long long memKiB = 0;
-    int maxCell;
-
-    /* Make sure the provided cell number is valid. */
-    if ((maxCell = virNumaGetMaxNode()) < 0)
-        goto cleanup;
-
-    if (cell > maxCell) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("cell %d out of range (0-%d)"),
-                       cell, maxCell);
-        goto cleanup;
-    }
-
-    /* Get the amount of memory(bytes) in the node */
-    if (virNumaGetNodeMemory(cell, &mem, NULL) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("Failed to query NUMA total memory for node: %d"),
-                       cell);
-        goto cleanup;
-    }
-
-    /* Convert the memory from bytes to KiB */
-    memKiB = mem >> 10;
-
-cleanup:
-    return memKiB;
-}
-
 
 #else
 int nodeCapsInitNUMA(virCapsPtr caps) {