mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Matt Mackall <mpm@selenic.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>,
	David Rientjes <rientjes@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	lkml - Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: maps2-add-proc-kpagemap-interface.patch
Date: Sun, 08 Jul 2007 21:46:02 +1000	[thread overview]
Message-ID: <1183895162.6005.338.camel@localhost.localdomain> (raw)

> + * Each entry is a pair of unsigned longs representing the
> + * corresponding physical page, the first containing the page flags
> + * and the second containing the page use count.
> + *
> + * The first 4 bytes of this file form a simple header:
> + *
> + * first byte:   0 for big endian, 1 for little
> + * second byte:  page shift (eg 12 for 4096 byte pages)
> + * third byte:   entry size in bytes (currently either 4 or 8)
> + * fourth byte:  header size

Hi Matt,

	This comment is worded badly: if the "entry is a pair" then "entry size
in bytes" would be 8 or 16.

> +	pfn = src / KPMSIZE - 1;
> +	count = min_t(size_t, count, ((max_pfn + 1) * KPMSIZE) - src);

Is min_t required here?  KPMSIZE is a sizeof() expression, so I'd expect
both sides to be type-compatible...

> +	page = (unsigned long *)__get_free_page(GFP_USER);
> +	if (!page)
> +		return -ENOMEM;

An explicit "struct kpagemap { unsigned long flags, count; };" would
simplify your iteration, clear up the code and get rid of the KPMSIZE &
KPMMASK macros.

But again I'd query the necessity of this cache page at all.

> +		if (copy_to_user(buf, page, chunk)) {
> +			ret = -EFAULT;
> +			break;
> +		}
> +		ret += chunk;
> +		src += chunk;
> +		buf += chunk;
> +		count -= chunk;
> +		cond_resched();

No cond_resched() needed here, either.

Cheers,
Rusty.


                 reply	other threads:[~2007-07-08 11:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1183895162.6005.338.camel@localhost.localdomain \
    --to=rusty@rustcorp.com.au \
    --cc=akpm@linux-foundation.org \
    --cc=jeremy@goop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpm@selenic.com \
    --cc=rientjes@google.com \
    /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®