Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1888946imu; Thu, 10 Jan 2019 04:55:10 -0800 (PST) X-Google-Smtp-Source: ALg8bN5dHR5+envvJX2iak1EzAIVEh4maYnIBPASt9gIrGJE+zlspdx31trjTdGv9WkFv3viQpDO X-Received: by 2002:a63:d252:: with SMTP id t18mr9327433pgi.133.1547124910325; Thu, 10 Jan 2019 04:55:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547124910; cv=none; d=google.com; s=arc-20160816; b=dSrsVbq/c/NJFtPYsgXnRNlwCYVVUpF+LyvXVmR3uSx5/rkCiebnSM3pvR2r6DHM/R aK5o5vBbuXcX55fjk56zZBNVFJ+YIBLrtomGo2f2vDUjkzuV57k6r7G8xmN1+qyRsnea xeOzpgh4AXuWqVOp1Ft4isfy8cHI1CwEguo331l5bckB4Q0Zh0vzN8dyfjhsACyB/Gbx 1LIZjhAu4Vtf5NOlPRmLmtU3ISntvki6vbW8MBQO+FtvfvP/Xt6ExhEgZuCAjZLe3WKx NQMiFgRDxj6KkdY3fBaQR5EvA7/pR12DqM4DlLJVKW5aiSnLjOmMJl20hCk3b4gvphyN WkCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=6vbhcvdkLKlaMENn/NDZIlJAD2tULxVTuxTmq+ZrNMQ=; b=D8Dn/fmdVmjJm4mhceSm7xmZOE9iCmtaOj7DorWen51C6MxEnh/2R+LpBMdeTWIRju UtctQaEFo2JYlJP51T5g+Is3v9fXYVoOGA+/ABeQITRJumYKv++WDp2kC+y2vWhvRhKq jy0DRmiQbTsW1c70jtmXL+FQPletbwExhgICyGB6s+UkOi0n1rXLhEAherMx2sOBVAgt c8lrmxGGhQJmTfUKRUkokP95bkn6a/2h8lVdKxRVunY63rfuwYCEiFBGKEty49CyRmKe YgYmZKicweC1iM80D934zAuLcXR1TPdH/M8HpiwQBJDSlZjNzdVdSvMoe5rXNOPXi9Sq IxvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="XXTxM/Sj"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s59si56826011plb.350.2019.01.10.04.54.55; Thu, 10 Jan 2019 04:55:10 -0800 (PST) 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=@google.com header.s=20161025 header.b="XXTxM/Sj"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728515AbfAJMxk (ORCPT + 99 others); Thu, 10 Jan 2019 07:53:40 -0500 Received: from mail-it1-f172.google.com ([209.85.166.172]:39867 "EHLO mail-it1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726974AbfAJMxk (ORCPT ); Thu, 10 Jan 2019 07:53:40 -0500 Received: by mail-it1-f172.google.com with SMTP id a6so16047556itl.4 for ; Thu, 10 Jan 2019 04:53:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6vbhcvdkLKlaMENn/NDZIlJAD2tULxVTuxTmq+ZrNMQ=; b=XXTxM/SjWPZYPCoAMHByfK6CPiyx5WLqzAKbaINFxoV5nV1Cmcv8koEYdbGC1/AljH a6ZgDQu+w2uCIkZMrt8rkNoA1qTqJwx1FfCGnCD8Dhn792Mrool1kg8Shf3z2Pu2Op/d S+TPvQM/xav3m4uv+U6AyfUrAC3R7GaNa7wEDF6Hn9NUdqHkfPI5AmneONCKW+LMsClC W321NJmFYgN/kWYzaM+oKxowVUFUeBonNiLIMu5Ghs6ySI9eC2/m8N+eN6PmoqQ2JNGZ XWMm8iwlf509t4r4B+LSrf8xRPvFtYDBl+sj9LH23nF+DkBLlXqtul2trocChSCW+n60 qKrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6vbhcvdkLKlaMENn/NDZIlJAD2tULxVTuxTmq+ZrNMQ=; b=lH+5vUZF1Si5Ut3oLxTGU9QEgiQIFA5z2pcFh5PBb0CAwXqKQkdfJ6+VBdnUxI+cFD RW8bqY2VJz9F4tnXxyBlZu6Ub+D2OBaWxF0Ii5STXn8jVfcawsThRPjnc48IA4d6JcB5 z5Q0T+nKF4PEeMWAnT474uIn02JsrP7raUcpAcllzSiFrL0ESnnfyaRSX3S4xnUi1ING +EEJqBedC1ulUMP2NHKRcIYhD+kgtalkQnAsb5ao8RZOE0maAQFvNtmwGklx+LB0vD9C mm1Quy7K5whbOCwG+nI0L78IV+0AH4N5JXGRRclil0+Ll6GUIG+HN+UphXNUcxrya2zV L+FA== X-Gm-Message-State: AJcUukfdjD92CBnSZTpacxVez4LK2nVqGkFY8IND79wzIywGcflPcJFE 75fIUoz6VcmDFoNHlsE7yd3Xc+roiK0C2m607etdBQ== X-Received: by 2002:a02:ac8c:: with SMTP id x12mr6388633jan.72.1547124818948; Thu, 10 Jan 2019 04:53:38 -0800 (PST) MIME-Version: 1.0 References: <20190108223746.shuwx3ro7cgwz7hh@breakpoint.cc> <20190110124123.GA21224@hirez.programming.kicks-ass.net> In-Reply-To: <20190110124123.GA21224@hirez.programming.kicks-ass.net> From: Dmitry Vyukov Date: Thu, 10 Jan 2019 13:53:28 +0100 Message-ID: Subject: Re: seqcount usage in xt_replace_table() To: Peter Zijlstra Cc: Florian Westphal , Anatol Pomozov , "Paul E. McKenney" , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 10, 2019 at 1:41 PM Peter Zijlstra wrote: > > On Tue, Jan 08, 2019 at 11:37:46PM +0100, Florian Westphal wrote: > > Anatol Pomozov wrote: > > > Or maybe xt_replace_table() can be enhanced? When I hear that > > > something waits until an event happens on all CPUs I think about > > > wait_event() function. Would it be better for xt_replace_table() to > > > introduce an atomic counter that is decremented by CPUs, and the main > > > CPU waits until the counter gets zero? > > > > That would mean placing an additional atomic op into the > > iptables evaluation path (ipt_do_table and friends). > > > > For: > > /* > * Ensure contents of newinfo are visible before assigning to > * private. > */ > smp_wmb(); > table->private = newinfo; > > we have: > > smp_store_release(&table->private, newinfo); > > But what store does that second smp_wmb() order against? The comment: > > /* make sure all cpus see new ->private value */ > smp_wmb(); > > makes no sense what so ever, no smp_*() barrier can provide such > guarantees. Do we want WRITE_ONCE here then? We want it to be compiled to an actual memory access and then it's up to hardware to make it visible to other CPUs. smp_wmb should most likely have this as a side effect too, but somewhat indirect. Also race-detector-friendly. > > Only alternative I see that might work is synchronize_rcu (the > > _do_table functions are called with rcu read lock held). > > > > I guess current scheme is cheaper though. > > Is performance a concern in this path? There is no comment justifying > this 'creative' stuff. >