netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: William Allen Simpson <william.allen.simpson@gmail.com>
To: netdev@vger.kernel.org
Subject: query: TCPCT setsockopt kmalloc's
Date: Tue, 06 Oct 2009 11:53:15 -0400	[thread overview]
Message-ID: <4ACB67EB.6080000@gmail.com> (raw)

On both the client and server side, the setsockopt does a kmalloc().  Only
once per connect on the client side, once per listen on the server side.

However, after Miller's expressed concern, it seems possible to reorganize
the code to do the kmalloc() before the lock_sock().  Does that mean that it
should be GFP_KERNEL?  Or should it still be GFP_ATOMIC?

[Not that anybody cares, but based on recent discussion on the list about
internal kernel coding standards, I've changed Adam's old sizeof(struct)
to sizeof(*tcvp).  Previously, I was trying to make as few changes as
possible, thinking everything was already correct.]

===
new:

+		/* Allocate ancillary memory before locking.
+		 */
+		if ((0 < tcd.tcpcd_used
...
+		 && NULL == (tcvp = kmalloc(sizeof(*tcvp) + tcd.tcpcd_used,
+					    GFP_KERNEL))) {
+			return -ENOMEM;
+		}
+
+		lock_sock(sk);
...
+		} else {
+			if (unlikely(NULL != tp->cookie_values)) {
+				kref_put(&tp->cookie_values->kref,
+					 tcp_cookie_values_release);
+			}
+			kref_init(&tcvp->kref);
...
+			tp->cookie_values = tcvp;
+		}
+
+		release_sock(sk);
+		return err;

===
old:

+		lock_sock(sk);
...
+		} else if (NULL != (tsdplp =
+				    kmalloc(sizeof(struct tcp_s_data_payload)
+					    + tcd.tcpcd_used,
+					    GFP_ATOMIC))) {
+			if (unlikely(tp->s_data_payload)) {
+				kref_put(&tp->s_data_payload->kref,
+					 tcp_s_data_payload_release);
+			}
+			kref_init(&tsdplp->kref);
...
+			tp->s_data_payload = tsdplp;
+		} else {
+			err = -ENOMEM;
+		}
+
+		release_sock(sk);
+		return err;

             reply	other threads:[~2009-10-06 15:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-06 15:53 William Allen Simpson [this message]
2009-10-06 16:31 ` query: TCPCT setsockopt kmalloc's Eric Dumazet

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=4ACB67EB.6080000@gmail.com \
    --to=william.allen.simpson@gmail.com \
    --cc=netdev@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).