Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7807080ybi; Thu, 6 Jun 2019 01:41:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKNIMsMWC5Xd59dEwh1L7F/4Oi360PcHObKm2IrEZJDqU84UeUpkCvj9/a8+0UzkVifblE X-Received: by 2002:a63:6e48:: with SMTP id j69mr2313495pgc.34.1559810505189; Thu, 06 Jun 2019 01:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559810505; cv=none; d=google.com; s=arc-20160816; b=UNgGqyC6nodFfMk5OzvF+zWs/Iq6scOz9it6NjXGuxZAk8yHigBwlYsuweDbBsy43H E+Z54/TUMxN3sKYTWfpc8D0eH8Jr6R+s4sGc/hvjp5CE7NarLhMylMj6uXekWMnxtFtt R268NncuzYi8ldi34lYc41RQTVtmgikealVxROaJRIuF/mLXQI1nK+kSPbJtuCawbZ7e HYhF1MSOOnLXVI62YMhySYhCvRgT83qpOKt0U4hChkc5kEDJMRidFngtPXpl4i2iCOOy pbLSZl4TWZhxDvt5aK0wpiQJJuS4OrjuVq40bVJp5yL2NFaNZEb5CzdkIXJtOin5JQt+ 8BFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=7W4AZwmqFUjZP9AmWoxftQySqTDv4cSCVrTgTUVf7H4=; b=tYLGuncxIPkxn/F3MJk+t8aiqXSEvF7DrsVSVx9MgCoR8eux3rgd22G2vZtMiJtS9G OKH2mwF1mXY6PBlVZk5RTbcmHnOFwrMD3go6x/PMRJc0xVTSdugRuefJEd5JAUMc64lm f+hADkUIam//Fk5XWZaxQStrPUUnVUyeo6WRhrU52xH2X6sg2iJml0NumKy0cViQwuIG Q+lTgYwdwGu3vQboONzQuMrV/rFAKMAExwlo1gwBttvFoigmRwpF2o90SVzuTC2N2vf7 dEUrOXPLYI6z0r5hN85mJccMyqq7mzFMaapveOwMTdlyOEIG1eGmziyGbxWBp6ecFZjE 61pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=cQos73Bv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k1si1251375pld.83.2019.06.06.01.41.28; Thu, 06 Jun 2019 01:41:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=cQos73Bv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727354AbfFFIjG (ORCPT + 99 others); Thu, 6 Jun 2019 04:39:06 -0400 Received: from mail-wm1-f48.google.com ([209.85.128.48]:55376 "EHLO mail-wm1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727158AbfFFIjF (ORCPT ); Thu, 6 Jun 2019 04:39:05 -0400 Received: by mail-wm1-f48.google.com with SMTP id a15so1170776wmj.5 for ; Thu, 06 Jun 2019 01:39:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=7W4AZwmqFUjZP9AmWoxftQySqTDv4cSCVrTgTUVf7H4=; b=cQos73BvgyiB1IQg1OSNrvkqRifL47HYGi5e4Nx6PhXHRgSZwW/eVPfwQyHtd3Dh0L KE1tKX8cfKJ/QRgGu3UABnZupi1wAtGK7aPYoTak22AKAOzDaoC5oCxU+HZV3eeZPWUt +X8DmH8DRgukz6TnG9GSm4rV6+ZYE2JC2Xml8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=7W4AZwmqFUjZP9AmWoxftQySqTDv4cSCVrTgTUVf7H4=; b=nkboVhpqTM4pJClYQIPf6rJ3Ie7YgXD8/Z7EZHTHNT2aILqn5cGyX+hyD5tOCtsVZy F2GoK1Dvus84+tVNDBUmWEV6N24gvru5XhlHU4nkl7udUO8Om0hrOBbioI0WgrvGiXYP +zFJjdNjmRspx/syZNtq6JPcx8wPYBGhemZ8ry9Sab25DS34WtGlXhAjPKrR9urRlaI9 EFUzmunOdr2iyALlsV6lRdEBAL6UOg79ISlNF6rz2RUDQzLB6l43D17pCrDXnohGp3cN ZG5dzMsUUC5lpz5TXw5jxcWhJo4eimegWZ9r2kD55d2o93lo6aAkNHe7J6aaI1XVwbpK 76UQ== X-Gm-Message-State: APjAAAVSHCfOEXRodFzr7aH9GMkPZbDjYR+EegOqr1ErLLg8kGG2UTuA 6dD/0XiCUzvqWM+pfeQxXfWlMw== X-Received: by 2002:a1c:3dc1:: with SMTP id k184mr26163386wma.88.1559810343349; Thu, 06 Jun 2019 01:39:03 -0700 (PDT) Received: from andrea (86.100.broadband17.iol.cz. [109.80.100.86]) by smtp.gmail.com with ESMTPSA id q21sm1076707wmq.13.2019.06.06.01.39.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Jun 2019 01:39:02 -0700 (PDT) Date: Thu, 6 Jun 2019 10:38:56 +0200 From: Andrea Parri To: Herbert Xu Cc: Linus Torvalds , "Paul E. McKenney" , Frederic Weisbecker , Boqun Feng , Fengguang Wu , LKP , LKML , Netdev , "David S. Miller" , Dmitry Vyukov , Alan Stern , Eric Dumazet Subject: Re: rcu_read_lock lost its compiler barrier Message-ID: <20190606083856.GA5337@andrea> References: <20150910005708.GA23369@wfg-t540p.sh.intel.com> <20150910102513.GA1677@fixme-laptop.cn.ibm.com> <20150910171649.GE4029@linux.vnet.ibm.com> <20150911021933.GA1521@fixme-laptop.cn.ibm.com> <20150921193045.GA13674@lerouge> <20150921204327.GH4029@linux.vnet.ibm.com> <20190602055607.bk5vgmwjvvt4wejd@gondor.apana.org.au> <20190603024640.2soysu4rpkwjuash@gondor.apana.org.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190603024640.2soysu4rpkwjuash@gondor.apana.org.au> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 03, 2019 at 10:46:40AM +0800, Herbert Xu wrote: > The case we were discussing is from net/ipv4/inet_fragment.c from > the net-next tree: BTW, thank you for keeping me and other people who intervened in that discussion in Cc:... Andrea > > void fqdir_exit(struct fqdir *fqdir) > { > ... > fqdir->dead = true; > > /* call_rcu is supposed to provide memory barrier semantics, > * separating the setting of fqdir->dead with the destruction > * work. This implicit barrier is paired with inet_frag_kill(). > */ > > INIT_RCU_WORK(&fqdir->destroy_rwork, fqdir_rwork_fn); > queue_rcu_work(system_wq, &fqdir->destroy_rwork); > } > > and > > void inet_frag_kill(struct inet_frag_queue *fq) > { > ... > rcu_read_lock(); > /* The RCU read lock provides a memory barrier > * guaranteeing that if fqdir->dead is false then > * the hash table destruction will not start until > * after we unlock. Paired with inet_frags_exit_net(). > */ > if (!fqdir->dead) { > rhashtable_remove_fast(&fqdir->rhashtable, &fq->node, > fqdir->f->rhash_params); > ... > } > ... > rcu_read_unlock(); > ... > } > > I simplified this to > > Initial values: > > a = 0 > b = 0 > > CPU1 CPU2 > ---- ---- > a = 1 rcu_read_lock > synchronize_rcu if (a == 0) > b = 2 b = 1 > rcu_read_unlock > > On exit we want this to be true: > b == 2