* [PATCH] nes: handling failed allocation when creating workqueue
@ 2016-02-17 18:06 Insu Yun
[not found] ` <1455732393-11029-1-git-send-email-wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Insu Yun @ 2016-02-17 18:06 UTC (permalink / raw)
To: faisal.latif, dledford, sean.hefty, hal.rosenstock, linux-rdma,
linux-kernel
Cc: taesoo, yeongjin.jang, insu, changwoo, Insu Yun
Since create_singlethread_workqueue uses kzalloc internally,
it can be failed in memory pressure, so need to handle it.
Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
drivers/infiniband/hw/nes/nes_cm.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index cb9f0f2..23afad6 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -2833,7 +2833,7 @@ static struct nes_cm_core *nes_cm_alloc_core(void)
/* alloc top level core control structure */
cm_core = kzalloc(sizeof(*cm_core), GFP_KERNEL);
if (!cm_core)
- return NULL;
+ goto enomem_3;
INIT_LIST_HEAD(&cm_core->connected_nodes);
init_timer(&cm_core->tcp_timer);
@@ -2856,12 +2856,23 @@ static struct nes_cm_core *nes_cm_alloc_core(void)
nes_debug(NES_DBG_CM, "Enable QUEUE EVENTS\n");
cm_core->event_wq = create_singlethread_workqueue("nesewq");
+ if (!cm_core->event_wq)
+ goto enomem_2;
cm_core->post_event = nes_cm_post_event;
nes_debug(NES_DBG_CM, "Enable QUEUE DISCONNECTS\n");
cm_core->disconn_wq = create_singlethread_workqueue("nesdwq");
+ if (!cm_core->disconn_wq)
+ goto enomem_1;
print_core(cm_core);
return cm_core;
+
+enomem_1:
+ destroy_workqueue(cm_core->event_wq);
+enomem_2:
+ kfree(cm_core);
+enomem_3:
+ return NULL;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread[parent not found: <1455732393-11029-1-git-send-email-wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] nes: handling failed allocation when creating workqueue [not found] ` <1455732393-11029-1-git-send-email-wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2016-02-18 4:59 ` Leon Romanovsky [not found] ` <20160218045905.GF30450-2ukJVAZIZ/Y@public.gmane.org> 0 siblings, 1 reply; 3+ messages in thread From: Leon Romanovsky @ 2016-02-18 4:59 UTC (permalink / raw) To: Insu Yun Cc: faisal.latif-ral2JQCrhuEAvxtiuMwx3w, dledford-H+wXaHxf7aLQT0dZR+AlfA, sean.hefty-ral2JQCrhuEAvxtiuMwx3w, hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w, linux-rdma-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, taesoo-/4noJB3qBVQ3uPMLIKxrzw, yeongjin.jang-/4noJB3qBVQ3uPMLIKxrzw, insu-/4noJB3qBVQ3uPMLIKxrzw, changwoo-/4noJB3qBVQ3uPMLIKxrzw Please see my minor comments below. Reviewed-by: Leon Romanovsky <leon-2ukJVAZIZ/Y@public.gmane.org> On Wed, Feb 17, 2016 at 01:06:33PM -0500, Insu Yun wrote: > Since create_singlethread_workqueue uses kzalloc internally, > it can be failed in memory pressure, so need to handle it. s/can be failed/can fail/ > > Signed-off-by: Insu Yun <wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > drivers/infiniband/hw/nes/nes_cm.c | 13 ++++++++++++- > 1 file changed, 12 insertions(+), 1 deletion(-) > > diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c > index cb9f0f2..23afad6 100644 > --- a/drivers/infiniband/hw/nes/nes_cm.c > +++ b/drivers/infiniband/hw/nes/nes_cm.c > @@ -2833,7 +2833,7 @@ static struct nes_cm_core *nes_cm_alloc_core(void) > /* alloc top level core control structure */ > cm_core = kzalloc(sizeof(*cm_core), GFP_KERNEL); > if (!cm_core) > - return NULL; > + goto enomem_3; IMHO, there is no need to define goto label for one return. > > INIT_LIST_HEAD(&cm_core->connected_nodes); > init_timer(&cm_core->tcp_timer); > @@ -2856,12 +2856,23 @@ static struct nes_cm_core *nes_cm_alloc_core(void) > > nes_debug(NES_DBG_CM, "Enable QUEUE EVENTS\n"); > cm_core->event_wq = create_singlethread_workqueue("nesewq"); > + if (!cm_core->event_wq) > + goto enomem_2; > cm_core->post_event = nes_cm_post_event; > nes_debug(NES_DBG_CM, "Enable QUEUE DISCONNECTS\n"); > cm_core->disconn_wq = create_singlethread_workqueue("nesdwq"); > + if (!cm_core->disconn_wq) > + goto enomem_1; > > print_core(cm_core); > return cm_core; > + > +enomem_1: > + destroy_workqueue(cm_core->event_wq); > +enomem_2: > + kfree(cm_core); > +enomem_3: > + return NULL; > } > > > -- > 1.9.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-rdma" in > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <20160218045905.GF30450-2ukJVAZIZ/Y@public.gmane.org>]
* Re: [PATCH] nes: handling failed allocation when creating workqueue [not found] ` <20160218045905.GF30450-2ukJVAZIZ/Y@public.gmane.org> @ 2016-02-18 17:45 ` Doug Ledford 0 siblings, 0 replies; 3+ messages in thread From: Doug Ledford @ 2016-02-18 17:45 UTC (permalink / raw) To: Insu Yun, faisal.latif-ral2JQCrhuEAvxtiuMwx3w, sean.hefty-ral2JQCrhuEAvxtiuMwx3w, hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w, linux-rdma-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, taesoo-/4noJB3qBVQ3uPMLIKxrzw, yeongjin.jang-/4noJB3qBVQ3uPMLIKxrzw, insu-/4noJB3qBVQ3uPMLIKxrzw, changwoo-/4noJB3qBVQ3uPMLIKxrzw [-- Attachment #1: Type: text/plain, Size: 1216 bytes --] On 2/17/2016 11:59 PM, Leon Romanovsky wrote: > Please see my minor comments below. > Reviewed-by: Leon Romanovsky <leon-2ukJVAZIZ/Y@public.gmane.org> > > On Wed, Feb 17, 2016 at 01:06:33PM -0500, Insu Yun wrote: >> Since create_singlethread_workqueue uses kzalloc internally, >> it can be failed in memory pressure, so need to handle it. > > s/can be failed/can fail/ > >> >> Signed-off-by: Insu Yun <wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> --- >> drivers/infiniband/hw/nes/nes_cm.c | 13 ++++++++++++- >> 1 file changed, 12 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c >> index cb9f0f2..23afad6 100644 >> --- a/drivers/infiniband/hw/nes/nes_cm.c >> +++ b/drivers/infiniband/hw/nes/nes_cm.c >> @@ -2833,7 +2833,7 @@ static struct nes_cm_core *nes_cm_alloc_core(void) >> /* alloc top level core control structure */ >> cm_core = kzalloc(sizeof(*cm_core), GFP_KERNEL); >> if (!cm_core) >> - return NULL; >> + goto enomem_3; > > IMHO, there is no need to define goto label for one return. I made the touchups Leon suggested, and a touchup of my own, but it is now applied, thanks. [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 884 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-02-18 17:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-17 18:06 [PATCH] nes: handling failed allocation when creating workqueue Insu Yun
[not found] ` <1455732393-11029-1-git-send-email-wuninsu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-02-18 4:59 ` Leon Romanovsky
[not found] ` <20160218045905.GF30450-2ukJVAZIZ/Y@public.gmane.org>
2016-02-18 17:45 ` Doug Ledford
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox