From: Andrew Morton <akpm@osdl.org>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-fbdev-devel@lists.sourceforge.net, davem@redhat.com
Subject: Re: [PATCH][FBDEV] Fix copy_to/from_user in fbmem.c:fb_read/write
Date: Mon, 30 Aug 2004 02:15:44 -0700 [thread overview]
Message-ID: <20040830021544.2ca107f5.akpm@osdl.org> (raw)
In-Reply-To: <Pine.GSO.4.58.0408301107430.3353@waterleaf.sonytel.be>
Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> > +
> > + cnt = 0;
> > + buffer = kmalloc((count > 64 * 1024) ? 64 * 1024 : count,
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > + GFP_KERNEL);
> > + if (!buffer)
> > + return -ENOMEM;
>
> Woops, what's the probability of a 64 kiB kmalloc() to fail?
Relatively high.
> [...]
>
> > + while (count) {
> > + c = (count > 64 * 1024) ? 64 * 1024 : count;
> > + dst = buffer;
> > + for (i = c >> 2; i--; )
> > + *dst++ = fb_readl(src++);
> > + if (c & 3) {
> > + for (i = c & 3; i--;)
> > + *((u8 *)dst++) = fb_readb((u8 *) src++);
> > + }
> > +
> > + if (copy_to_user(buf, buffer, c)) {
> > + err = -EFAULT;
> > + break;
> > + }
> > + *ppos += c;
> > + buf += c;
> > + cnt += c;
> > + count -= c;
> > }
>
> I don't expect the penalty for always using a buffer of PAGE_SIZE to be very
> large. Or am I missing something?
The 64k copy buffer will most likely be slower than using an 8k one. it
depends, of course, upon the vintage of the CPU.
4k or 8k should be fine here.
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
next prev parent reply other threads:[~2004-08-30 9:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-30 2:47 [PATCH][FBDEV] Fix copy_to/from_user in fbmem.c:fb_read/write Antonino A. Daplas
2004-08-30 3:16 ` David S. Miller
2004-08-30 9:10 ` Geert Uytterhoeven
2004-08-30 9:15 ` Andrew Morton [this message]
2004-08-30 11:58 ` Antonino A. Daplas
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=20040830021544.2ca107f5.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=davem@redhat.com \
--cc=geert@linux-m68k.org \
--cc=linux-fbdev-devel@lists.sourceforge.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;
as well as URLs for NNTP newsgroup(s).