public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dontneed nonlinear
@ 2004-04-19 17:51 Hugh Dickins
  2004-04-20  0:29 ` Jamie Lokier
  0 siblings, 1 reply; 2+ messages in thread
From: Hugh Dickins @ 2004-04-19 17:51 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, Jamie Lokier, linux-kernel

Jamie points out that madvise(MADV_DONTNEED) should unmap pages from a
nonlinear area in such a way that the nonlinear offsets are preserved if
the pages do turn out to be needed later after all, instead of reverting
them to linearity: needs to pass down a zap_details block.

(But this still leaves mincore unaware of nonlinear vmas: bigger job.)

--- 2.6.6-rc1-bk4/include/linux/mm.h	2004-04-19 15:29:38.808606600 +0100
+++ linux/include/linux/mm.h	2004-04-19 16:15:16.925349584 +0100
@@ -439,7 +439,16 @@ struct file *shmem_file_setup(char * nam
 void shmem_lock(struct file * file, int lock);
 int shmem_zero_setup(struct vm_area_struct *);
 
-struct zap_details;
+/*
+ * Parameter block passed down to zap_pte_range in exceptional cases.
+ */
+struct zap_details {
+	struct vm_area_struct *nonlinear_vma;	/* Check page->index if set */
+	struct address_space *check_mapping;	/* Check page->mapping if set */
+	pgoff_t	first_index;			/* Lowest page->index to unmap */
+	pgoff_t last_index;			/* Highest page->index to unmap */
+};
+
 void zap_page_range(struct vm_area_struct *vma, unsigned long address,
 		unsigned long size, struct zap_details *);
 int unmap_vmas(struct mmu_gather **tlbp, struct mm_struct *mm,
--- 2.6.6-rc1-bk4/mm/madvise.c	2004-04-19 15:29:38.896593224 +0100
+++ linux/mm/madvise.c	2004-04-19 16:42:15.197334848 +0100
@@ -92,10 +92,19 @@ static long madvise_willneed(struct vm_a
 static long madvise_dontneed(struct vm_area_struct * vma,
 			     unsigned long start, unsigned long end)
 {
+	struct zap_details details;
+
 	if (vma->vm_flags & VM_LOCKED)
 		return -EINVAL;
 
-	zap_page_range(vma, start, end - start, NULL);
+	if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
+		details.check_mapping = NULL;
+		details.nonlinear_vma = vma;
+		details.first_index = 0;
+		details.last_index = ULONG_MAX;
+		zap_page_range(vma, start, end - start, &details);
+	} else
+		zap_page_range(vma, start, end - start, NULL);
 	return 0;
 }
 
--- 2.6.6-rc1-bk4/mm/memory.c	2004-04-19 15:29:38.902592312 +0100
+++ linux/mm/memory.c	2004-04-19 16:15:16.000000000 +0100
@@ -384,16 +384,6 @@ nomem:
 	return -ENOMEM;
 }
 
-/*
- * Parameter block passed down to zap_pte_range in exceptional cases.
- */
-struct zap_details {
-	struct vm_area_struct *nonlinear_vma;	/* Check page->index if set */
-	struct address_space *check_mapping;	/* Check page->mapping if set */
-	pgoff_t	first_index;			/* Lowest page->index to unmap */
-	pgoff_t last_index;			/* Highest page->index to unmap */
-};
-
 static void zap_pte_range(struct mmu_gather *tlb,
 		pmd_t *pmd, unsigned long address,
 		unsigned long size, struct zap_details *details)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] dontneed nonlinear
  2004-04-19 17:51 [PATCH] dontneed nonlinear Hugh Dickins
@ 2004-04-20  0:29 ` Jamie Lokier
  0 siblings, 0 replies; 2+ messages in thread
From: Jamie Lokier @ 2004-04-20  0:29 UTC (permalink / raw)
  To: Hugh Dickins; +Cc: Linus Torvalds, Andrew Morton, linux-kernel

Hugh Dickins wrote:
> (But this still leaves mincore unaware of nonlinear vmas: bigger job.)

mincore has other problems too: like giving useless results for
private mappings.

-- Jamie

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-04-20  0:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-19 17:51 [PATCH] dontneed nonlinear Hugh Dickins
2004-04-20  0:29 ` Jamie Lokier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox