From: Annie <annie.li@oracle.com>
To: Annie <annie.li@oracle.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
"wei.liu2@citrix.com" <wei.liu2@citrix.com>,
Ian Campbell <ian.campbell@citrix.com>,
"msw@amazon.com" <msw@amazon.com>
Subject: Re: [PATCH v2 1/1] xen/netback: correctly calculate required slots of skb.
Date: Thu, 11 Jul 2013 18:59:26 +0800 [thread overview]
Message-ID: <3038108B-5529-452A-A488-4E616F7C1B8E@oracle.com> (raw)
In-Reply-To: <4A59CC63-9B57-49FA-A2FD-6903C86E110E@oracle.com>
[-- Attachment #1.1: Type: text/plain, Size: 4426 bytes --]
发自我的 iPhone
在 2013-7-11,下午6:46,Annie <annie.li@oracle.com> 写道:
>
>
> 发自我的 iPhone
>
> 在 2013-7-11,下午5:47,Ian Campbell <ian.campbell@citrix.com> 写道:
>
>> On Thu, 2013-07-11 at 16:34 +0800, annie li wrote:
>>> On 2013-7-11 16:11, Ian Campbell wrote:
>>>> On Wed, 2013-07-10 at 17:15 +0800, Annie Li wrote:
>>>>> +static int netbk_count_slots(struct xenvif *vif, struct sk_buff *skb,
>>>>> + int *copy_off, unsigned long size,
>>>>> + unsigned long offset, int *head)
>>>>> {
>>>>> - unsigned int count;
>>>>> - int i, copy_off;
>>>>> + unsigned long bytes;
>>>>> + int count = 0;
>>>>>
>>>>> - count = DIV_ROUND_UP(skb_headlen(skb), PAGE_SIZE);
>>>>> + offset &= ~PAGE_MASK;
>>>>>
>>>>> - copy_off = skb_headlen(skb) % PAGE_SIZE;
>>>>> + while (size > 0) {
>>>>> + BUG_ON(offset >= PAGE_SIZE);
>>>>> + BUG_ON(*copy_off > MAX_BUFFER_OFFSET);
>>>>>
>>>>> - if (skb_shinfo(skb)->gso_size)
>>>>> - count++;
>>>>> + bytes = PAGE_SIZE - offset;
>>>>>
>>>>> - for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
>>>>> - unsigned long size = skb_frag_size(&skb_shinfo(skb)->frags[i]);
>>>>> - unsigned long offset = skb_shinfo(skb)->frags[i].page_offset;
>>>>> - unsigned long bytes;
>>>>> + if (bytes > size)
>>>>> + bytes = size;
>>>>>
>>>>> - offset &= ~PAGE_MASK;
>>>>> + if (start_new_rx_buffer(*copy_off, bytes, *head)) {
>>>>> + count++;
>>>>> + *copy_off = 0;
>>>>> + }
>>>>>
>>>>> - while (size > 0) {
>>>>> - BUG_ON(offset >= PAGE_SIZE);
>>>>> - BUG_ON(copy_off > MAX_BUFFER_OFFSET);
>>>>> + if (*copy_off + bytes > MAX_BUFFER_OFFSET)
>>>>> + bytes = MAX_BUFFER_OFFSET - *copy_off;
>>>>>
>>>>> - bytes = PAGE_SIZE - offset;
>>>>> + *copy_off += bytes;
>>>>>
>>>>> - if (bytes > size)
>>>>> - bytes = size;
>>>>> + offset += bytes;
>>>>> + size -= bytes;
>>>>>
>>>>> - if (start_new_rx_buffer(copy_off, bytes, 0)) {
>>>>> - count++;
>>>>> - copy_off = 0;
>>>>> - }
>>>>> + /* Next frame */
>>>>> + if (offset == PAGE_SIZE && size)
>>>>> + offset = 0;
>>>>> +
>>>>> + if (*head)
>>>>> + count++;
>>>> This little bit corresponds to the "/* Leave a gap for the GSO
>>>> descriptor. */" in gop_frag_copy?
>>>
>>> No, it does not correspond to this in gop_frag_copy.
>>
>> So what does it correspond to?
>
> It corresponds to following code in gop_frag_copy,
> req = RING_GET_REQUEST(&vif->rx, vif->rx.req_cons++);
Hit the button and Send it wrongly last time, it is in netbk_gop_skb.
>
>>
>>> The code here only
>>> increase count for the first time. I thought to initialize the count in
>>> xen_netbk_count_skb_slots with 1 to avoid this. But thinking of the
>>> extreme case when the header size is zero(not sure whether this case
>>> could be true), I increase the count here to keep safe in case header
>>> size is zero.
>>
>> netfront requires that the first slot always contains some data,
>> gop_frag_copy will BUG if that's not the case.
In gop_frag_copy, we can not go into the while if the size is 0. Which BUG_ON do you mean here?
Thanks
Annie
>>
>>>
>>> There is code correspond to that in gop_frag_copy in
>>> xen_netbk_count_skb_slots, see following,
>>>
>>> + if (skb_shinfo(skb)->gso_size && !vif->gso_prefix)
>>> + count++;
>>> (The original code does not have gso_prefix, I added it in this patch
>>> too based on Wei's suggestion)
>>
>> OK.
>>
>> It's be nice if the count and copy variants of this logic could be as
>> similar as possible but they already differ quite a bit. I have
>> considered whether we could combine the two by adding "dry-run"
>> functionality to gop_frag_copy but that seems like it would just ugly up
>> both versions.
>>
>> Ian.
>>
>>
>> _______________________________________________
>> Xen-devel mailing list
>> Xen-devel@lists.xen.org
>> http://lists.xen.org/xen-devel
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
[-- Attachment #1.2: Type: text/html, Size: 14909 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2013-07-11 10:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-10 9:15 [PATCH v2 1/1] xen/netback: correctly calculate required slots of skb Annie Li
2013-07-11 2:18 ` David Miller
2013-07-11 2:48 ` [Xen-devel] " annie li
2013-07-11 19:04 ` David Miller
2013-07-11 8:11 ` Ian Campbell
2013-07-11 8:34 ` annie li
2013-07-11 9:47 ` Ian Campbell
2013-07-11 10:46 ` Annie
2013-07-11 10:59 ` Annie [this message]
2013-07-11 11:12 ` [Xen-devel] " Ian Campbell
2013-07-11 13:35 ` annie li
2013-07-11 20:03 ` David Miller
2013-07-11 21:12 ` [Xen-devel] " Wei Liu
2013-07-16 9:00 ` Ian Campbell
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=3038108B-5529-452A-A488-4E616F7C1B8E@oracle.com \
--to=annie.li@oracle.com \
--cc=ian.campbell@citrix.com \
--cc=msw@amazon.com \
--cc=netdev@vger.kernel.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xensource.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).