mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Andrew Morton <akpm@osdl.org>
Cc: alan@lxorguk.ukuu.org.uk, linux-kernel@vger.kernel.org,
	Doug Thompson <dthompson@lnxi.com>
Subject: Re: PATCH: EDAC - clean up atomic stuff
Date: Tue, 01 Nov 2005 05:03:57 -0700	[thread overview]
Message-ID: <m18xw88thu.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <20051031120254.4579dc9a.akpm@osdl.org> (Andrew Morton's message of "Mon, 31 Oct 2005 12:02:54 -0800")

Andrew Morton <akpm@osdl.org> writes:

> ebiederm@xmission.com (Eric W. Biederman) wrote:
>>
>> Ok.  If I recall correctly atomic kmaps have the rule that they are
>>  per cpu, and you can't be interrupted when the map is taken, by
>>  something else that will use the map.  But they are safe to use from
>>  interrupt context.  As I recall the code needs to ensure that an
>>  interrupt handler doesn't use the same buffer and that it isn't
>>  preempted where another thread will use the buffer.  The preemption
>>  angle is new since that piece of code was written.
>
> Yes, a particular atomic kmap slot is simply a static, per-cpu scalar. 
> It's just like
>
> int foo[NR_CPUS];
>
> 	...
> 	foo(smp_processor_id());
>
> and all the same rules apply.
>
> The use of KM_BOUNCE_READ does appear to be incorrect.  bounce_copy_vec()
> will use KM_BOUNCE_READ from interrupt context, so if the EDAC code is
> interrupted by the block layer while it holds that kmap, it will find that
> it's suddenly diddling with a different physical page.
>
> So to use KM_BOUNCE_READ, the EDAC code nees to disable local interrupts,
> or to use a different (or new) slot.
>
> In what contexts is edac_mc_scrub_block() called?  If process context, then
> KM_USER0 would suit.

That function is very nice functionality but we could not implement it
properly outside of the kernel.  So the code has been disabled until
just recently. 

Hmm.  Looking at the patch it is most definitely being called from
process context.  Although I think the original was ok from interrupt
context as well.

> Ah, edac_mc_scrub_block() is passing the pageframe address to
> kunmap_atomic() - that's a common bug.  It needs to pass in the virtual
> address which kmap_atomic() returned.

Oops.  Although I am actually surprised kunmap_atomic even needs the address.
Although I can see the kmap type being equally redundant.

There is a much more serious bug there as well.  The code as it
exists is flatly impossible on x86_64 and some other architectures
as they do not support kmap.  It is also broken on x86 as grain can
easily be larger than page size, on old memory controllers where this
is most needed it is the frequently the size of a memory chip select
(aka the size of a single sided DIMM).

We need to do two things.
- Remove a factor from edac_mc_scrub_block (call it edac_mc_scrub_page)
  that simply scrubs a page or maybe a sub page.
- Place the edac_mc_scrub_page which does the kmap and a loop through
  the page contents in arch specific code.

Eric

  reply	other threads:[~2005-11-01 12:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-21 13:40 Alan Cox
2005-10-28 16:33 ` Eric W. Biederman
2005-10-31 15:30   ` Alan Cox
2005-10-31 16:34     ` Eric W. Biederman
2005-10-31 20:02       ` Andrew Morton
2005-11-01 12:03         ` Eric W. Biederman [this message]
2005-11-01 12:46           ` Alan Cox
2005-11-01 12:38             ` Eric W. Biederman
2005-11-02  5:26           ` Andrew Morton
2005-11-02 16:02             ` Alan Cox

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=m18xw88thu.fsf@ebiederm.dsl.xmission.com \
    --to=ebiederm@xmission.com \
    --cc=akpm@osdl.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=dthompson@lnxi.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

Powered by JetHome