mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
To: "Maciej W. Rozycki" <macro@ds2.pg.gda.pl>
Cc: Tom Vier <tmv5@home.com>, Alan Cox <alan@lxorguk.ukuu.org.uk>,
	linux-kernel@vger.kernel.org
Subject: Re: [patch] Re: Linux 2.4.5-ac6
Date: Tue, 5 Jun 2001 21:41:07 +0400	[thread overview]
Message-ID: <20010605214107.A566@jurassic.park.msu.ru> (raw)
In-Reply-To: <20010604210835.A2907@jurassic.park.msu.ru> <Pine.GSO.3.96.1010605170310.12987F-100000@delta.ds2.pg.gda.pl>
In-Reply-To: <Pine.GSO.3.96.1010605170310.12987F-100000@delta.ds2.pg.gda.pl>; from macro@ds2.pg.gda.pl on Tue, Jun 05, 2001 at 05:11:01PM +0200

On Tue, Jun 05, 2001 at 05:11:01PM +0200, Maciej W. Rozycki wrote:
>  Iterating over memory areas twice is ugly.

Hmm, yes. However, your patch isn't pretty, too. You may check
the same area twice, and won't satisfy requested address > TASK_UNMAPPED_BASE.
What do you think about following? Everything is scanned only once, and
returned address matches specified one as close as possible.

Ivan.

--- linux/mm/mmap.c.orig	Mon Jun  4 14:19:02 2001
+++ linux/mm/mmap.c	Tue Jun  5 21:05:23 2001
@@ -398,22 +398,30 @@ free_vma:
 static inline unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
 {
 	struct vm_area_struct *vma;
+	unsigned long addr_limit = TASK_SIZE - len;
 
 	if (len > TASK_SIZE)
 		return -ENOMEM;
 
 	if (addr) {
 		addr = PAGE_ALIGN(addr);
-		vma = find_vma(current->mm, addr);
-		if (TASK_SIZE - len >= addr &&
-		    (!vma || addr + len <= vma->vm_start))
-			return addr;
+		if (addr <= TASK_UNMAPPED_BASE)
+			goto scan_low;
+		addr_limit = addr;
+		for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) {
+			if (TASK_SIZE - len < addr)
+				break;
+			if (!vma || addr + len <= vma->vm_start)
+				return addr;
+			addr = vma->vm_end;
+		}
 	}
 	addr = PAGE_ALIGN(TASK_UNMAPPED_BASE);
 
+scan_low:
 	for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) {
 		/* At this point:  (!vma || addr < vma->vm_end). */
-		if (TASK_SIZE - len < addr)
+		if (addr_limit < addr)
 			return -ENOMEM;
 		if (!vma || addr + len <= vma->vm_start)
 			return addr;

  reply	other threads:[~2001-06-05 17:44 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-01 11:01 Alan Cox
2001-06-01 11:28 ` Alexander Viro
2001-06-01 11:52   ` Alan Cox
2001-06-01 12:23 ` Keith Owens
2001-06-02  2:27 ` Tom Vier
2001-06-04 10:16   ` Maciej W. Rozycki
2001-06-04 17:08   ` [patch] " Ivan Kokshaysky
2001-06-05 15:11     ` Maciej W. Rozycki
2001-06-05 17:41       ` Ivan Kokshaysky [this message]
2001-06-05 18:32         ` Maciej W. Rozycki
2001-06-06  5:37           ` Ivan Kokshaysky
2001-06-06 13:09             ` Maciej W. Rozycki
2001-06-06 14:49               ` Jeff Garzik
2001-06-06 17:26                 ` Maciej W. Rozycki
2001-06-07 17:48                   ` Ivan Kokshaysky
2001-06-07 18:31                     ` Maciej W. Rozycki
2001-06-08 10:18                       ` jlnance
2001-06-08 17:06                         ` Gerhard Mack
2001-06-08 14:18                       ` Ivan Kokshaysky
2001-06-07 17:20               ` Ivan Kokshaysky
2001-06-07 18:28                 ` Maciej W. Rozycki
2001-06-08 14:16                   ` Ivan Kokshaysky
2001-06-08 16:08                     ` Maciej W. Rozycki
2001-06-08 17:23                       ` Ivan Kokshaysky
2001-06-09 10:14                       ` Ivan Kokshaysky
2001-06-09 18:46                         ` Tom Vier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010605214107.A566@jurassic.park.msu.ru \
    --to=ink@jurassic.park.msu.ru \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=macro@ds2.pg.gda.pl \
    --cc=tmv5@home.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®