linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Lameter <clameter@sgi.com>,
	ak@suse.de, gregkh@suse.de, linux-mm@kvack.org, mel@skynet.ie,
	eric.whitney@hp.com
Subject: [PATCH ] Mem Policy:  fix mempolicy usage in pci driver
Date: Tue, 06 Nov 2007 13:09:04 -0500	[thread overview]
Message-ID: <1194372544.5317.28.camel@localhost> (raw)
In-Reply-To: <Pine.LNX.4.64.0710111843160.1181@schroedinger.engr.sgi.com>

I see that you're starting to build up the next -mm tree.  Would you
please apply the following patch?  I posted it earlier [twice] and
Christoph Ack'd it [twice].  Haven't heard any objections. 

Lee

--------------

PATCH  Mem Policy:  Fix memory policy usage in pci driver

Against:  2.6.23-mm1

In an attempt to ensure memory allocation from the local node,
the pci driver temporarily replaces the current task's memory
policy with the system default policy.  Trying to be a good
citizen, the driver then call's mpol_get() on the new policy.
When it's finished probing, it undoes the '_get by calling
mpol_free() [on the system default policy] and then restores
the current task's saved mempolicy.

A couple of issues here:

1) it's never necessary to set a task's mempolicy to the
   system default policy in order to get system default
   allocation behavior.  Simply set the current task's
   mempolicy to NULL and allocations will fall back to
   system default policy.

2) we should never [need to] call mpol_free() on the system
   default policy.  [I plan on trapping this with a VM_BUG_ON()
   in a subsequent patch.]

This patch removes the calls to mpol_get() and mpol_free()
and uses NULL for the temporary task mempolicy to effect
default allocation behavior.

Signed-off-by:  Lee Schermerhorn <lee.schermerhorn@hp.com>
Twice:
Acked-by: Christoph Lameter <clameter@sgi.com>

 drivers/pci/pci-driver.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Index: Linux/drivers/pci/pci-driver.c
===================================================================
--- Linux.orig/drivers/pci/pci-driver.c	2007-10-09 14:31:57.000000000 -0400
+++ Linux/drivers/pci/pci-driver.c	2007-10-09 14:43:57.000000000 -0400
@@ -177,13 +177,11 @@ static int pci_call_probe(struct pci_dri
 	    set_cpus_allowed(current, node_to_cpumask(node));
 	/* And set default memory allocation policy */
 	oldpol = current->mempolicy;
-	current->mempolicy = &default_policy;
-	mpol_get(current->mempolicy);
+	current->mempolicy = NULL;	/* fall back to system default policy */
 #endif
 	error = drv->probe(dev, id);
 #ifdef CONFIG_NUMA
 	set_cpus_allowed(current, oldmask);
-	mpol_free(current->mempolicy);
 	current->mempolicy = oldpol;
 #endif
 	return error;


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2007-11-06 18:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-10 20:58 [PATCH/RFC 0/2] More Mempolicy Reference Counting Fixes Lee Schermerhorn
2007-10-10 20:58 ` [PATCH/RFC 1/2] Mem Policy: fix mempolicy usage in pci driver Lee Schermerhorn
2007-10-10 21:12   ` Christoph Lameter
2007-10-11 19:11     ` [PATCH " Lee Schermerhorn
2007-10-12  1:43       ` Christoph Lameter
2007-11-06 18:09         ` Lee Schermerhorn [this message]
2007-10-15 11:19       ` Mel Gorman
2007-10-10 20:58 ` [PATCH/RFC 2/2] Mem Policy: Fixup Shm and Interleave Policy Reference Counting Lee Schermerhorn
2007-10-10 21:22   ` Christoph Lameter
2007-10-11 13:41     ` Lee Schermerhorn
2007-10-11 19:07     ` [PATCH 2/2] Mem Policy: Fixup Shm and Interleave Policy Reference Counting - V2 Lee Schermerhorn
2007-10-12  1:42       ` Christoph Lameter
2007-10-12 14:35         ` Lee Schermerhorn
2007-10-12 17:27           ` Christoph Lameter

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=1194372544.5317.28.camel@localhost \
    --to=lee.schermerhorn@hp.com \
    --cc=ak@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=clameter@sgi.com \
    --cc=eric.whitney@hp.com \
    --cc=gregkh@suse.de \
    --cc=linux-mm@kvack.org \
    --cc=mel@skynet.ie \
    /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;
as well as URLs for NNTP newsgroup(s).