From: Anton Altaparmakov <aia21@cam.ac.uk>
To: Andrew Morton <akpm@osdl.org>
Cc: hirofumi@mail.parknet.co.jp, Linus Torvalds <torvalds@osdl.org>,
lkml <linux-kernel@vger.kernel.org>
Subject: write barriers - Was: Re: [RFC][PATCH] problem of cont_prepare_write()
Date: Thu, 13 Jan 2005 14:47:07 +0000 [thread overview]
Message-ID: <1105627627.22536.30.camel@imp.csi.cam.ac.uk> (raw)
In-Reply-To: <20041122154325.4d8e53ef.akpm@osdl.org>
Hi,
Sorry to pickup such a long thread but here goes anyway...
On Mon, 2004-11-22 at 15:43 -0800, Andrew Morton wrote:
> Anton Altaparmakov <aia21@cam.ac.uk> wrote:
> >
> > I always have a flush_dcache_page(page) between the memset() and
> > the SetPageUptodate() so I don't need the barrier, right? Or does the
> > flush_dcache_page() not imply ordering?
>
> err, flush_dcache_page() might indeed provide a write barrier on all
> architectures which need write barriers. Then again it might not ;) It's
> not intended that this be the case.
What about if the page is unmapped between the memset() and the
SetPageUptodate()? Does that imply ordering? I.e. do I need a write
barrier in code like this:
memset(page_address(page), 0, blah);
flush_dcache_page(page);
kunmap(page);
SetPageUptodate(page);
And a more general question:
If I am setting two variables in sequence and it is essential that if a
different cpu reads those variables it seems them updated in the same
order as they were written in the C code do I need a write barrier in
between the two? For example:
ntfs_inode->allocated_size = 10;
ntfs_inode->initilized_size = 10;
Should another CPU see initialized_size = 10 but allocated_size < 10 the
ntfs driver will blow up in some places. So does that mean I need a
write barrier, between the two?
If yes, do I still need it if I wrap the two settings (and all accesses)
with a spin lock? And in particular with a rw-spinlock? For example:
write_lock_irqsave(&ntfs_inode->size_lock, flags);
ntfs_inode->allocated_size = 10;
ntfs_inode->initilized_size = 10;
write_unlock_irqrestore(&ntfs_inode->size_lock, flags);
Do I still need a write barrier or does the spinlock imply it already?
Thanks a lot in advance and apologies for the stupid(?) questions...
Best regards,
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
next prev parent reply other threads:[~2005-01-13 14:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-22 10:30 [RFC][PATCH] problem of cont_prepare_write() OGAWA Hirofumi
2004-11-22 10:41 ` Andrew Morton
2004-11-22 10:46 ` Andrew Morton
2004-11-22 11:03 ` Anton Altaparmakov
2004-11-22 21:53 ` Andrew Morton
2004-11-22 23:30 ` Anton Altaparmakov
2004-11-22 23:43 ` Andrew Morton
2005-01-13 14:47 ` Anton Altaparmakov [this message]
2005-01-13 15:56 ` write barriers - Was: " Chris Friesen
2005-01-13 18:08 ` Florian Weimer
2004-11-22 11:38 ` OGAWA Hirofumi
2004-11-22 21:43 ` Andrew Morton
2004-11-23 2:22 ` OGAWA Hirofumi
2004-11-23 2:30 ` Andrew Morton
2004-11-23 2:55 ` OGAWA Hirofumi
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=1105627627.22536.30.camel@imp.csi.cam.ac.uk \
--to=aia21@cam.ac.uk \
--cc=akpm@osdl.org \
--cc=hirofumi@mail.parknet.co.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.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