netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: William Allen Simpson <william.allen.simpson@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: query: TCPCT setsockopt kmalloc's
Date: Tue, 06 Oct 2009 18:31:16 +0200	[thread overview]
Message-ID: <4ACB70D4.7010108@gmail.com> (raw)
In-Reply-To: <4ACB67EB.6080000@gmail.com>

William Allen Simpson a écrit :
> 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.

But if server has to generate a random data for a connection, you'll have to clone
the data to be able to give it at application request ?

> 
> 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?

GFP_KERNEL is better in this context, it allows the requestor to sleep a bit if necessary.

> 
> [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

Ah, could you please reverse all your conditions ?

Their form are unusual in linux kernel.

if (tcd.tcpcd_used > 0)


> ...
> +         && NULL == (tcvp = kmalloc(sizeof(*tcvp) + tcd.tcpcd_used,
> +                        GFP_KERNEL))) {
> +            return -ENOMEM;
> +        }
>
 
tcvp = kmalloc(sizeof(*tcvp) + tcd.tcpcd_used, GFP_KERNEL));
if (tcvp == NULL) ...


      reply	other threads:[~2009-10-06 16:31 UTC|newest]

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

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=4ACB70D4.7010108@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=william.allen.simpson@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: 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).