[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [linux-2.6.18-xen] streamline clearing of memory in a few places



# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxx>
# Date 1318491236 -7200
# Node ID e8e3b1247124e6e9ae603a7f8ed845ebb2b28171
# Parent  f4a4962d40e425e13af4401e0f44141f82828064
streamline clearing of memory in a few places

- use kzalloc() in favor of kmalloc()+memset() in one more spot
- use clear_page() in favor of memset(, 0, PAGE_SIZE) (also use
  copy_page() in favor of memcpy(, , PAGE_SIZE))
- don't redundantly clear memory

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---


diff -r f4a4962d40e4 -r e8e3b1247124 arch/i386/mm/init-xen.c
--- a/arch/i386/mm/init-xen.c   Thu Oct 13 09:30:50 2011 +0200
+++ b/arch/i386/mm/init-xen.c   Thu Oct 13 09:33:56 2011 +0200
@@ -558,7 +558,7 @@
         * dummy page. */
        set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
        HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
-       memset(empty_zero_page, 0, sizeof(empty_zero_page));
+       clear_page(empty_zero_page);
 
        /* Setup mapping of lower 1st MB */
        for (i = 0; i < NR_FIX_ISAMAPS; i++)
diff -r f4a4962d40e4 -r e8e3b1247124 arch/x86_64/mm/init-xen.c
--- a/arch/x86_64/mm/init-xen.c Thu Oct 13 09:30:50 2011 +0200
+++ b/arch/x86_64/mm/init-xen.c Thu Oct 13 09:33:56 2011 +0200
@@ -218,7 +218,7 @@
        else if (start_pfn < table_end) {
                ptr = __va(start_pfn << PAGE_SHIFT);
                start_pfn++;
-               memset(ptr, 0, PAGE_SIZE);
+               clear_page(ptr);
        } else
                ptr = alloc_bootmem_pages(PAGE_SIZE);
        if (!ptr || ((unsigned long)ptr & ~PAGE_MASK))
@@ -376,7 +376,7 @@
 
        *phys = start_pfn << PAGE_SHIFT;
        start_pfn++;
-       memset((void *)va, 0, PAGE_SIZE);
+       clear_page((void *)va);
        return (void *)va;
 } 
 
@@ -728,7 +728,7 @@
        /* Switch to the real shared_info page, and clear the dummy page. */
        set_fixmap(FIX_SHARED_INFO, xen_start_info->shared_info);
        HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
-       memset(empty_zero_page, 0, sizeof(empty_zero_page));
+       clear_page(empty_zero_page);
 
        /* Set up mapping of lowest 1MB of physical memory. */
        for (i = 0; i < NR_FIX_ISAMAPS; i++)
diff -r f4a4962d40e4 -r e8e3b1247124 drivers/xen/core/gnttab.c
--- a/drivers/xen/core/gnttab.c Thu Oct 13 09:30:50 2011 +0200
+++ b/drivers/xen/core/gnttab.c Thu Oct 13 09:33:56 2011 +0200
@@ -543,7 +543,7 @@
 
        new_addr = page_address(new_page);
        addr = page_address(page);
-       memcpy(new_addr, addr, PAGE_SIZE);
+       copy_page(new_addr, addr);
 
        pfn = page_to_pfn(page);
        mfn = pfn_to_mfn(pfn);
diff -r f4a4962d40e4 -r e8e3b1247124 drivers/xen/core/machine_reboot.c
--- a/drivers/xen/core/machine_reboot.c Thu Oct 13 09:30:50 2011 +0200
+++ b/drivers/xen/core/machine_reboot.c Thu Oct 13 09:33:56 2011 +0200
@@ -89,7 +89,7 @@
                BUG();
        HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
 
-       memset(empty_zero_page, 0, PAGE_SIZE);
+       clear_page(empty_zero_page);
 
        fpp = PAGE_SIZE/sizeof(unsigned long);
        for (i = 0, j = 0, k = -1; i < max_pfn; i += fpp, j++) {
diff -r f4a4962d40e4 -r e8e3b1247124 drivers/xen/core/smpboot.c
--- a/drivers/xen/core/smpboot.c        Thu Oct 13 09:30:50 2011 +0200
+++ b/drivers/xen/core/smpboot.c        Thu Oct 13 09:33:56 2011 +0200
@@ -198,17 +198,12 @@
        ctxt.flags = VGCF_IN_KERNEL;
        ctxt.user_regs.ds = __USER_DS;
        ctxt.user_regs.es = __USER_DS;
-       ctxt.user_regs.fs = 0;
-       ctxt.user_regs.gs = 0;
        ctxt.user_regs.ss = __KERNEL_DS;
        ctxt.user_regs.eip = (unsigned long)cpu_bringup_and_idle;
        ctxt.user_regs.eflags = X86_EFLAGS_IF | 0x1000; /* IOPL_RING1 */
 
-       memset(&ctxt.fpu_ctxt, 0, sizeof(ctxt.fpu_ctxt));
-
        smp_trap_init(ctxt.trap_ctxt);
 
-       ctxt.ldt_ents = 0;
 
        ctxt.gdt_frames[0] = virt_to_mfn(gdt_descr->address);
        ctxt.gdt_ents      = gdt_descr->size / 8;
diff -r f4a4962d40e4 -r e8e3b1247124 drivers/xen/netback/interface.c
--- a/drivers/xen/netback/interface.c   Thu Oct 13 09:30:50 2011 +0200
+++ b/drivers/xen/netback/interface.c   Thu Oct 13 09:33:56 2011 +0200
@@ -236,7 +236,6 @@
        SET_NETDEV_DEV(dev, parent);
 
        netif = netdev_priv(dev);
-       memset(netif, 0, sizeof(*netif));
        netif->domid  = domid;
        netif->handle = handle;
        netif->can_sg = 1;
diff -r f4a4962d40e4 -r e8e3b1247124 drivers/xen/sfc_netutil/accel_cuckoo_hash.c
--- a/drivers/xen/sfc_netutil/accel_cuckoo_hash.c       Thu Oct 13 09:30:50 
2011 +0200
+++ b/drivers/xen/sfc_netutil/accel_cuckoo_hash.c       Thu Oct 13 09:33:56 
2011 +0200
@@ -76,7 +76,7 @@
        BUG_ON(length_bits >= sizeof(unsigned) * 8);
        BUG_ON(key_length > sizeof(cuckoo_hash_key));
 
-       table_mem = kmalloc(sizeof(cuckoo_hash_entry) * 2 * length, GFP_KERNEL);
+       table_mem = kzalloc(sizeof(cuckoo_hash_entry) * 2 * length, GFP_KERNEL);
 
        if (table_mem == NULL)
                return -ENOMEM;
@@ -92,9 +92,6 @@
 
        set_hash_parameters(hashtab);
 
-       /* Zero the table */
-       memset(hashtab->table0, 0, length * 2 * sizeof(cuckoo_hash_entry));
-
        return 0;
 }
 EXPORT_SYMBOL_GPL(cuckoo_hash_init);
diff -r f4a4962d40e4 -r e8e3b1247124 drivers/xen/tpmback/interface.c
--- a/drivers/xen/tpmback/interface.c   Thu Oct 13 09:30:50 2011 +0200
+++ b/drivers/xen/tpmback/interface.c   Thu Oct 13 09:33:56 2011 +0200
@@ -93,7 +93,7 @@
        tpmif->tx_area = area;
 
        tpmif->tx = (tpmif_tx_interface_t *)area->addr;
-       memset(tpmif->tx, 0, PAGE_SIZE);
+       clear_page(tpmif->tx);
 
        err = bind_interdomain_evtchn_to_irqhandler(
                tpmif->domid, evtchn, tpmif_be_int, 0, tpmif->devname, tpmif);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.