From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> To: netdev@vger.kernel.org Cc: linux-sctp@vger.kernel.org, Neil Horman <nhorman@tuxdriver.com>, Vlad Yasevich <vyasevich@gmail.com>, Xin Long <lucien.xin@gmail.com>, David Laight <David.Laight@ACULAB.COM> Subject: [PATCH net-next 01/10] sctp: silence warns on sctp_stream_init allocations Date: Thu, 28 Sep 2017 17:25:14 -0300 [thread overview] Message-ID: <78853a7e413d1900fb410d73d064558fa09f221d.1506536044.git.marcelo.leitner@gmail.com> (raw) In-Reply-To: <cover.1506536044.git.marcelo.leitner@gmail.com> As SCTP supports up to 65535 streams, that can lead to very large allocations in sctp_stream_init(). As Xin Long noticed, systems with small amounts of memory are more prone to not have enough memory and dump warnings on dmesg initiated by user actions. Thus, silence them. Also, if the reallocation of stream->out is not necessary, skip it and keep the memory we already have. Reported-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> --- net/sctp/stream.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/sctp/stream.c b/net/sctp/stream.c index 63ea1550371493ec8863627c7a43f46a22f4a4c9..1afa9555808390d5fc736727422d9700a3855613 100644 --- a/net/sctp/stream.c +++ b/net/sctp/stream.c @@ -40,9 +40,14 @@ int sctp_stream_init(struct sctp_stream *stream, __u16 outcnt, __u16 incnt, { int i; + gfp |= __GFP_NOWARN; + /* Initial stream->out size may be very big, so free it and alloc - * a new one with new outcnt to save memory. + * a new one with new outcnt to save memory if needed. */ + if (outcnt == stream->outcnt) + goto in; + kfree(stream->out); stream->out = kcalloc(outcnt, sizeof(*stream->out), gfp); @@ -53,6 +58,7 @@ int sctp_stream_init(struct sctp_stream *stream, __u16 outcnt, __u16 incnt, for (i = 0; i < stream->outcnt; i++) stream->out[i].state = SCTP_STREAM_OPEN; +in: if (!incnt) return 0; -- 2.13.5
WARNING: multiple messages have this Message-ID (diff)
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> To: netdev@vger.kernel.org Cc: linux-sctp@vger.kernel.org, Neil Horman <nhorman@tuxdriver.com>, Vlad Yasevich <vyasevich@gmail.com>, Xin Long <lucien.xin@gmail.com>, David Laight <David.Laight@ACULAB.COM> Subject: [PATCH net-next 01/10] sctp: silence warns on sctp_stream_init allocations Date: Thu, 28 Sep 2017 20:25:14 +0000 [thread overview] Message-ID: <78853a7e413d1900fb410d73d064558fa09f221d.1506536044.git.marcelo.leitner@gmail.com> (raw) In-Reply-To: <cover.1506536044.git.marcelo.leitner@gmail.com> As SCTP supports up to 65535 streams, that can lead to very large allocations in sctp_stream_init(). As Xin Long noticed, systems with small amounts of memory are more prone to not have enough memory and dump warnings on dmesg initiated by user actions. Thus, silence them. Also, if the reallocation of stream->out is not necessary, skip it and keep the memory we already have. Reported-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> --- net/sctp/stream.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/sctp/stream.c b/net/sctp/stream.c index 63ea1550371493ec8863627c7a43f46a22f4a4c9..1afa9555808390d5fc736727422d9700a3855613 100644 --- a/net/sctp/stream.c +++ b/net/sctp/stream.c @@ -40,9 +40,14 @@ int sctp_stream_init(struct sctp_stream *stream, __u16 outcnt, __u16 incnt, { int i; + gfp |= __GFP_NOWARN; + /* Initial stream->out size may be very big, so free it and alloc - * a new one with new outcnt to save memory. + * a new one with new outcnt to save memory if needed. */ + if (outcnt = stream->outcnt) + goto in; + kfree(stream->out); stream->out = kcalloc(outcnt, sizeof(*stream->out), gfp); @@ -53,6 +58,7 @@ int sctp_stream_init(struct sctp_stream *stream, __u16 outcnt, __u16 incnt, for (i = 0; i < stream->outcnt; i++) stream->out[i].state = SCTP_STREAM_OPEN; +in: if (!incnt) return 0; -- 2.13.5
next prev parent reply other threads:[~2017-09-28 20:25 UTC|newest] Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-09-28 20:25 [PATCH net-next 00/10] Introduce SCTP Stream Schedulers Marcelo Ricardo Leitner 2017-09-28 20:25 ` Marcelo Ricardo Leitner 2017-09-28 20:25 ` Marcelo Ricardo Leitner [this message] 2017-09-28 20:25 ` [PATCH net-next 01/10] sctp: silence warns on sctp_stream_init allocations Marcelo Ricardo Leitner 2017-09-28 20:25 ` [PATCH net-next 02/10] sctp: factor out stream->out allocation Marcelo Ricardo Leitner 2017-09-28 20:25 ` Marcelo Ricardo Leitner 2017-09-28 20:25 ` [PATCH net-next 03/10] sctp: factor out stream->in allocation Marcelo Ricardo Leitner 2017-09-28 20:25 ` Marcelo Ricardo Leitner 2017-09-29 10:04 ` David Laight 2017-09-29 13:05 ` 'Marcelo Ricardo Leitner' 2017-09-29 13:05 ` 'Marcelo Ricardo Leitner' 2017-09-28 20:25 ` [PATCH net-next 04/10] sctp: introduce struct sctp_stream_out_ext Marcelo Ricardo Leitner 2017-09-28 20:25 ` Marcelo Ricardo Leitner 2017-09-28 20:25 ` [PATCH net-next 05/10] sctp: introduce sctp_chunk_stream_no Marcelo Ricardo Leitner 2017-09-28 20:25 ` Marcelo Ricardo Leitner 2017-09-28 20:25 ` [PATCH net-next 06/10] sctp: introduce stream scheduler foundations Marcelo Ricardo Leitner 2017-09-28 20:25 ` Marcelo Ricardo Leitner 2017-09-28 20:25 ` [PATCH net-next 07/10] sctp: add sockopt to get/set stream scheduler Marcelo Ricardo Leitner 2017-09-28 20:25 ` Marcelo Ricardo Leitner 2017-09-29 16:47 ` Neil Horman 2017-09-29 16:47 ` Neil Horman 2017-09-29 17:14 ` Marcelo Ricardo Leitner 2017-09-29 17:14 ` Marcelo Ricardo Leitner 2017-09-28 20:25 ` [PATCH net-next 08/10] sctp: add sockopt to get/set stream scheduler parameters Marcelo Ricardo Leitner 2017-09-28 20:25 ` Marcelo Ricardo Leitner 2017-09-28 20:25 ` [PATCH net-next 09/10] sctp: introduce priority based stream scheduler Marcelo Ricardo Leitner 2017-09-28 20:25 ` Marcelo Ricardo Leitner 2017-09-29 16:54 ` Neil Horman 2017-09-29 16:54 ` Neil Horman 2017-09-29 17:10 ` Marcelo Ricardo Leitner 2017-09-29 17:10 ` Marcelo Ricardo Leitner 2017-09-28 20:25 ` [PATCH net-next 10/10] sctp: introduce round robin " Marcelo Ricardo Leitner 2017-09-28 20:25 ` Marcelo Ricardo Leitner 2017-09-30 16:52 ` [PATCH net-next 00/10] Introduce SCTP Stream Schedulers Xin Long 2017-09-30 16:52 ` Xin Long
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=78853a7e413d1900fb410d73d064558fa09f221d.1506536044.git.marcelo.leitner@gmail.com \ --to=marcelo.leitner@gmail.com \ --cc=David.Laight@ACULAB.COM \ --cc=linux-sctp@vger.kernel.org \ --cc=lucien.xin@gmail.com \ --cc=netdev@vger.kernel.org \ --cc=nhorman@tuxdriver.com \ --cc=vyasevich@gmail.com \ /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: linkBe 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.