public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Try to avoid a pessimistic vmalloc() recursion
Date: Mon, 9 Oct 2006 16:47:55 +0200	[thread overview]
Message-ID: <200610091647.55184.dada1@cosmosbay.com> (raw)
In-Reply-To: <20061006230609.c04e78bc.akpm@osdl.org>

[-- Attachment #1: Type: text/plain, Size: 688 bytes --]

__vmalloc_area_node() is a litle bit pessimist when allocating space for 
storing struct page pointers.

When allocating more than 4 MB on ia32, or 2 MB on x86_64,  
__vmalloc_area_node() has to allocate more than PAGE_SIZE bytes to store 
pointers to  page structs. This means that two TLB translations are needed to 
access data.

This patch tries a kmalloc() call, then only if this first attempt failed, a 
vmalloc() is performed. (Later, at vfree() time we chose kfree() or vfree() 
with a test on flags & VM_VPAGES : no change is needed) 

Most of the time, the first kmalloc() should be OK, so we reduce TLB usage.

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>

[-- Attachment #2: vmalloc.patch --]
[-- Type: text/plain, Size: 702 bytes --]

--- linux-2.6.18/mm/vmalloc.c	2006-10-09 13:58:13.000000000 +0200
+++ linux-2.6.18-ed/mm/vmalloc.c	2006-10-09 14:04:11.000000000 +0200
@@ -426,12 +426,12 @@
 	array_size = (nr_pages * sizeof(struct page *));
 
 	area->nr_pages = nr_pages;
+	pages = kmalloc_node(array_size, (gfp_mask & ~__GFP_HIGHMEM), node);
 	/* Please note that the recursion is strictly bounded. */
-	if (array_size > PAGE_SIZE) {
+	if (!pages && array_size > PAGE_SIZE) {
 		pages = __vmalloc_node(array_size, gfp_mask, PAGE_KERNEL, node);
 		area->flags |= VM_VPAGES;
-	} else
-		pages = kmalloc_node(array_size, (gfp_mask & ~__GFP_HIGHMEM), node);
+	}
 	area->pages = pages;
 	if (!area->pages) {
 		remove_vm_area(area->addr);

  parent reply	other threads:[~2006-10-09 14:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-06 11:49 [PATCH 0/3] Fix IO error reporting on fsync() Jan Kara
2006-10-06 11:55 ` [PATCH 1/3] " Jan Kara
2006-10-06 11:56 ` [PATCH 2/3] " Jan Kara
2006-10-06 11:57 ` [PATCH 3/3] " Jan Kara
2006-10-07  6:06 ` [PATCH 0/3] " Andrew Morton
2006-10-09 11:40   ` Jan Kara
2006-10-09 18:20     ` Andrew Morton
2006-10-10 11:56       ` Jan Kara
2006-10-09 14:47   ` Eric Dumazet [this message]
2006-10-09 16:25     ` [PATCH] Try to avoid a pessimistic vmalloc() recursion Nick Piggin
2006-10-09 19:43       ` Eric Dumazet

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=200610091647.55184.dada1@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /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