shmem.c (86a2f3f2d99e9765d13a55ee2e4364deb6cdf794) | shmem.c (050dcb5c85bb47f8151175ca5833aa882cc7fe0c) |
---|---|
1/* 2 * Resizable virtual memory filesystem for Linux. 3 * 4 * Copyright (C) 2000 Linus Torvalds. 5 * 2000 Transmeta Corp. 6 * 2000-2001 Christoph Rohland 7 * 2000-2001 SAP AG 8 * 2002 Red Hat Inc. --- 2705 unchanged lines hidden (view full) --- 2714 shmem_falloc.start = start; 2715 shmem_falloc.next = start; 2716 shmem_falloc.nr_falloced = 0; 2717 shmem_falloc.nr_unswapped = 0; 2718 spin_lock(&inode->i_lock); 2719 inode->i_private = &shmem_falloc; 2720 spin_unlock(&inode->i_lock); 2721 | 1/* 2 * Resizable virtual memory filesystem for Linux. 3 * 4 * Copyright (C) 2000 Linus Torvalds. 5 * 2000 Transmeta Corp. 6 * 2000-2001 Christoph Rohland 7 * 2000-2001 SAP AG 8 * 2002 Red Hat Inc. --- 2705 unchanged lines hidden (view full) --- 2714 shmem_falloc.start = start; 2715 shmem_falloc.next = start; 2716 shmem_falloc.nr_falloced = 0; 2717 shmem_falloc.nr_unswapped = 0; 2718 spin_lock(&inode->i_lock); 2719 inode->i_private = &shmem_falloc; 2720 spin_unlock(&inode->i_lock); 2721 |
2722 for (index = start; index < end; index++) { | 2722 for (index = start; index < end; ) { |
2723 struct page *page; 2724 2725 /* 2726 * Good, the fallocate(2) manpage permits EINTR: we may have 2727 * been interrupted because we are using up too much memory. 2728 */ 2729 if (signal_pending(current)) 2730 error = -EINTR; --- 6 unchanged lines hidden (view full) --- 2737 if (index > start) { 2738 shmem_undo_range(inode, 2739 (loff_t)start << PAGE_SHIFT, 2740 ((loff_t)index << PAGE_SHIFT) - 1, true); 2741 } 2742 goto undone; 2743 } 2744 | 2723 struct page *page; 2724 2725 /* 2726 * Good, the fallocate(2) manpage permits EINTR: we may have 2727 * been interrupted because we are using up too much memory. 2728 */ 2729 if (signal_pending(current)) 2730 error = -EINTR; --- 6 unchanged lines hidden (view full) --- 2737 if (index > start) { 2738 shmem_undo_range(inode, 2739 (loff_t)start << PAGE_SHIFT, 2740 ((loff_t)index << PAGE_SHIFT) - 1, true); 2741 } 2742 goto undone; 2743 } 2744 |
2745 index++; |
|
2745 /* | 2746 /* |
2747 * Here is a more important optimization than it appears: 2748 * a second SGP_FALLOC on the same huge page will clear it, 2749 * making it PageUptodate and un-undoable if we fail later. 2750 */ 2751 if (PageTransCompound(page)) { 2752 index = round_up(index, HPAGE_PMD_NR); 2753 /* Beware 32-bit wraparound */ 2754 if (!index) 2755 index--; 2756 } 2757 2758 /* |
|
2746 * Inform shmem_writepage() how far we have reached. 2747 * No need for lock or barrier: we have the page lock. 2748 */ | 2759 * Inform shmem_writepage() how far we have reached. 2760 * No need for lock or barrier: we have the page lock. 2761 */ |
2749 shmem_falloc.next++; | |
2750 if (!PageUptodate(page)) | 2762 if (!PageUptodate(page)) |
2751 shmem_falloc.nr_falloced++; | 2763 shmem_falloc.nr_falloced += index - shmem_falloc.next; 2764 shmem_falloc.next = index; |
2752 2753 /* 2754 * If !PageUptodate, leave it that way so that freeable pages 2755 * can be recognized if we need to rollback on error later. 2756 * But set_page_dirty so that memory pressure will swap rather 2757 * than free the pages we are allocating (and SGP_CACHE pages 2758 * might still be clean: we now need to mark those dirty too). 2759 */ --- 1466 unchanged lines hidden --- | 2765 2766 /* 2767 * If !PageUptodate, leave it that way so that freeable pages 2768 * can be recognized if we need to rollback on error later. 2769 * But set_page_dirty so that memory pressure will swap rather 2770 * than free the pages we are allocating (and SGP_CACHE pages 2771 * might still be clean: we now need to mark those dirty too). 2772 */ --- 1466 unchanged lines hidden --- |