public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@suse.cz>
To: Andrew Morton <akpm@digeo.com>
Cc: torvalds@transmeta.com, linux-kernel@vger.kernel.org,
	trivial@rustcorp.com.au
Subject: Re: Provide example copy_in_user implementation
Date: Tue, 24 Jun 2003 12:33:08 +0200	[thread overview]
Message-ID: <20030624103308.GF159@elf.ucw.cz> (raw)
In-Reply-To: <20030624032904.13213eb8.akpm@digeo.com>

Hi!

> > +static inline unsigned long copy_in_user(void *dst, const void *src, unsigned size) 
> >  +{ 
> >  +	unsigned i, ret;
> >  +	unsigned char c;
> >  +	for (i=0; i<size; i++) {
> >  +		if (copy_from_user(&c, src+i, 1)) 
> >  +			return size-i;
> >  +		if (copy_to_user(dst+i, &c, 1))
> >  +			return size-i;
> >  +	}
> >  +	return 0;
> >  +}	
> >  +
> 
> I know that this is usually not performance critical, but by gawd that code
> is inefficient and bloaty.
> 
> It has 18 callsites; it can be put in lib/lib.a:copy_in_user.o.  The
> access_ok() checks only need to be run once.  It can copy a cacheline at a
> time.

It was meant to demonstrate calling convention of copy_in_user();
architectures probably want to modify their copy_from_user to be able
to copy into user, too; usually that can be done at 0 overhead.
								Pavel
-- 
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]

  reply	other threads:[~2003-06-24 10:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-24 10:06 Provide example copy_in_user implementation Pavel Machek
2003-06-24 10:18 ` Russell King
2003-06-24 10:25   ` Pavel Machek
2003-06-24 11:01     ` Russell King
2003-06-24 18:52     ` Linus Torvalds
2003-06-24 10:29 ` Andrew Morton
2003-06-24 10:33   ` Pavel Machek [this message]
2003-06-24 18:51 ` Linus Torvalds

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=20030624103308.GF159@elf.ucw.cz \
    --to=pavel@suse.cz \
    --cc=akpm@digeo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    --cc=trivial@rustcorp.com.au \
    /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