mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: KY Srinivasan <kys@microsoft.com>
To: David Miller <davem@davemloft.net>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"devel@linuxdriverproject.org" <devel@linuxdriverproject.org>,
	"olaf@aepfle.de" <olaf@aepfle.de>,
	"apw@canonical.com" <apw@canonical.com>,
	"jasowang@redhat.com" <jasowang@redhat.com>
Subject: RE: [PATCH V2 1/6] Drivers: net: hyperv: Enable scatter gather I/O
Date: Sat, 8 Mar 2014 04:12:01 +0000	[thread overview]
Message-ID: <fd6bb08bd9a447aa9c0da3b584ea9bb8@BY2PR03MB299.namprd03.prod.outlook.com> (raw)
In-Reply-To: <20140307.164756.1488071770631289333.davem@davemloft.net>



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

Regards,

K. Y
> 
> Consider an "offset" of X, where X is smaller than PAGE_SIZE.  And a "len"
> which is exactly "PAGE_SIZE - offset".
> 
> We will fill in exactly one page buffer entry, however we will erroneously
> return 2 from this function.
> 
> I believe the fix is to first replace the test at the end of the loop
> with:
> 
> 	page++;
> 	offset = 0;
> 	j++;
> 
> And subsequently change the function to just return plain "j".

  reply	other threads:[~2014-03-08  4:12 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 [this message]
2014-03-08  6:36       ` David Miller
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=fd6bb08bd9a447aa9c0da3b584ea9bb8@BY2PR03MB299.namprd03.prod.outlook.com \
    --to=kys@microsoft.com \
    --cc=apw@canonical.com \
    --cc=davem@davemloft.net \
    --cc=devel@linuxdriverproject.org \
    --cc=jasowang@redhat.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

all inboxes | Powered by JetHome®