From: Antonio Quartulli <ordex@autistici.org>
To: "Martin Hundebøll" <martin@hundeboll.net>
Cc: The list for a Better Approach To Mobile Ad-hoc Networking
<b.a.t.m.a.n@lists.open-mesh.org>
Subject: Re: [B.A.T.M.A.N.] [PATCHv3 3/3] batman-adv: Fragment and send skbs larger than mtu
Date: Thu, 23 May 2013 09:29:42 +0200 [thread overview]
Message-ID: <20130523072942.GB1679@ritirata.org> (raw)
In-Reply-To: <519DAB59.9070001@hundeboll.net>
[-- Attachment #1: Type: text/plain, Size: 2856 bytes --]
Hi Martin,
On Thu, May 23, 2013 at 07:38:33AM +0200, Martin Hundebøll wrote:
> Hi Antonio,
>
> On 2013-05-21 21:19, Antonio Quartulli wrote:
> > On Tue, May 21, 2013 at 12:48:19PM +0200, Martin Hundebøll wrote:
> >> +static struct sk_buff *batadv_frag_create(struct sk_buff *skb,
> >> + struct batadv_frag_packet *frag_head,
> >> + unsigned int mtu)
> >> +{
> >> + struct sk_buff *skb_fragment;
> >> + unsigned header_size = sizeof(*frag_head);
> >> + unsigned fragment_size = mtu - header_size;
> >> +
> >> + skb_fragment = dev_alloc_skb(mtu + ETH_HLEN);
> >> + if (!skb_fragment)
> >> + goto err;
> >> +
> >> + /* Eat the last mtu-bytes of the skb */
> >> + skb_reserve(skb_fragment, header_size + ETH_HLEN);
> >> + skb_split(skb, skb_fragment, skb->len - fragment_size);
> >> +
> >> + /* Add the header */
> >> + skb_push(skb_fragment, header_size);
> >> + memcpy(skb_fragment->data, frag_head, header_size);
> >
> > here we are copying the data right after the Fragment header. However I am not
> > sure we are accessing aligned memory because:
> >
> > ETH_HLEN + header_size = 14 + 20 = 34
> >
> > To speed up the copy, wouldn't it be better to allocate ETH_HLEN +
> > header_size + IP_ALIGN bytes like we do for other packets? (you can use
> > netdev_alloc_skb_ip_align() like we do somewhere else).
> >
> > In this way the memcpy will access a 4bytes aligned memory (if I am not wrong).
> >
> > Can somebody else comment on this?
>
> I did a quick test by adding some printk-debugging after skb_split() and
> skb_push():
> printk("data: %lu\n", (unsigned long)skb->data % 4);
>
> and it seems like the skb->data pointer is aligned to boundaries of 4 in
> both with and without the use of netdev_alloc_skb_ip_align().
>
Because in x86 NET_IP_ALIGN is 0 since unaligned memory is correctly handled in
hardware using DMA
(http://lingrok.org/xref/linux-net-next/arch/x86/include/asm/processor.h#40).
I don't know if my explanation is correct, but refer to the link for more
details :D
> This was done on x86_64 virtual machines. Is there another way this
> should be tested or maybe on some different architecture?
>
I guess MIPS would be a good choice (like most of the routers out there).
Please, put the printk before and after the push(). Before the push it will give
us an idea of how the header is going to be aligned (which is the most important
case since memcpy does not care about unaligned memory - it accesses memory byte
by byte). You can try to do this tests on the x86 too.
> The next revision is pretty much ready, but I will keep it back a bit,
> until someone clarifies this align stuff :)
>
Thank you very much for these tests!!
Cheers,
--
Antonio Quartulli
..each of us alone is worth nothing..
Ernesto "Che" Guevara
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2013-05-23 7:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-21 10:48 [B.A.T.M.A.N.] [PATCHv3 0/3] Fragmentation version 2 Martin Hundebøll
2013-05-21 10:48 ` [B.A.T.M.A.N.] [PATCHv3 1/3] batman-adv: Remove old fragmentation code Martin Hundebøll
2013-05-21 10:48 ` [B.A.T.M.A.N.] [PATCHv3 2/3] batman-adv: Receive fragmented packets and merge Martin Hundebøll
2013-05-21 19:10 ` Antonio Quartulli
2013-05-23 5:07 ` Martin Hundebøll
2013-05-21 10:48 ` [B.A.T.M.A.N.] [PATCHv3 3/3] batman-adv: Fragment and send skbs larger than mtu Martin Hundebøll
2013-05-21 19:19 ` Antonio Quartulli
2013-05-23 5:38 ` Martin Hundebøll
2013-05-23 7:29 ` Antonio Quartulli [this message]
2013-05-23 8:46 ` Antonio Quartulli
2013-05-23 8:51 ` [B.A.T.M.A.N.] [PATCHv3 0/3] Fragmentation version 2 Antonio Quartulli
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=20130523072942.GB1679@ritirata.org \
--to=ordex@autistici.org \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
--cc=martin@hundeboll.net \
/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