From: viro@www.linux.org.uk removed dead code from sparc64 hugetlbpage.c arch/sparc64/mm/hugetlbpage.c | 201 ------------------------------------------ 1 files changed, 201 deletions(-) diff -puN arch/sparc64/mm/hugetlbpage.c~large-dev_t-07 arch/sparc64/mm/hugetlbpage.c --- 25/arch/sparc64/mm/hugetlbpage.c~large-dev_t-07 2003-08-26 18:28:54.000000000 -0700 +++ 25-akpm/arch/sparc64/mm/hugetlbpage.c 2003-08-26 18:28:54.000000000 -0700 @@ -380,207 +380,6 @@ int free_hugepages(struct vm_area_struct return 1; } -static struct inode *set_new_inode(unsigned long len, int prot, int flag, int key) -{ - struct inode *inode; - int i; - - for (i = 0; i < MAX_ID; i++) { - if (htlbpagek[i].key == 0) - break; - } - if (i == MAX_ID) - return NULL; - inode = kmalloc(sizeof (struct inode), GFP_KERNEL); - if (inode == NULL) - return NULL; - - inode_init_once(inode); - atomic_inc(&inode->i_writecount); - inode->i_mapping = &inode->i_data; - inode->i_mapping->host = inode; - inode->i_ino = (unsigned long)key; - - htlbpagek[i].key = key; - htlbpagek[i].in = inode; - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; - inode->i_mode = prot; - inode->i_size = len; - return inode; -} - -static int check_size_prot(struct inode *inode, unsigned long len, int prot, int flag) -{ - if (inode->i_uid != current->fsuid) - return -1; - if (inode->i_gid != current->fsgid) - return -1; - if (inode->i_size != len) - return -1; - return 0; -} - -static int alloc_shared_hugetlb_pages(int key, unsigned long addr, unsigned long len, - int prot, int flag) -{ - struct mm_struct *mm = current->mm; - struct vm_area_struct *vma; - struct inode *inode; - struct address_space *mapping; - struct page *page; - int idx; - int retval = -ENOMEM; - int newalloc = 0; - -try_again: - spin_lock(&htlbpage_lock); - - inode = find_key_inode(key); - if (inode == NULL) { - if (!capable(CAP_SYS_ADMIN)) { - if (!in_group_p(0)) { - retval = -EPERM; - goto out_err; - } - } - if (!(flag & IPC_CREAT)) { - retval = -ENOENT; - goto out_err; - } - inode = set_new_inode(len, prot, flag, key); - if (inode == NULL) - goto out_err; - newalloc = 1; - } else { - if (check_size_prot(inode, len, prot, flag) < 0) { - retval = -EINVAL; - goto out_err; - } else if (atomic_read(&inode->i_writecount)) { - spin_unlock(&htlbpage_lock); - goto try_again; - } - } - spin_unlock(&htlbpage_lock); - mapping = inode->i_mapping; - - addr = do_mmap_pgoff(NULL, addr, len, (unsigned long) prot, - MAP_NORESERVE|MAP_FIXED|MAP_PRIVATE|MAP_ANONYMOUS, 0); - if (IS_ERR((void *) addr)) - goto freeinode; - - vma = find_vma(mm, addr); - if (!vma) { - retval = -EINVAL; - goto freeinode; - } - - spin_lock(&mm->page_table_lock); - do { - pte_t *pte = huge_pte_alloc_map(mm, addr); - - if (!pte || !pte_none(pte)) { - if (pte) - pte_unmap(pte); - goto out; - } - - idx = (addr - vma->vm_start) >> HPAGE_SHIFT; - page = find_get_page(mapping, idx); - if (page == NULL) { - page = alloc_hugetlb_page(); - if (page == NULL) { - pte_unmap(pte); - retval = -ENOMEM; - goto out; - } - retval = add_to_page_cache(page, mapping, - idx, GFP_ATOMIC); - if (retval) { - pte_unmap(pte); - free_hugetlb_page(page); - goto out; - } - } - set_huge_pte(mm, vma, page, pte, - (vma->vm_flags & VM_WRITE)); - pte_unmap(pte); - - addr += HPAGE_SIZE; - } while (addr < vma->vm_end); - - retval = 0; - vma->vm_flags |= (VM_HUGETLB | VM_RESERVED); - vma->vm_ops = &hugetlb_vm_ops; - spin_unlock(&mm->page_table_lock); - spin_lock(&htlbpage_lock); - atomic_set(&inode->i_writecount, 0); - spin_unlock(&htlbpage_lock); - - return retval; - -out: - if (addr > vma->vm_start) { - unsigned long raddr; - raddr = vma->vm_end; - vma->vm_end = addr; - - flush_cache_range(vma, vma->vm_start, vma->vm_end); - zap_hugetlb_resources(vma); - flush_tlb_range(vma, vma->vm_start, vma->vm_end); - - vma->vm_end = raddr; - } - spin_unlock(&mm->page_table_lock); - do_munmap(mm, vma->vm_start, len); - if (newalloc) - goto freeinode; - - return retval; - -out_err: - spin_unlock(&htlbpage_lock); - -freeinode: - if (newalloc) { - for (idx = 0; idx < MAX_ID; idx++) { - if (htlbpagek[idx].key == inode->i_ino) { - htlbpagek[idx].key = 0; - htlbpagek[idx].in = NULL; - break; - } - } - kfree(inode); - } - return retval; -} - -static int alloc_private_hugetlb_pages(int key, unsigned long addr, unsigned long len, - int prot, int flag) -{ - if (!capable(CAP_SYS_ADMIN)) { - if (!in_group_p(0)) - return -EPERM; - } - addr = do_mmap_pgoff(NULL, addr, len, prot, - MAP_NORESERVE|MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, 0); - if (IS_ERR((void *) addr)) - return -ENOMEM; - if (make_hugetlb_pages_present(addr, (addr + len), flag) < 0) { - do_munmap(current->mm, addr, len); - return -ENOMEM; - } - return 0; -} - -int alloc_hugetlb_pages(int key, unsigned long addr, unsigned long len, int prot, - int flag) -{ - if (key > 0) - return alloc_shared_hugetlb_pages(key, addr, len, prot, flag); - return alloc_private_hugetlb_pages(key, addr, len, prot, flag); -} - extern long htlbzone_pages; extern struct list_head htlbpage_freelist; _