lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 21 Nov 2009 09:54:29 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Ilya Loginov <isloginov@...il.com>
Cc:	David Woodhouse <dwmw2@...radead.org>,
	linux-kernel@...r.kernel.org, Peter Horton <phorton@...box.co.uk>,
	"Ed L. Cashin" <ecashin@...aid.com>,
	Jens Axboe <jens.axboe@...cle.com>
Subject: Re: [PATCH] mtd: fix mtd_blkdevs problem with caches on some
 architectures (2.6.31)

On Sat, 21 Nov 2009 17:04:37 +0300 Ilya Loginov <isloginov@...il.com> wrote:

> On Fri, 20 Nov 2009 16:37:51 -0800
> Andrew Morton <akpm@...ux-foundation.org> wrote:
> 
> > Your patch fixes bascially the same problem in MTD as we have in AOE. 
> > And it introduces the same problem as well - pointless empty
> > cache-thrashing loops on architectures for which flush_dcache_page() is
> > a no-op.
> > 
> > What would be better here would be for block core to add a new
> > rq_flush_dcache_pages() and bio_flush_dcache_pages() which the drivers
> > can call.  Those functions would be a no-op on architectures which
> > don't need them.
> 
> Do you mean something like this?
> 
> in include/linux/bio.h
> 
> #ifdef SOMETHING_LIKE_CONFIG_CPU_HAS_DCACHE_ALIAS
> extern void bio_flush_dcache_pages(struct bio *bi);
> #else
> static inline void bio_flush_dcache_pages(struct bio *bi)
> {
> }
> #endif /* SOMETHING_LIKE_CONFIG_CPU_HAS_DCACHE_ALIAS */
> 
> in fs/bio.c
> 
> void bio_flush_dcache_pages(struct bio *bi)
> {
> 	int i;
> 	struct bio_vec* bvec;
> 
> 	rq_for_each_segment(bvec, bio, i)
> 		flush_dcache_page(bvec->bv_page);
> }
> 
> in include/linux/blkdev.h
> 
> #ifdef SOMETHING_LIKE_CONFIG_CPU_HAS_DCACHE_ALIAS
> extern void rq_flush_dcache_pages(struct request *rq);
> #else
> static inline void rq_flush_dcache_pages(struct request *rq)
> {
> }
> #endif
> 
> in block/blk-core.c
> 
> void rq_flush_dcache_pages(struct request *rq)
> {
> 	struct req_iterator iter;
> 	struct bio_vec* bvec;
> 
> 	rq_for_each_segment(bvec, bio, iter)
> 		flush_dcache_page(bvec->bv_page);
> }
> 
> And SOMETHING_LIKE_CONFIG_CPU_HAS_DCACHE_ALIAS should be defined
> in Kconfigs for each architecture that requires this fix.

yep, that would work.

The one somewhat fragile thing is that we'll end up in a situation
where an architecture could implement a real flush_dcache_page(), but
would forget to set SOMETHING_LIKE_CONFIG_CPU_HAS_DCACHE_ALIAS.  Or
vice versa.  To make things reliable it would be good to cause a
compilation failure in that case.

One way of addressing this is to

- change every arch/*/include/asm/cacheflush.h to include asm-generic/cacheflush.h

- put #ifndef SOMETHING_LIKE_CONFIG_CPU_HAS_DCACHE_ALIAS wrappers around all content
  in asm-generic/cacheflush

So it the above mistake happens, we'll get lots of duplicated
definitions, or no definitions at all (I think).

> I think 
> this is good solution and if you think the same I can create the
> patch.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ