[bryan at staidm.org: [PATCH] ppc32 copy_to_user dcbt fixup]

linas at austin.ibm.com linas at austin.ibm.com
Wed Mar 17 03:54:59 EST 2004


So,

Does the problem described below affect the ppc64 cpu's?

--linas

----- Forwarded message from Bryan Rittmeyer <bryan at staidm.org> -----

Date: Fri, 12 Mar 2004 20:15:47 -0800
From: Bryan Rittmeyer <bryan at staidm.org>
To: linux-kernel at vger.kernel.org
Cc: linuxppc-dev list <linuxppc-dev at lists.linuxppc.org>,
        Paul Mackerras <paulus at samba.org>,
        Benjamin Herrenschmidt <benh at kernel.crashing.org>
Subject: [PATCH] ppc32 copy_to_user dcbt fixup
X-Loop: linuxppc-dev at lists.linuxppc.org

copy_tofrom_user and copy_page use dcbt to prefetch source data [1].
Since at least 2.4.17, these functions have been prefetching
beyond the end of the source buffer, leading to two problems:

1. Subtly broken software cache coherency. If the area following src
was invalidate_dcache_range'd prior to submitting for DMA,
an out-of-bounds dcbt from copy_to_user of a separate slab object
may read in the area before DMA completion. When the DMA does complete,
data will not be loaded from RAM because stale data is already in cache.
Thus you get a corrupt network packet, bogus audio capture, etc.

This problem probably does not affect hardware coherent systems
(all Apple machines?). However:

2. The extra 'dcbt' wastes bus bandwidth. Worst case: on a 128 byte copy,
we currently dcbt 256 bytes. These extra loads trash cache, potentially
causing writeback of more useful data.

The attached patch attempts to reign in dcbt prefetching at the end of
copies such that we do not read beyond the src area. This change fixes
DMA data corruption on software coherent systems and improves
performance slightly in my lame microbenchmark [2].

[1] csum_partial_copy_generic does not use dcbt/dcbz despite being
scorching hot in TCP workloads. I'm cooking up another patch to
dcb?ize it.

[2] http://staidm.org/linux/ppc/copy_dcbt/copyuser-microbench.tar.bz2

Comments?

-Bryan


----- End forwarded message -----

** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc64-dev mailing list