mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hugh Dickins <hugh@veritas.com>
To: Akinobu Mita <mita@miraclelinux.com>
Cc: linux-kernel@vger.kernel.org, akpm@osdl.org
Subject: Re: [PATCH] fix swap cluster offset
Date: Mon, 13 Mar 2006 16:52:53 +0000 (GMT)	[thread overview]
Message-ID: <Pine.LNX.4.61.0603131632300.9207@goblin.wat.veritas.com> (raw)
In-Reply-To: <20060312043450.GA7088@miraclelinux.com>

On Sun, 12 Mar 2006, Akinobu Mita wrote:

> When we've allocated SWAPFILE_CLUSTER pages, ->cluster_next should
> be the first index of swap cluster. But current code probably sets it
> wrong offset.
> 
> Signed-off-by: Akinobu Mita <mita@miraclelinux.com>

Acked-by: Hugh Dickins <hugh@veritas.com>

Very good eye!  My shame.
No need to say "probably" above, it was simply wrong.

By a stroke of luck, it's no worse than a slight inefficiency in an
algorithm only used when we're already going slow; but (if offset had
been signed, or not checked against highest_bit for unrelated reasons)
it could very easily have tried to access and modify swap_map[-1].

Anyway, thanks for catching that:
Andrew, please apply (but not desperate for 2.6.16).

Hugh

> Index: work/mm/swapfile.c
> ===================================================================
> --- work.orig/mm/swapfile.c
> +++ work/mm/swapfile.c
> @@ -116,7 +116,7 @@ static inline unsigned long scan_swap_ma
>  				last_in_cluster = offset + SWAPFILE_CLUSTER;
>  			else if (offset == last_in_cluster) {
>  				spin_lock(&swap_lock);
> -				si->cluster_next = offset-SWAPFILE_CLUSTER-1;
> +				si->cluster_next = offset-SWAPFILE_CLUSTER+1;
>  				goto cluster;
>  			}
>  			if (unlikely(--latency_ration < 0)) {

      reply	other threads:[~2006-03-13 16:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-12  4:34 Akinobu Mita
2006-03-13 16:52 ` Hugh Dickins [this message]

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=Pine.LNX.4.61.0603131632300.9207@goblin.wat.veritas.com \
    --to=hugh@veritas.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mita@miraclelinux.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®