vmalloc.c (1f5307b1e094bfffa83c65c40ac6e3415c108780) vmalloc.c (19809c2da28aee5860ad9a2eff760730a0710df0)
1/*
2 * linux/mm/vmalloc.c
3 *
4 * Copyright (C) 1993 Linus Torvalds
5 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
6 * SMP-safe vmalloc/vfree/ioremap, Tigran Aivazian <tigran@veritas.com>, May 2000
7 * Major rework to support vmap/vunmap, Christoph Hellwig, SGI, August 2002
8 * Numa awareness, Christoph Lameter, SGI, June 2005

--- 1641 unchanged lines hidden (view full) ---

1650EXPORT_SYMBOL(vmap);
1651
1652static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
1653 pgprot_t prot, int node)
1654{
1655 struct page **pages;
1656 unsigned int nr_pages, array_size, i;
1657 const gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO;
1/*
2 * linux/mm/vmalloc.c
3 *
4 * Copyright (C) 1993 Linus Torvalds
5 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
6 * SMP-safe vmalloc/vfree/ioremap, Tigran Aivazian <tigran@veritas.com>, May 2000
7 * Major rework to support vmap/vunmap, Christoph Hellwig, SGI, August 2002
8 * Numa awareness, Christoph Lameter, SGI, June 2005

--- 1641 unchanged lines hidden (view full) ---

1650EXPORT_SYMBOL(vmap);
1651
1652static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
1653 pgprot_t prot, int node)
1654{
1655 struct page **pages;
1656 unsigned int nr_pages, array_size, i;
1657 const gfp_t nested_gfp = (gfp_mask & GFP_RECLAIM_MASK) | __GFP_ZERO;
1658 const gfp_t alloc_mask = gfp_mask | __GFP_NOWARN;
1658 const gfp_t alloc_mask = gfp_mask | __GFP_HIGHMEM | __GFP_NOWARN;
1659
1660 nr_pages = get_vm_area_size(area) >> PAGE_SHIFT;
1661 array_size = (nr_pages * sizeof(struct page *));
1662
1663 area->nr_pages = nr_pages;
1664 /* Please note that the recursion is strictly bounded. */
1665 if (array_size > PAGE_SIZE) {
1666 pages = __vmalloc_node(array_size, 1, nested_gfp|__GFP_HIGHMEM,

--- 146 unchanged lines hidden (view full) ---

1813 * allocator and map them into contiguous kernel virtual space.
1814 *
1815 * For tight control over page level allocator and protection flags
1816 * use __vmalloc() instead.
1817 */
1818void *vmalloc(unsigned long size)
1819{
1820 return __vmalloc_node_flags(size, NUMA_NO_NODE,
1659
1660 nr_pages = get_vm_area_size(area) >> PAGE_SHIFT;
1661 array_size = (nr_pages * sizeof(struct page *));
1662
1663 area->nr_pages = nr_pages;
1664 /* Please note that the recursion is strictly bounded. */
1665 if (array_size > PAGE_SIZE) {
1666 pages = __vmalloc_node(array_size, 1, nested_gfp|__GFP_HIGHMEM,

--- 146 unchanged lines hidden (view full) ---

1813 * allocator and map them into contiguous kernel virtual space.
1814 *
1815 * For tight control over page level allocator and protection flags
1816 * use __vmalloc() instead.
1817 */
1818void *vmalloc(unsigned long size)
1819{
1820 return __vmalloc_node_flags(size, NUMA_NO_NODE,
1821 GFP_KERNEL | __GFP_HIGHMEM);
1821 GFP_KERNEL);
1822}
1823EXPORT_SYMBOL(vmalloc);
1824
1825/**
1826 * vzalloc - allocate virtually contiguous memory with zero fill
1827 * @size: allocation size
1828 * Allocate enough pages to cover @size from the page level
1829 * allocator and map them into contiguous kernel virtual space.
1830 * The memory allocated is set to zero.
1831 *
1832 * For tight control over page level allocator and protection flags
1833 * use __vmalloc() instead.
1834 */
1835void *vzalloc(unsigned long size)
1836{
1837 return __vmalloc_node_flags(size, NUMA_NO_NODE,
1822}
1823EXPORT_SYMBOL(vmalloc);
1824
1825/**
1826 * vzalloc - allocate virtually contiguous memory with zero fill
1827 * @size: allocation size
1828 * Allocate enough pages to cover @size from the page level
1829 * allocator and map them into contiguous kernel virtual space.
1830 * The memory allocated is set to zero.
1831 *
1832 * For tight control over page level allocator and protection flags
1833 * use __vmalloc() instead.
1834 */
1835void *vzalloc(unsigned long size)
1836{
1837 return __vmalloc_node_flags(size, NUMA_NO_NODE,
1838 GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO);
1838 GFP_KERNEL | __GFP_ZERO);
1839}
1840EXPORT_SYMBOL(vzalloc);
1841
1842/**
1843 * vmalloc_user - allocate zeroed virtually contiguous memory for userspace
1844 * @size: allocation size
1845 *
1846 * The resulting memory area is zeroed so it can be mapped to userspace
1847 * without leaking data.
1848 */
1849void *vmalloc_user(unsigned long size)
1850{
1851 struct vm_struct *area;
1852 void *ret;
1853
1854 ret = __vmalloc_node(size, SHMLBA,
1839}
1840EXPORT_SYMBOL(vzalloc);
1841
1842/**
1843 * vmalloc_user - allocate zeroed virtually contiguous memory for userspace
1844 * @size: allocation size
1845 *
1846 * The resulting memory area is zeroed so it can be mapped to userspace
1847 * without leaking data.
1848 */
1849void *vmalloc_user(unsigned long size)
1850{
1851 struct vm_struct *area;
1852 void *ret;
1853
1854 ret = __vmalloc_node(size, SHMLBA,
1855 GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO,
1855 GFP_KERNEL | __GFP_ZERO,
1856 PAGE_KERNEL, NUMA_NO_NODE,
1857 __builtin_return_address(0));
1858 if (ret) {
1859 area = find_vm_area(ret);
1860 area->flags |= VM_USERMAP;
1861 }
1862 return ret;
1863}

--- 7 unchanged lines hidden (view full) ---

1871 * Allocate enough pages to cover @size from the page level
1872 * allocator and map them into contiguous kernel virtual space.
1873 *
1874 * For tight control over page level allocator and protection flags
1875 * use __vmalloc() instead.
1876 */
1877void *vmalloc_node(unsigned long size, int node)
1878{
1856 PAGE_KERNEL, NUMA_NO_NODE,
1857 __builtin_return_address(0));
1858 if (ret) {
1859 area = find_vm_area(ret);
1860 area->flags |= VM_USERMAP;
1861 }
1862 return ret;
1863}

--- 7 unchanged lines hidden (view full) ---

1871 * Allocate enough pages to cover @size from the page level
1872 * allocator and map them into contiguous kernel virtual space.
1873 *
1874 * For tight control over page level allocator and protection flags
1875 * use __vmalloc() instead.
1876 */
1877void *vmalloc_node(unsigned long size, int node)
1878{
1879 return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL,
1879 return __vmalloc_node(size, 1, GFP_KERNEL, PAGE_KERNEL,
1880 node, __builtin_return_address(0));
1881}
1882EXPORT_SYMBOL(vmalloc_node);
1883
1884/**
1885 * vzalloc_node - allocate memory on a specific node with zero fill
1886 * @size: allocation size
1887 * @node: numa node
1888 *
1889 * Allocate enough pages to cover @size from the page level
1890 * allocator and map them into contiguous kernel virtual space.
1891 * The memory allocated is set to zero.
1892 *
1893 * For tight control over page level allocator and protection flags
1894 * use __vmalloc_node() instead.
1895 */
1896void *vzalloc_node(unsigned long size, int node)
1897{
1898 return __vmalloc_node_flags(size, node,
1880 node, __builtin_return_address(0));
1881}
1882EXPORT_SYMBOL(vmalloc_node);
1883
1884/**
1885 * vzalloc_node - allocate memory on a specific node with zero fill
1886 * @size: allocation size
1887 * @node: numa node
1888 *
1889 * Allocate enough pages to cover @size from the page level
1890 * allocator and map them into contiguous kernel virtual space.
1891 * The memory allocated is set to zero.
1892 *
1893 * For tight control over page level allocator and protection flags
1894 * use __vmalloc_node() instead.
1895 */
1896void *vzalloc_node(unsigned long size, int node)
1897{
1898 return __vmalloc_node_flags(size, node,
1899 GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO);
1899 GFP_KERNEL | __GFP_ZERO);
1900}
1901EXPORT_SYMBOL(vzalloc_node);
1902
1903#ifndef PAGE_KERNEL_EXEC
1904# define PAGE_KERNEL_EXEC PAGE_KERNEL
1905#endif
1906
1907/**

--- 5 unchanged lines hidden (view full) ---

1913 * executable kernel virtual space.
1914 *
1915 * For tight control over page level allocator and protection flags
1916 * use __vmalloc() instead.
1917 */
1918
1919void *vmalloc_exec(unsigned long size)
1920{
1900}
1901EXPORT_SYMBOL(vzalloc_node);
1902
1903#ifndef PAGE_KERNEL_EXEC
1904# define PAGE_KERNEL_EXEC PAGE_KERNEL
1905#endif
1906
1907/**

--- 5 unchanged lines hidden (view full) ---

1913 * executable kernel virtual space.
1914 *
1915 * For tight control over page level allocator and protection flags
1916 * use __vmalloc() instead.
1917 */
1918
1919void *vmalloc_exec(unsigned long size)
1920{
1921 return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
1921 return __vmalloc_node(size, 1, GFP_KERNEL, PAGE_KERNEL_EXEC,
1922 NUMA_NO_NODE, __builtin_return_address(0));
1923}
1924
1925#if defined(CONFIG_64BIT) && defined(CONFIG_ZONE_DMA32)
1926#define GFP_VMALLOC32 GFP_DMA32 | GFP_KERNEL
1927#elif defined(CONFIG_64BIT) && defined(CONFIG_ZONE_DMA)
1928#define GFP_VMALLOC32 GFP_DMA | GFP_KERNEL
1929#else

--- 823 unchanged lines hidden ---
1922 NUMA_NO_NODE, __builtin_return_address(0));
1923}
1924
1925#if defined(CONFIG_64BIT) && defined(CONFIG_ZONE_DMA32)
1926#define GFP_VMALLOC32 GFP_DMA32 | GFP_KERNEL
1927#elif defined(CONFIG_64BIT) && defined(CONFIG_ZONE_DMA)
1928#define GFP_VMALLOC32 GFP_DMA | GFP_KERNEL
1929#else

--- 823 unchanged lines hidden ---