From: Mike Christie <mchristi@redhat.com>
To: Damien Le Moal <damien.lemoal@wdc.com>,
linux-scsi@vger.kernel.org,
"Martin K . Petersen" <martin.petersen@oracle.com>,
target-devel@vger.kernel.org
Subject: Re: [PATCH v2] target: core: Prevent memory reclaim recursion
Date: Fri, 8 Nov 2019 09:19:11 -0600 [thread overview]
Message-ID: <5DC5876F.2000301@redhat.com> (raw)
In-Reply-To: <20191108082901.417950-1-damien.lemoal@wdc.com>
On 11/08/2019 02:29 AM, Damien Le Moal wrote:
> Prevent recursion into the IO path under low memory conditions by using
> GFP_NOIO in place of GFP_KERNEL when allocating a new command with
> tcmu_alloc_cmd() and user ring space with tcmu_get_empty_block().
>
> Reported-by: Masato Suzuki <masato.suzuki@wdc.com>
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> ---
>
> Changes from v1:
> * Added reported-by tag
>
> drivers/target/target_core_user.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
> index 35be1be87d2a..0b9dfa6b17bc 100644
> --- a/drivers/target/target_core_user.c
> +++ b/drivers/target/target_core_user.c
> @@ -499,7 +499,7 @@ static inline bool tcmu_get_empty_block(struct tcmu_dev *udev,
> schedule_delayed_work(&tcmu_unmap_work, 0);
>
> /* try to get new page from the mm */
> - page = alloc_page(GFP_KERNEL);
> + page = alloc_page(GFP_NOIO);
> if (!page)
> goto err_alloc;
>
> @@ -573,7 +573,7 @@ static struct tcmu_cmd *tcmu_alloc_cmd(struct se_cmd *se_cmd)
> struct tcmu_dev *udev = TCMU_DEV(se_dev);
> struct tcmu_cmd *tcmu_cmd;
>
> - tcmu_cmd = kmem_cache_zalloc(tcmu_cmd_cache, GFP_KERNEL);
> + tcmu_cmd = kmem_cache_zalloc(tcmu_cmd_cache, GFP_NOIO);
> if (!tcmu_cmd)
> return NULL;
>
> @@ -584,7 +584,7 @@ static struct tcmu_cmd *tcmu_alloc_cmd(struct se_cmd *se_cmd)
> tcmu_cmd_reset_dbi_cur(tcmu_cmd);
> tcmu_cmd->dbi_cnt = tcmu_cmd_get_block_cnt(tcmu_cmd);
> tcmu_cmd->dbi = kcalloc(tcmu_cmd->dbi_cnt, sizeof(uint32_t),
> - GFP_KERNEL);
> + GFP_NOIO);
> if (!tcmu_cmd->dbi) {
> kmem_cache_free(tcmu_cmd_cache, tcmu_cmd);
> return NULL;
>
Acked-by: Mike Christie <mchristi@redhat.com>
We should also change tcmu_setup_cmd_timer so the gfp use in that code
path is consistent. I think we can do that in a separate patch later as
this one just fixes a specific bug.
WARNING: multiple messages have this Message-ID (diff)
From: Mike Christie <mchristi@redhat.com>
To: Damien Le Moal <damien.lemoal@wdc.com>,
linux-scsi@vger.kernel.org,
"Martin K . Petersen" <martin.petersen@oracle.com>,
target-devel@vger.kernel.org
Subject: Re: [PATCH v2] target: core: Prevent memory reclaim recursion
Date: Fri, 08 Nov 2019 15:19:11 +0000 [thread overview]
Message-ID: <5DC5876F.2000301@redhat.com> (raw)
In-Reply-To: <20191108082901.417950-1-damien.lemoal@wdc.com>
On 11/08/2019 02:29 AM, Damien Le Moal wrote:
> Prevent recursion into the IO path under low memory conditions by using
> GFP_NOIO in place of GFP_KERNEL when allocating a new command with
> tcmu_alloc_cmd() and user ring space with tcmu_get_empty_block().
>
> Reported-by: Masato Suzuki <masato.suzuki@wdc.com>
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> ---
>
> Changes from v1:
> * Added reported-by tag
>
> drivers/target/target_core_user.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
> index 35be1be87d2a..0b9dfa6b17bc 100644
> --- a/drivers/target/target_core_user.c
> +++ b/drivers/target/target_core_user.c
> @@ -499,7 +499,7 @@ static inline bool tcmu_get_empty_block(struct tcmu_dev *udev,
> schedule_delayed_work(&tcmu_unmap_work, 0);
>
> /* try to get new page from the mm */
> - page = alloc_page(GFP_KERNEL);
> + page = alloc_page(GFP_NOIO);
> if (!page)
> goto err_alloc;
>
> @@ -573,7 +573,7 @@ static struct tcmu_cmd *tcmu_alloc_cmd(struct se_cmd *se_cmd)
> struct tcmu_dev *udev = TCMU_DEV(se_dev);
> struct tcmu_cmd *tcmu_cmd;
>
> - tcmu_cmd = kmem_cache_zalloc(tcmu_cmd_cache, GFP_KERNEL);
> + tcmu_cmd = kmem_cache_zalloc(tcmu_cmd_cache, GFP_NOIO);
> if (!tcmu_cmd)
> return NULL;
>
> @@ -584,7 +584,7 @@ static struct tcmu_cmd *tcmu_alloc_cmd(struct se_cmd *se_cmd)
> tcmu_cmd_reset_dbi_cur(tcmu_cmd);
> tcmu_cmd->dbi_cnt = tcmu_cmd_get_block_cnt(tcmu_cmd);
> tcmu_cmd->dbi = kcalloc(tcmu_cmd->dbi_cnt, sizeof(uint32_t),
> - GFP_KERNEL);
> + GFP_NOIO);
> if (!tcmu_cmd->dbi) {
> kmem_cache_free(tcmu_cmd_cache, tcmu_cmd);
> return NULL;
>
Acked-by: Mike Christie <mchristi@redhat.com>
We should also change tcmu_setup_cmd_timer so the gfp use in that code
path is consistent. I think we can do that in a separate patch later as
this one just fixes a specific bug.
next prev parent reply other threads:[~2019-11-08 15:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-08 8:29 [PATCH v2] target: core: Prevent memory reclaim recursion Damien Le Moal
2019-11-08 8:29 ` Damien Le Moal
2019-11-08 15:19 ` Mike Christie [this message]
2019-11-08 15:19 ` Mike Christie
2019-11-08 16:22 ` Bart Van Assche
2019-11-08 16:22 ` Bart Van Assche
2019-11-08 16:34 ` Mike Christie
2019-11-08 16:34 ` Mike Christie
2019-11-09 2:18 ` Damien Le Moal
2019-11-09 2:18 ` Damien Le Moal
2019-11-09 2:38 ` Martin K. Petersen
2019-11-09 2:38 ` Martin K. Petersen
2019-11-08 17:02 ` Bart Van Assche
2019-11-08 17:02 ` Bart Van Assche
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=5DC5876F.2000301@redhat.com \
--to=mchristi@redhat.com \
--cc=damien.lemoal@wdc.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=target-devel@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 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.