Re: [PATCH 2.6.30-rc5] ehea: fix invalid pointer access

2009-05-05 Thread David Howells
Hannes Hering hannes.her...@linux.vnet.ibm.com wrote:

   pref = skb_array[x];
 - prefetchw(pref);
 - prefetchw(pref + EHEA_CACHE_LINE);
 + if (pref) {
 + prefetchw(pref);
 + prefetchw(pref + EHEA_CACHE_LINE);

Ummm...  Is prefetch() or prefetchw() faulting?

David
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 2.6.30-rc5] ehea: fix invalid pointer access

2009-05-05 Thread Hannes Hering
On Tuesday 05 May 2009 11:11:27 David Howells wrote:
 Hannes Hering hannes.her...@linux.vnet.ibm.com wrote:
 
  pref = skb_array[x];
  -   prefetchw(pref);
  -   prefetchw(pref + EHEA_CACHE_LINE);
  +   if (pref) {
  +   prefetchw(pref);
  +   prefetchw(pref + EHEA_CACHE_LINE);
 
 Ummm...  Is prefetch() or prefetchw() faulting?
 
 David
Hi David,

this is an ehea driver problem, which is occuring when the receive queue runs
empty. The faulting code is more specifically the following line:

pref = (skb_array[x]-data);

Here the access to the struct element data would cause an exception.We could
have made the if block a little smaller.

Regards

Hannes
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 2.6.30-rc5] ehea: fix invalid pointer access

2009-05-05 Thread Hannes Hering
On Tuesday 05 May 2009 14:19:54 David Howells wrote:
 In that case, you might want to move the prefetchw() calls in the following:
 
   pref = skb_array[x];
   -   prefetchw(pref);
   -   prefetchw(pref + EHEA_CACHE_LINE);
   +   if (pref) {
   +   prefetchw(pref);
   +   prefetchw(pref + EHEA_CACHE_LINE);
 
 to before the if-statement.  That way the CPU can be attempting the prefetch
 whilst it's chewing over the test and branch.  prefetching shouldn't fault on
 a bad address.
 
 David
Hi David,

you are right so far, but actually the prefetch calls on POWER also contain
an if statement to check if the address is valid (i. e. non-zero). We never
have the case that the pref != NULL and pref-data == NULL. And the situation
of pref==NULL is very rare. This means there is no benefit moving our if
statement down from performance perspective if we assume that our if does not
take longer then the if in the prefetch command. We can add an
if(likely(pref) if you like. In fact doing the if statement as we do it now
we actually save the prefetch if statements in case we hit the situation of
pref==NULL.

Regards

Hannes
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 2.6.30-rc5] ehea: fix invalid pointer access

2009-05-04 Thread David Miller
From: Hannes Hering hannes.her...@linux.vnet.ibm.com
Date: Mon, 4 May 2009 18:02:30 +0200

 This patch fixes an invalid pointer access in case the receive queue holds no
 pointer to the next skb when the queue is empty.
 
 Signed-off-by: Hannes Hering heri...@de.ibm.com
 Signed-off-by: Jan-Bernd Themann them...@de.ibm.com

Applied, thanks.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev