From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: afzal mohammed <afzal.mohd.ma@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>, Nicolas Pitre <nico@fluxnic.net>,
Catalin Marinas <catalin.marinas@arm.com>,
Linus Walleij <linus.walleij@linaro.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Linux-MM <linux-mm@kvack.org>, Will Deacon <will@kernel.org>,
Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [RFC 1/3] lib: copy_{from,to}_user using gup & kmap_atomic()
Date: Sat, 13 Jun 2020 14:15:52 +0100 [thread overview]
Message-ID: <20200613131552.GL1551@shell.armlinux.org.uk> (raw)
In-Reply-To: <20200613120432.GA5319@afzalpc>
On Sat, Jun 13, 2020 at 05:34:32PM +0530, afzal mohammed wrote:
> Hi,
>
> On Fri, Jun 12, 2020 at 10:07:28PM +0200, Arnd Bergmann wrote:
>
> > I think a lot
> > of usercopy calls are only for a few bytes, though this is of course
> > highly workload dependent and you might only care about the large
> > ones.
>
> Observation is that max. pages reaching copy_{from,to}_user() is 2,
> observed maximum of n (number of bytes) being 1 page size. i think C
> library cuts any size read, write to page size (if it exceeds) &
> invokes the system call. Max. pages reaching 2, happens when 'n'
> crosses page boundary, this has been observed w/ small size request
> as well w/ ones of exact page size (but not page aligned).
You can't make that assumption about read(2). stdio in the C library
may read a page size of data at a time, but programs are allowed to
call read(2) directly, and the C library will pass such a call straight
through to the kernel. So, if userspace requests a 16k read via
read(2), then read(2) will be invoked covering 16k.
As an extreme case, for example:
$ strace -e read dd if=/dev/zero of=/dev/null bs=1048576 count=1
read(0, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576) = 1048576
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: afzal mohammed <afzal.mohd.ma@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>, Nicolas Pitre <nico@fluxnic.net>,
Catalin Marinas <catalin.marinas@arm.com>,
Linus Walleij <linus.walleij@linaro.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Linux-MM <linux-mm@kvack.org>, Will Deacon <will@kernel.org>,
Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [RFC 1/3] lib: copy_{from,to}_user using gup & kmap_atomic()
Date: Sat, 13 Jun 2020 14:15:52 +0100 [thread overview]
Message-ID: <20200613131552.GL1551@shell.armlinux.org.uk> (raw)
In-Reply-To: <20200613120432.GA5319@afzalpc>
On Sat, Jun 13, 2020 at 05:34:32PM +0530, afzal mohammed wrote:
> Hi,
>
> On Fri, Jun 12, 2020 at 10:07:28PM +0200, Arnd Bergmann wrote:
>
> > I think a lot
> > of usercopy calls are only for a few bytes, though this is of course
> > highly workload dependent and you might only care about the large
> > ones.
>
> Observation is that max. pages reaching copy_{from,to}_user() is 2,
> observed maximum of n (number of bytes) being 1 page size. i think C
> library cuts any size read, write to page size (if it exceeds) &
> invokes the system call. Max. pages reaching 2, happens when 'n'
> crosses page boundary, this has been observed w/ small size request
> as well w/ ones of exact page size (but not page aligned).
You can't make that assumption about read(2). stdio in the C library
may read a page size of data at a time, but programs are allowed to
call read(2) directly, and the C library will pass such a call straight
through to the kernel. So, if userspace requests a 16k read via
read(2), then read(2) will be invoked covering 16k.
As an extreme case, for example:
$ strace -e read dd if=/dev/zero of=/dev/null bs=1048576 count=1
read(0, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1048576) = 1048576
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2020-06-13 13:18 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-12 10:17 [RFC 0/3] ARM: copy_{from,to}_user() for vmsplit 4g/4g afzal mohammed
2020-06-12 10:17 ` afzal mohammed
2020-06-12 10:17 ` [RFC 1/3] lib: copy_{from,to}_user using gup & kmap_atomic() afzal mohammed
2020-06-12 10:35 ` [RFC PATCH " afzal mohammed
2020-06-12 12:02 ` [RFC " Arnd Bergmann
2020-06-12 12:02 ` Arnd Bergmann
2020-06-12 13:55 ` afzal mohammed
2020-06-12 13:55 ` afzal mohammed
2020-06-12 20:07 ` Arnd Bergmann
2020-06-12 20:07 ` Arnd Bergmann
2020-06-13 12:04 ` afzal mohammed
2020-06-13 12:04 ` afzal mohammed
2020-06-13 12:51 ` Al Viro
2020-06-13 12:51 ` Al Viro
2020-06-13 12:56 ` Al Viro
2020-06-13 12:56 ` Al Viro
2020-06-13 13:42 ` afzal mohammed
2020-06-13 13:42 ` afzal mohammed
2020-06-13 15:31 ` Al Viro
2020-06-13 15:31 ` Al Viro
2020-06-13 15:41 ` Al Viro
2020-06-13 15:41 ` Al Viro
2020-06-13 16:00 ` Al Viro
2020-06-13 16:00 ` Al Viro
2020-06-13 18:55 ` Arnd Bergmann
2020-06-13 18:55 ` Arnd Bergmann
2020-06-15 11:22 ` David Laight
2020-06-15 11:22 ` David Laight
2020-06-13 13:15 ` Russell King - ARM Linux admin [this message]
2020-06-13 13:15 ` Russell King - ARM Linux admin
2020-06-14 13:06 ` afzal mohammed
2020-06-14 13:06 ` afzal mohammed
2020-06-13 20:45 ` Arnd Bergmann
2020-06-13 20:45 ` Arnd Bergmann
2020-06-13 22:16 ` Matthew Wilcox
2020-06-13 22:16 ` Matthew Wilcox
2020-06-14 13:21 ` afzal mohammed
2020-06-14 13:21 ` afzal mohammed
2020-06-14 14:55 ` afzal mohammed
2020-06-14 14:55 ` afzal mohammed
2020-06-13 11:08 ` Andy Shevchenko
2020-06-13 11:08 ` Andy Shevchenko
2020-06-13 13:29 ` afzal mohammed
2020-06-13 13:29 ` afzal mohammed
2020-06-12 10:18 ` [RFC 2/3] ARM: uaccess: let UACCESS_GUP_KMAP_MEMCPY enabling afzal mohammed
2020-06-12 10:40 ` [RFC PATCH " afzal mohammed
2020-06-12 10:18 ` [RFC 3/3] ARM: provide CONFIG_VMSPLIT_4G_DEV for development afzal mohammed
2020-06-12 10:38 ` [RFC PATCH " afzal mohammed
2020-06-12 15:19 ` [RFC 0/3] ARM: copy_{from,to}_user() for vmsplit 4g/4g Nicolas Pitre
2020-06-12 15:19 ` Nicolas Pitre
2020-06-12 16:01 ` afzal mohammed
2020-06-12 16:01 ` afzal mohammed
2020-06-12 16:03 ` afzal mohammed
2020-06-12 16:03 ` afzal mohammed
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=20200613131552.GL1551@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=afzal.mohd.ma@gmail.com \
--cc=arnd@arndb.de \
--cc=catalin.marinas@arm.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nico@fluxnic.net \
--cc=will@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.