From: David Miller <davem@davemloft.net>
To: kys@microsoft.com
Cc: olaf@aepfle.de, netdev@vger.kernel.org, jasowang@redhat.com,
linux-kernel@vger.kernel.org, apw@canonical.com,
devel@linuxdriverproject.org
Subject: Re: [PATCH V2 1/6] Drivers: net: hyperv: Enable scatter gather I/O
Date: Sat, 08 Mar 2014 01:36:58 -0500 (EST) [thread overview]
Message-ID: <20140308.013658.918013334851017662.davem@davemloft.net> (raw)
In-Reply-To: <fd6bb08bd9a447aa9c0da3b584ea9bb8@BY2PR03MB299.namprd03.prod.outlook.com>
From: KY Srinivasan <kys@microsoft.com>
Date: Sat, 8 Mar 2014 04:12:01 +0000
>
>
>> -----Original Message-----
>> From: David Miller [mailto:davem@davemloft.net]
>> Sent: Saturday, March 8, 2014 3:18 AM
>> To: KY Srinivasan
>> Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org;
>> devel@linuxdriverproject.org; olaf@aepfle.de; apw@canonical.com;
>> jasowang@redhat.com
>> Subject: Re: [PATCH V2 1/6] Drivers: net: hyperv: Enable scatter gather I/O
>>
>> From: "K. Y. Srinivasan" <kys@microsoft.com>
>> Date: Thu, 6 Mar 2014 21:32:36 -0800
>>
>> > +static u32 fill_pg_buf(struct page *page, u32 offset, u32 len,
>> > + struct hv_page_buffer *pb)
>> > +{
>> > + int j = 0;
>> > +
>> > + /* Deal with compund pages by ignoring unused part
>> > + * of the page.
>> > + */
>> > + page += offset >> PAGE_SHIFT;
>>
>> Please only one space between "offset" and ">>"
>>
>> > + offset &= ~PAGE_MASK;
>> > +
>> > + while (len > 0) {
>> > + unsigned long bytes;
>> > +
>> > + bytes = PAGE_SIZE - offset;
>> > + if (bytes > len)
>> > + bytes = len;
>> > + pb[j].pfn = page_to_pfn(page);
>> > + pb[j].offset = offset;
>> > + pb[j].len = bytes;
>> > +
>> > + offset += bytes;
>> > + len -= bytes;
>> > +
>> > + if (offset == PAGE_SIZE && len) {
>> > + page++;
>> > + offset = 0;
>> > + j++;
>> > + }
>> > + }
>> > +
>> > + return j + 1;
>> > +}
>>
>> I think this function has some edge case errors.
>>
>> As I understand it, this function returns how many page buffer entries were
>> filled in.
>>
>> But if we fill exactly the end of a page, we will report one too many in the
>> return value.
>
> I may be missing something here; but in the case you are describing we would return a value
> of one as we should. When offset + len is exactly equal to the page size, we would not increment
> the value of j, since at that point len == 0. Since the initial value of j was 0 and we return (j + 1),
> we will return 1.
That's not what happens, you execute the loop code at least once, and
hit:
>> > + if (offset == PAGE_SIZE && len) {
>> > + page++;
>> > + offset = 0;
>> > + j++;
>> > + }
thus incrementing j before the return statement.
next prev parent reply other threads:[~2014-03-08 6:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-07 5:32 [PATCH V2 0/6] Drivers: net: hyperv: Enable various offloads K. Y. Srinivasan
2014-03-07 5:32 ` [PATCH V2 1/6] Drivers: net: hyperv: Enable scatter gather I/O K. Y. Srinivasan
2014-03-07 5:32 ` [PATCH V2 2/6] Drivers: net: hyperv: Cleanup the send path K. Y. Srinivasan
2014-03-07 5:32 ` [PATCH V3 3/6] Drivers: net: hyperv: Enable offloads on the host K. Y. Srinivasan
2014-03-07 5:32 ` [PATCH V2 4/6] Drivers: net: hyperv: Enable receive side IP checksum offload K. Y. Srinivasan
2014-03-07 5:32 ` [PATCH V2 5/6] Drivers: net: hyperv: Enable send side " K. Y. Srinivasan
2014-03-07 5:32 ` [PATCH V2 6/6] Drivers: net: hyperv: Enable large send offload K. Y. Srinivasan
2014-03-07 21:47 ` [PATCH V2 1/6] Drivers: net: hyperv: Enable scatter gather I/O David Miller
2014-03-08 4:12 ` KY Srinivasan
2014-03-08 6:36 ` David Miller [this message]
2014-03-08 10:27 ` KY Srinivasan
2014-03-08 23:38 ` David Miller
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=20140308.013658.918013334851017662.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=apw@canonical.com \
--cc=devel@linuxdriverproject.org \
--cc=jasowang@redhat.com \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olaf@aepfle.de \
/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).