public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pekka Enberg <penberg@cs.helsinki.fi>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Roman Jarosz <kedgedev@gmail.com>,
	A Rojas <nqn1976list@gmail.com>,
	"A. Boulan" <arnaud.boulan@libertysurf.fr>,
	michael@reinelt.co.at, jcnengel@googlemail.com,
	rientjes@google.com, earny@net4u.de,
	linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	Hugh Dickins <hugh.dickins@tiscali.co.uk>,
	Jesse Barnes <jbarnes@virtuousgeek.org>,
	Eric Anholt <eric@anholt.net>,
	stable@kernel.org
Subject: Re: [PATCH] drm/i915: Selectively enable self-reclaim
Date: Wed, 27 Jan 2010 13:20:38 +0200	[thread overview]
Message-ID: <4B602186.8050303@cs.helsinki.fi> (raw)
In-Reply-To: <1264590844-22972-1-git-send-email-chris@chris-wilson.co.uk>

Chris Wilson kirjoitti:
> Having missed the ENOMEM return via i915_gem_fault(), there are probably
> other paths that I also missed. By not enabling NORETRY by default these
> paths can run the shrinker and take memory from the system (but not from
> our own inactive lists because our shrinker can not run whilst we hold
> the struct mutex) and this may allow the system to survive a little longer
> whilst our drivers consume all available memory.
> 
> References:
>   OOM killer unexpectedly called with kernel 2.6.32
>   http://bugzilla.kernel.org/show_bug.cgi?id=14933
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>
> Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
> Cc: Eric Anholt <eric@anholt.net>
> Cc: stable@kernel.org

Roman, can you give this patch a spin?

> ---
>  drivers/gpu/drm/drm_gem.c       |   13 -------------
>  drivers/gpu/drm/i915/i915_gem.c |   22 ++++++++++------------
>  2 files changed, 10 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index e9dbb48..8bf3770 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
> @@ -142,19 +142,6 @@ drm_gem_object_alloc(struct drm_device *dev, size_t size)
>  	if (IS_ERR(obj->filp))
>  		goto free;
>  
> -	/* Basically we want to disable the OOM killer and handle ENOMEM
> -	 * ourselves by sacrificing pages from cached buffers.
> -	 * XXX shmem_file_[gs]et_gfp_mask()
> -	 */
> -	mapping_set_gfp_mask(obj->filp->f_path.dentry->d_inode->i_mapping,
> -			     GFP_HIGHUSER |
> -			     __GFP_COLD |
> -			     __GFP_FS |
> -			     __GFP_RECLAIMABLE |
> -			     __GFP_NORETRY |
> -			     __GFP_NOWARN |
> -			     __GFP_NOMEMALLOC);
> -
>  	kref_init(&obj->refcount);
>  	kref_init(&obj->handlecount);
>  	obj->size = size;
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 28b8f03..1ef5b54 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -336,25 +336,25 @@ i915_gem_object_set_page_gfp_mask (struct drm_gem_object *obj, gfp_t gfp)
>  static int
>  i915_gem_object_get_pages_or_evict(struct drm_gem_object *obj)
>  {
> +	gfp_t gfp;
>  	int ret;
>  
> +	gfp = i915_gem_object_get_page_gfp_mask(obj);
> +	i915_gem_object_set_page_gfp_mask(obj, gfp | __GFP_NORETRY | __GFP_NOWARN);
>  	ret = i915_gem_object_get_pages(obj);
> +	i915_gem_object_set_page_gfp_mask (obj, gfp);
>  
>  	/* If we've insufficient memory to map in the pages, attempt
>  	 * to make some space by throwing out some old buffers.
>  	 */
>  	if (ret == -ENOMEM) {
>  		struct drm_device *dev = obj->dev;
> -		gfp_t gfp;
>  
>  		ret = i915_gem_evict_something(dev, obj->size);
>  		if (ret)
>  			return ret;
>  
> -		gfp = i915_gem_object_get_page_gfp_mask(obj);
> -		i915_gem_object_set_page_gfp_mask(obj, gfp & ~__GFP_NORETRY);
>  		ret = i915_gem_object_get_pages(obj);
> -		i915_gem_object_set_page_gfp_mask (obj, gfp);
>  	}
>  
>  	return ret;
> @@ -2580,6 +2580,7 @@ i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, unsigned alignment)
>  	struct drm_i915_gem_object *obj_priv = obj->driver_private;
>  	struct drm_mm_node *free_space;
>  	bool retry_alloc = false;
> +	gfp_t gfp;
>  	int ret;
>  
>  	if (obj_priv->madv != I915_MADV_WILLNEED) {
> @@ -2623,15 +2624,12 @@ i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, unsigned alignment)
>  	DRM_INFO("Binding object of size %zd at 0x%08x\n",
>  		 obj->size, obj_priv->gtt_offset);
>  #endif
> -	if (retry_alloc) {
> -		i915_gem_object_set_page_gfp_mask (obj,
> -						   i915_gem_object_get_page_gfp_mask (obj) & ~__GFP_NORETRY);
> -	}
> +	gfp = i915_gem_object_get_page_gfp_mask(obj);
> +	if (! retry_alloc)
> +		i915_gem_object_set_page_gfp_mask (obj, gfp | __GFP_NORETRY | __GFP_NOWARN);
>  	ret = i915_gem_object_get_pages(obj);
> -	if (retry_alloc) {
> -		i915_gem_object_set_page_gfp_mask (obj,
> -						   i915_gem_object_get_page_gfp_mask (obj) | __GFP_NORETRY);
> -	}
> +	i915_gem_object_set_page_gfp_mask (obj, gfp);
> +
>  	if (ret) {
>  		drm_mm_put_block(obj_priv->gtt_space);
>  		obj_priv->gtt_space = NULL;


  reply	other threads:[~2010-01-27 11:20 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-14 13:15 OOM-Killer kills too much with 2.6.32.2 Roman Jarosz
2010-01-23  0:40 ` David Rientjes
2010-01-25 22:12   ` Roman Jarosz
2010-01-25  1:48 ` KOSAKI Motohiro
2010-01-25 20:47   ` Roman Jarosz
2010-01-26  5:19     ` KOSAKI Motohiro
2010-01-26  7:51       ` A Rojas
2010-01-26  9:06       ` Roman Jarosz
2010-01-26 11:07         ` KOSAKI Motohiro
2010-01-26 12:33           ` Chris Wilson
2010-01-26 13:03             ` KOSAKI Motohiro
2010-01-26 13:18               ` Chris Wilson
2010-01-26 13:59                 ` Michael Reinelt
2010-01-26 14:07                   ` Michael Reinelt
2010-01-27  0:50                 ` KOSAKI Motohiro
2010-01-27  9:56                   ` Pekka Enberg
2010-01-27 10:55                     ` Linus Torvalds
2010-01-27 11:12                       ` Pekka Enberg
2010-01-27 11:14                       ` [PATCH] drm/i915: Selectively enable self-reclaim Chris Wilson
2010-01-27 11:20                         ` Pekka Enberg [this message]
2010-01-27 11:30                           ` Michael Reinelt
2010-01-28  3:15                           ` Michael Reinelt
2010-01-28 18:21                             ` Roman Jarosz
2010-01-27 11:50                         ` KOSAKI Motohiro
2010-01-27 12:16                         ` Linus Torvalds
2010-01-27 12:28                           ` Linus Torvalds
2010-01-27 15:25                           ` Chris Wilson
2010-01-27 16:09                             ` Linus Torvalds
2010-01-27 17:14                               ` Chris Wilson
2010-01-27 17:19                                 ` Linus Torvalds
2010-01-27 21:03                                   ` Roman Jarosz
2010-06-30  6:54                                   ` [Intel-gfx] " Dave Airlie
2010-06-30  7:05                                     ` Chris Wilson
2010-06-30 23:07                                       ` Linus Torvalds
2010-07-01  1:24                                         ` Linus Torvalds
2010-07-01  1:55                                           ` KOSAKI Motohiro
2010-07-01 10:15                                           ` Dave Airlie
2010-07-01 11:19                                           ` Chris Wilson
2010-07-01 22:34                                           ` M. Vefa Bicakci
2010-07-01 23:59                                             ` Linus Torvalds
2010-07-02  0:06                                               ` Dave Airlie
2010-07-02  0:49                                                 ` Dave Airlie
2010-07-02  1:28                                                   ` Linus Torvalds
2010-07-17 18:58                                                     ` M. Vefa Bicakci
2010-07-17 19:15                                                       ` Linus Torvalds
2010-07-18 14:27                                                         ` M. Vefa Bicakci
2010-07-18 16:59                                                           ` Linus Torvalds
2010-01-28  6:37                                 ` Willy Tarreau
2010-01-26 13:41           ` OOM-Killer kills too much with 2.6.32.2 Roman Jarosz
2010-01-27  0:14             ` KOSAKI Motohiro
2010-01-27  9:53               ` Roman Jarosz
2010-01-26 13:57       ` Pekka Enberg

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=4B602186.8050303@cs.helsinki.fi \
    --to=penberg@cs.helsinki.fi \
    --cc=arnaud.boulan@libertysurf.fr \
    --cc=chris@chris-wilson.co.uk \
    --cc=earny@net4u.de \
    --cc=eric@anholt.net \
    --cc=hugh.dickins@tiscali.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jbarnes@virtuousgeek.org \
    --cc=jcnengel@googlemail.com \
    --cc=kedgedev@gmail.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael@reinelt.co.at \
    --cc=nqn1976list@gmail.com \
    --cc=rientjes@google.com \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.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