public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
To: David Ahern <david.ahern-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] IB/core: Fix unaligned accesses
Date: Wed, 29 Apr 2015 16:15:37 -0600	[thread overview]
Message-ID: <20150429221537.GB31415@obsidianresearch.com> (raw)
In-Reply-To: <55415438.1040205-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

On Wed, Apr 29, 2015 at 03:59:20PM -0600, David Ahern wrote:
> On 4/29/15 3:51 PM, Jason Gunthorpe wrote:
> >On Wed, Apr 29, 2015 at 03:38:22PM -0600, David Ahern wrote:
> >
> >>>And dealing with the fairly few resulting changes..
> >>
> >>Confused. That does not deal with the alignment problem. Internal to
> >>cm_mask_copy unsigned longs are used (8-bytes), so why change the
> >>signature to u32?
> >
> >You'd change the loop stride to by u32 as well.
> >
> >This whole thing is just an attempted optimization, but doing copy and
> >mask 8 bytes at a time on unaligned data is not very efficient, even
> >on x86.
> >
> >So either drop the optimization and use u8 as the stride.
> >
> >Or keep the optimization and guarentee alignment, the best we can do
> >is u32.
> >
> >Since this is an optimization, get_unaligned should be avoided,
> >looping over u8 would be faster.
> 
> Sorry, to be dense on this but I still don't see how your proposal
> addresses the underlying problem -- guarantee of 8 byte alignment.
> Be it a u8 or u32 for the input arguments the cast to unsigned long
> says that an extended load operation can be used for access. For
> that to work the address (src, dst, mask) must all be 8-byte
> aligned.

Read carefully:

> >You'd change the loop stride to by u32 as well.

which means this:

static void cm_mask_copy(u32 *dst, const u32 *src, const u32 *mask)
{
	int i;

	for (i = 0; i < IB_CM_COMPARE_SIZE; i++)
		dst[i] = src[i] & mask[i];
}

Divide IB_CM_COMPARE_SIZE by 4, adjust all users.

Make other related type changes the compiler tells you about.

Do not add casts.

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

  parent reply	other threads:[~2015-04-29 22:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-29 20:56 [PATCH] IB/core: Fix unaligned accesses David Ahern
     [not found] ` <1430340983-12538-1-git-send-email-david.ahern-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2015-04-29 21:18   ` Jason Gunthorpe
     [not found]     ` <20150429211822.GA25951-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-04-29 21:24       ` David Ahern
     [not found]         ` <55414C03.40902-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2015-04-29 21:30           ` Jason Gunthorpe
     [not found]             ` <20150429213042.GA28812-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-04-29 21:38               ` David Ahern
     [not found]                 ` <55414F4E.5020209-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2015-04-29 21:51                   ` Jason Gunthorpe
     [not found]                     ` <20150429215123.GA29809-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-04-29 21:59                       ` David Ahern
     [not found]                         ` <55415438.1040205-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2015-04-29 22:15                           ` Jason Gunthorpe [this message]
     [not found]                             ` <20150429221537.GB31415-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-04-29 22:34                               ` David Ahern

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=20150429221537.GB31415@obsidianresearch.com \
    --to=jgunthorpe-epgobjl8dl3ta4ec/59zmfatqe2ktcn/@public.gmane.org \
    --cc=david.ahern-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@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