All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig-5C7GfCeVMHo@public.gmane.org>
To: Andrey Grodzovsky
	<andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org>,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: Hongbo.He-5C7GfCeVMHo@public.gmane.org
Subject: Re: [PATCH v2 1/2] drm/ttm: Allow page allocations w/o triggering OOM..
Date: Tue, 16 Jan 2018 16:22:52 +0100	[thread overview]
Message-ID: <a8e08218-774b-c91f-2024-9eb531055df3@amd.com> (raw)
In-Reply-To: <1516115906-26095-1-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org>

Am 16.01.2018 um 16:18 schrieb Andrey Grodzovsky:
> This to allow drivers to choose to avoid OOM invocation and handle
> page allocation failures instead.
>
> v2:
> Remove extra new lines.
>
> Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com>

Reviewed-by: Christian König <christian.koenig@amd.com> for the series.

> ---
>   drivers/gpu/drm/ttm/ttm_bo.c             |  3 +++
>   drivers/gpu/drm/ttm/ttm_page_alloc.c     |  6 ++++++
>   drivers/gpu/drm/ttm/ttm_page_alloc_dma.c |  3 +++
>   drivers/gpu/drm/ttm/ttm_tt.c             | 13 +++++++++++--
>   include/drm/ttm/ttm_bo_driver.h          |  4 ++++
>   5 files changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 2eb71ff..f32aab1 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -234,6 +234,9 @@ static int ttm_bo_add_ttm(struct ttm_buffer_object *bo, bool zero_alloc)
>   	if (bdev->need_dma32)
>   		page_flags |= TTM_PAGE_FLAG_DMA32;
>   
> +	if (bdev->no_retry)
> +		page_flags |= TTM_PAGE_FLAG_NO_RETRY;
> +
>   	switch (bo->type) {
>   	case ttm_bo_type_device:
>   		if (zero_alloc)
> diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
> index 0eab24e..f34c843 100644
> --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
> +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
> @@ -741,6 +741,9 @@ static int ttm_page_pool_get_pages(struct ttm_page_pool *pool,
>   		if (ttm_flags & TTM_PAGE_FLAG_ZERO_ALLOC)
>   			gfp_flags |= __GFP_ZERO;
>   
> +		if (ttm_flags & TTM_PAGE_FLAG_NO_RETRY)
> +			gfp_flags |= __GFP_RETRY_MAYFAIL;
> +
>   		/* ttm_alloc_new_pages doesn't reference pool so we can run
>   		 * multiple requests in parallel.
>   		 **/
> @@ -893,6 +896,9 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags,
>   		if (flags & TTM_PAGE_FLAG_ZERO_ALLOC)
>   			gfp_flags |= __GFP_ZERO;
>   
> +		if (flags & TTM_PAGE_FLAG_NO_RETRY)
> +			gfp_flags |= __GFP_RETRY_MAYFAIL;
> +
>   		if (flags & TTM_PAGE_FLAG_DMA32)
>   			gfp_flags |= GFP_DMA32;
>   		else
> diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
> index c7f01a4..6949ef7 100644
> --- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
> +++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
> @@ -920,6 +920,9 @@ static gfp_t ttm_dma_pool_gfp_flags(struct ttm_dma_tt *ttm_dma, bool huge)
>   		gfp_flags &= ~__GFP_COMP;
>   	}
>   
> +	if (ttm->page_flags & TTM_PAGE_FLAG_NO_RETRY)
> +		gfp_flags |= __GFP_RETRY_MAYFAIL;
> +
>   	return gfp_flags;
>   }
>   
> diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
> index 5a046a3..9e4d43d 100644
> --- a/drivers/gpu/drm/ttm/ttm_tt.c
> +++ b/drivers/gpu/drm/ttm/ttm_tt.c
> @@ -301,7 +301,11 @@ int ttm_tt_swapin(struct ttm_tt *ttm)
>   	swap_space = swap_storage->f_mapping;
>   
>   	for (i = 0; i < ttm->num_pages; ++i) {
> -		from_page = shmem_read_mapping_page(swap_space, i);
> +		gfp_t gfp_mask = mapping_gfp_mask(swap_space);
> +
> +		gfp_mask |= (ttm->page_flags & TTM_PAGE_FLAG_NO_RETRY ? __GFP_RETRY_MAYFAIL : 0);
> +		from_page = shmem_read_mapping_page_gfp(swap_space, i, gfp_mask);
> +
>   		if (IS_ERR(from_page)) {
>   			ret = PTR_ERR(from_page);
>   			goto out_err;
> @@ -350,10 +354,15 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage)
>   	swap_space = swap_storage->f_mapping;
>   
>   	for (i = 0; i < ttm->num_pages; ++i) {
> +		gfp_t gfp_mask = mapping_gfp_mask(swap_space);
> +
> +		gfp_mask |= (ttm->page_flags & TTM_PAGE_FLAG_NO_RETRY ? __GFP_RETRY_MAYFAIL : 0);
> +
>   		from_page = ttm->pages[i];
>   		if (unlikely(from_page == NULL))
>   			continue;
> -		to_page = shmem_read_mapping_page(swap_space, i);
> +
> +		to_page = shmem_read_mapping_page_gfp(swap_space, i, gfp_mask);
>   		if (IS_ERR(to_page)) {
>   			ret = PTR_ERR(to_page);
>   			goto out_err;
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 94064b1..9b417eb 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -86,6 +86,7 @@ struct ttm_backend_func {
>   #define TTM_PAGE_FLAG_ZERO_ALLOC      (1 << 6)
>   #define TTM_PAGE_FLAG_DMA32           (1 << 7)
>   #define TTM_PAGE_FLAG_SG              (1 << 8)
> +#define TTM_PAGE_FLAG_NO_RETRY	       (1 << 9)
>   
>   enum ttm_caching_state {
>   	tt_uncached,
> @@ -556,6 +557,7 @@ struct ttm_bo_global {
>    * @dev_mapping: A pointer to the struct address_space representing the
>    * device address space.
>    * @wq: Work queue structure for the delayed delete workqueue.
> + * @no_retry: Don't retry allocation if it fails
>    *
>    */
>   
> @@ -592,6 +594,8 @@ struct ttm_bo_device {
>   	struct delayed_work wq;
>   
>   	bool need_dma32;
> +
> +	bool no_retry;
>   };
>   
>   /**

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2018-01-16 15:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-12 22:28 [PATCH 1/2] drm/ttm: Allow page allocations w/o triggering OOM Andrey Grodzovsky
2018-01-12 22:28 ` [PATCH 2/2] drm/amdgpu: Use new TTM flag to avoid OOM triggering Andrey Grodzovsky
2018-01-16  6:18   ` He, Roger
     [not found]     ` <MWHPR1201MB012784C4B5F4E7E90FE49F2FFDEA0-3iK1xFAIwjq9imrIu4W8xGrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2018-01-16  8:54       ` Christian König
2018-01-16 12:43         ` Andrey Grodzovsky
     [not found]           ` <2fb8142b-99c2-c682-d867-83da7327030b-5C7GfCeVMHo@public.gmane.org>
2018-01-16 12:46             ` Christian König
2018-01-17  2:09               ` He, Roger
2018-01-16 15:18         ` [PATCH v2 1/2] drm/ttm: Allow page allocations w/o triggering OOM Andrey Grodzovsky
     [not found]           ` <1516115906-26095-1-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org>
2018-01-16 15:18             ` [PATCH v2 2/2] drm/amdgpu: Use new TTM flag to avoid OOM triggering Andrey Grodzovsky
     [not found]               ` <1516115906-26095-2-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org>
2018-01-16 16:42                 ` Felix Kuehling
     [not found]                   ` <ce727655-b4cc-0e41-eeef-7e768fe958d6-5C7GfCeVMHo@public.gmane.org>
2018-01-16 17:28                     ` Andrey Grodzovsky
2018-01-16 19:50                       ` [PATCH v3] " Andrey Grodzovsky
     [not found]                         ` <1516132211-32035-1-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org>
2018-01-16 20:00                           ` Felix Kuehling
2018-01-16 15:22             ` Christian König [this message]
2018-01-17  2:21           ` [PATCH v2 1/2] drm/ttm: Allow page allocations w/o triggering OOM He, Roger
2018-01-16  6:02 ` [PATCH " He, Roger
2018-01-16  8:53   ` Christian König

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=a8e08218-774b-c91f-2024-9eb531055df3@amd.com \
    --to=christian.koenig-5c7gfcevmho@public.gmane.org \
    --cc=Hongbo.He-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.