Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752872AbaKVAcc (ORCPT ); Fri, 21 Nov 2014 19:32:32 -0500 Received: from mail.anarazel.de ([217.115.131.40]:37902 "EHLO mail.anarazel.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752314AbaKVAcb (ORCPT ); Fri, 21 Nov 2014 19:32:31 -0500 X-Greylist: delayed 457 seconds by postgrey-1.27 at vger.kernel.org; Fri, 21 Nov 2014 19:32:30 EST Date: Sat, 22 Nov 2014 01:24:45 +0100 From: Andres Freund To: Pranith Kumar Cc: Eric Dumazet , Pablo Neira Ayuso , Patrick McHardy , Jozsef Kadlecsik , "David S. Miller" , Alexey Kuznetsov , James Morris , Hideaki YOSHIFUJI , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, "open list:NETWORKING [IPv4/..." , open list Subject: Re: [PATCH v2 9/9] netfilter: Replace smp_read_barrier_depends() with lockless_dereference() Message-ID: <20141122002445.GA4704@alap3.anarazel.de> References: <1416582363-20661-1-git-send-email-bobby.prani@gmail.com> <1416582363-20661-10-git-send-email-bobby.prani@gmail.com> <1416586364.8629.104.camel@edumazet-glaptop2.roam.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 2014-11-21 16:57:00 -0500, Pranith Kumar wrote: > On Fri, Nov 21, 2014 at 11:12 AM, Eric Dumazet wrote: > > On Fri, 2014-11-21 at 10:06 -0500, Pranith Kumar wrote: > >> Recently lockless_dereference() was added which can be used in place of > >> hard-coding smp_read_barrier_depends(). The following PATCH makes the change. > >> > >> Signed-off-by: Pranith Kumar > >> --- > >> net/ipv4/netfilter/arp_tables.c | 3 +-- > >> net/ipv4/netfilter/ip_tables.c | 3 +-- > >> net/ipv6/netfilter/ip6_tables.c | 3 +-- > >> 3 files changed, 3 insertions(+), 6 deletions(-) > >> > >> diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c > >> index f95b6f9..fc7533d 100644 > >> --- a/net/ipv4/netfilter/arp_tables.c > >> +++ b/net/ipv4/netfilter/arp_tables.c > >> @@ -270,12 +270,11 @@ unsigned int arpt_do_table(struct sk_buff *skb, > >> > >> local_bh_disable(); > >> addend = xt_write_recseq_begin(); > >> - private = table->private; > >> /* > >> * Ensure we load private-> members after we've fetched the base > >> * pointer. > >> */ > >> - smp_read_barrier_depends(); > >> + private = lockless_dereference(table->private); > >> table_base = private->entries[smp_processor_id()]; > >> > > > > > > Please carefully read the code, before and after your change, then > > you'll see this change broke the code. > > > > Problem is that a bug like that can be really hard to diagnose and fix > > later, so really you have to be very careful doing these mechanical > > changes. > > > > IMO, current code+comment is better than with this > > lockless_dereference() which in this particular case obfuscates the > > code. more than anything. > > > > In this case we do have a lock (sort of), so lockless_dereference() is > > quite misleading. > > > > Hi Eric, > > Thanks for looking at this patch. > > I've been scratching my head since morning trying to find out what was > so obviously wrong with this patch. Alas, I don't see what you do. Afaics the read_barrier_depends protected the load from private->entries[x] earlier, not the load of table->private itself. Greetings, Andres Freund -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/