WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] linux-2.6.18: streamline clearing of memory in a few

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] linux-2.6.18: streamline clearing of memory in a few places
From: "Jan Beulich" <JBeulich@xxxxxxxx>
Date: Tue, 11 Oct 2011 15:00:38 +0100
Delivery-date: Tue, 11 Oct 2011 07:06:41 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
- 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>

--- a/arch/i386/mm/init-xen.c
+++ b/arch/i386/mm/init-xen.c
@@ -558,7 +558,7 @@ void __init paging_init(void)
         * 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++)
--- a/arch/x86_64/mm/init-xen.c
+++ b/arch/x86_64/mm/init-xen.c
@@ -218,7 +218,7 @@ static __init void *spp_getpage(void)
        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 @@ static __meminit void *alloc_static_page
 
        *phys = start_pfn << PAGE_SHIFT;
        start_pfn++;
-       memset((void *)va, 0, PAGE_SIZE);
+       clear_page((void *)va);
        return (void *)va;
 } 
 
@@ -728,7 +728,7 @@ static void xen_finish_init_mapping(void
        /* 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++)
--- a/drivers/xen/core/gnttab.c
+++ b/drivers/xen/core/gnttab.c
@@ -543,7 +543,7 @@ int gnttab_copy_grant_page(grant_ref_t r
 
        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);
--- a/drivers/xen/core/machine_reboot.c
+++ b/drivers/xen/core/machine_reboot.c
@@ -89,7 +89,7 @@ static void post_suspend(int suspend_can
                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++) {
--- a/drivers/xen/core/smpboot.c
+++ b/drivers/xen/core/smpboot.c
@@ -198,17 +198,12 @@ static void __cpuinit cpu_initialize_con
        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;
--- a/drivers/xen/netback/interface.c
+++ b/drivers/xen/netback/interface.c
@@ -236,7 +236,6 @@ netif_t *netif_alloc(struct device *pare
        SET_NETDEV_DEV(dev, parent);
 
        netif = netdev_priv(dev);
-       memset(netif, 0, sizeof(*netif));
        netif->domid  = domid;
        netif->handle = handle;
        netif->can_sg = 1;
--- a/drivers/xen/sfc_netutil/accel_cuckoo_hash.c
+++ b/drivers/xen/sfc_netutil/accel_cuckoo_hash.c
@@ -76,7 +76,7 @@ int cuckoo_hash_init(cuckoo_hash_table *
        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 @@ int cuckoo_hash_init(cuckoo_hash_table *
 
        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);
--- a/drivers/xen/tpmback/interface.c
+++ b/drivers/xen/tpmback/interface.c
@@ -93,7 +93,7 @@ int tpmif_map(tpmif_t *tpmif, grant_ref_
        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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] linux-2.6.18: streamline clearing of memory in a few places, Jan Beulich <=