mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Satyam Sharma" <satyam.sharma@gmail.com>
To: "Andrew Morton" <akpm@linux-foundation.org>
Cc: "Christoph Lameter" <clameter@sgi.com>,
	linux-kernel@vger.kernel.org,
	"Nate Diller" <nate.diller@gmail.com>,
	"Nick Piggin" <nickpiggin@yahoo.com.au>
Subject: Re: Pagecache zeroing: zero_user_segment, zero_user_segments and zero_user
Date: Wed, 16 May 2007 23:09:11 +0530	[thread overview]
Message-ID: <a781481a0705161039v56ae211di8b6e5b92d3dec93@mail.gmail.com> (raw)
In-Reply-To: <20070515202442.eeaa49a0.akpm@linux-foundation.org>

On 5/16/07, Andrew Morton <akpm@linux-foundation.org> wrote:
> >
> > 2. It has a useless parameter specifying the kmap slot.
> >    The functions above default to KM_USER0 which is also always used when
> >    zero_user_page was called except in one single case. We open code that
> >    single case to draw attention to the spot.
> >
>
> Dunno.  fwiw, we decided to _not_ embed KM_USER0 in the callee: we have had
> some pretty ghastly bugs in the past due to misuse of kmap slots so the
> idea was to shove the decision into the caller's face, make them think
> about what they're doing

Christoph hasn't really _replaced_ any !KM_USER0 case with
KM_USER0 in this patch. AFAIR, we had originally decided to not
embed KM_USER0 in zero_user_page because of this complaint
from Anton Altaparmakov:
http://lkml.org/lkml/2007/4/10/62

But Christoph's patch here seems to have left that fs/ntfs/aops.c case
alone, and used the zero_xxx helpers only for KM_USER0 cases, so
we should probably be safe.

> > +static inline void zero_user_segments(struct page *page,
> > +     unsigned start1, unsigned end1,
> > +     unsigned start2, unsigned end2)
> > +{
> > +     void *kaddr = kmap_atomic(page, KM_USER0);
> > +
> > +     BUG_ON(end1 > PAGE_SIZE ||
> > +             end2 > PAGE_SIZE);
> > +
> > +     if (end1 > start1)
> > +             memset(kaddr + start1, 0, end1 - start1);
> > +
> > +     if (end2 > start2)
> > +             memset(kaddr + start2, 0, end2 - start2);
> > +
> > +     flush_dcache_page(page);
> > +     kunmap_atomic(kaddr, KM_USER0);
> > +}
>
> For some reason we've always done the flush_dcache_page() while holding the
> kmap.  There's no reason for doing it this way and it just serves to worsen
> scheduling latency a tiny bit.

Wonder if any arch requires a valid mapping when doing the flush?

(reading Documentation/cachetlb.txt)

Documentation/cachetlb.txt is silent on whether flush_dcache_page()
really must be called before a kunmap(), but mentions that
flush_kernel_dcache_page() _must_ be called _before_ kunmap.
And I saw that parisc implements flush_dcache_page() using
flush_kernel_dcache_page itself (but then, we've not implemented a
meaningful kmap for parisc in the first place), so we've _just_
managed to be fine here ...

Still, flush_dcache_page() before kunmap'ing is an old practice,
would be wise to get this whetted by linux-arch first?

Satyam

      parent reply	other threads:[~2007-05-16 17:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-16  3:00 Christoph Lameter
2007-05-16  3:24 ` Andrew Morton
2007-05-16  4:05   ` Christoph Lameter
2007-05-16  4:52     ` Nick Piggin
2007-05-16  5:29       ` Andrew Morton
2007-05-16  5:51         ` Nick Piggin
2007-05-16  6:13           ` Christoph Lameter
2007-05-16  6:19             ` Nick Piggin
2007-05-16 17:39   ` Satyam Sharma [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=a781481a0705161039v56ae211di8b6e5b92d3dec93@mail.gmail.com \
    --to=satyam.sharma@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=clameter@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nate.diller@gmail.com \
    --cc=nickpiggin@yahoo.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

all inboxes | Powered by JetHome®