public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@suse.de>
To: Joe Korty <joe.korty@ccur.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] bug in 2.4 bh_kmap_irq() breaks IDE under preempt patch
Date: Thu, 13 Mar 2003 10:26:01 +0100	[thread overview]
Message-ID: <20030313092601.GB827@suse.de> (raw)
In-Reply-To: <200303122213.WAA17415@rudolph.ccur.com>

On Wed, Mar 12 2003, Joe Korty wrote:
> Hi Alan, Everyone,
> The bh_map_irq/bh_unmap_irq functions are broken in 2.4.21-pre5.
> However no symptoms occur unless the preemption patch is applied.
> 
> The bug is that bh_map_irq *conditionally* calls kmap_atomic (which
> disables preemption as one of its functions), while bh_unmap_irq
> *unconditionally* calls kunmap_atomic (which enables it).  This
> imbalance results in a occasional off-by-one preempt_count, which in
> turn causes IDE PIO mode interrupt code (specifically, read_intr) to
> erronously invoke preempt_schedule while at interrupt level.
> 
> The below patch compiles and boots ide=nodma on my preempt 2.4 kernel
> on the one motherboard that had the problem.  Before this patch, the
> kernel would not even boot for that motherboard.  I also applied and
> test booted a pure 2.4.21-pre5 kernel with this patch.
> 
> The patch implements my preference for simplicity, so you may want to
> take some other approach if maximal performance is what you want.

I fixed this in 2.5 ages ago, just didn't get it in 2.4 block-highmem...
There's a tiny bit missing from your patch:

> --- include/linux/highmem.h.orig	2003-03-12 05:01:56.000000000 -0500
> +++ include/linux/highmem.h	2003-03-12 16:07:04.000000000 -0500
> @@ -33,22 +33,10 @@
>  {
>  	unsigned long addr;
>  
> -	__save_flags(*flags);
> -
> -	/*
> -	 * could be low
> -	 */
> -	if (!PageHighMem(bh->b_page))
> -		return bh->b_data;
> -
> -	/*
> -	 * it's a highmem page
> -	 */
> -	__cli();
> +	local_irq_save(*flags);
	local_irq_disable();

>  	addr = (unsigned long) kmap_atomic(bh->b_page, KM_BH_IRQ);
>  
> -	if (addr & ~PAGE_MASK)
> -		BUG();
> +	BUG_ON (addr & ~PAGE_MASK);
>  
>  	return (char *) addr + bh_offset(bh);
>  }
> @@ -58,7 +46,7 @@
>  	unsigned long ptr = (unsigned long) buffer & PAGE_MASK;
>  
>  	kunmap_atomic((void *) ptr, KM_BH_IRQ);
> -	__restore_flags(*flags);
> +	local_irq_restore(*flags);
>  }

other than that it's fine. See 2.5 for reference.

-- 
Jens Axboe


  parent reply	other threads:[~2003-03-13  9:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-12 22:13 [PATCH] bug in 2.4 bh_kmap_irq() breaks IDE under preempt patch Joe Korty
2003-03-12 23:27 ` Alan Cox
2003-03-13  9:26 ` Jens Axboe [this message]
2003-03-13 10:26   ` Marc-Christian Petersen
2003-03-13 10:28     ` Jens Axboe
2003-03-13 11:50       ` Marc-Christian Petersen
2003-03-13 14:59   ` Joe Korty
2003-03-13 15:05     ` Jens Axboe

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=20030313092601.GB827@suse.de \
    --to=axboe@suse.de \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=joe.korty@ccur.com \
    --cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox