From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
To: Dan Carpenter <error27-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Roland Dreier <rolandd-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>,
Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Hal Rosenstock
<hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [patch v3] infiniband: uverbs: handle large number of entries
Date: Tue, 12 Oct 2010 21:01:18 +0000 [thread overview]
Message-ID: <20101012210118.GR24268@obsidianresearch.com> (raw)
In-Reply-To: <20101012113117.GB6742@bicker>
On Tue, Oct 12, 2010 at 01:31:17PM +0200, Dan Carpenter wrote:
> In the original code there was a potential integer overflow if you
> passed in a large cmd.ne. The calls to kmalloc() would allocate smaller
> buffers than intended, leading to memory corruption.
Keep in mind these are probably performance sensitive APIs, I was
imagining batching a small number and they copy_to_user ? No idea what
the various performance trades offs are..
> Please, please, check this. I've think I've done it right, but I don't
> have the hardware and can not test it.
Nor, do I.. I actually don't know what hardware uses this path? The
Mellanox cards use a user-space only version.
Maybe an iwarp card? I kinda recall some recent messages concerning
memory allocations in these paths for iwarp. I wonder if removing the
allocation is such a big win the larger number of copy_to_user calls
does not matter?
> It's strange to me that we return "in_len" on success.
Agree..
> +static int copy_header_to_user(void __user *dest, u32 count)
> +{
> + u32 header[2]; /* the second u32 is reserved */
> +
> + memset(header, 0, sizeof(header));
Don't you need header[0] = count ?
Maybe:
u32 header[2] = {count};
And let the compiler 0 the other word optimally. Also, I'm not matters
here, since you are zeroing user memory that isn't currently used..
> +static int copy_wc_to_user(void __user *dest, struct ib_wc *wc)
> +{
> + struct ib_uverbs_wc tmp;
> +
> + memset(&tmp, 0, sizeof(tmp));
I'd really like to see that memset go away for performance. Again
maybe use named initializers and let the compiler zero the
uninitialized (does it zero padding, I wonder?). Or pre-zero this
memory outside the loop..
Jason
next prev parent reply other threads:[~2010-10-12 21:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-07 7:16 [patch] infiniband: uverbs: limit the number of entries Dan Carpenter
2010-10-07 16:16 ` Jason Gunthorpe
[not found] ` <20101007161649.GD21206-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-10-07 16:59 ` Dan Carpenter
2010-10-08 7:59 ` Nicolas Palix
[not found] ` <AANLkTin5zou2JHsdDyhGESuxyPonOs3kLo9Th0vg-kd8-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-10-08 14:25 ` [patch v2] " Dan Carpenter
2010-10-09 23:16 ` [patch] " Jason Gunthorpe
[not found] ` <20101009231607.GA24649-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-10-12 11:31 ` [patch v3] infiniband: uverbs: handle large " Dan Carpenter
2010-10-12 21:01 ` Jason Gunthorpe [this message]
[not found] ` <20101012210118.GR24268-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-10-13 9:05 ` Dan Carpenter
2010-10-13 9:13 ` [patch v4] " Dan Carpenter
2010-11-23 7:10 ` Dan Carpenter
2010-11-24 22:07 ` Roland Dreier
[not found] ` <adahbf6gytv.fsf-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>
2010-11-24 22:18 ` Jason Gunthorpe
[not found] ` <20101124221845.GH2369-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2010-11-25 4:05 ` Roland Dreier
[not found] ` <adad3pugi90.fsf-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>
2010-11-25 4:13 ` Jason Gunthorpe
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=20101012210118.GR24268@obsidianresearch.com \
--to=jgunthorpe@obsidianresearch.com \
--cc=error27-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=rolandd-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org \
--cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.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).