Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1890855imu; Thu, 10 Jan 2019 04:57:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN7bWo/wjWsUFIhkYoLtWcoGtiplVvBdYXwSvxrQkuLMSmuG+ZDQS4MQ5zbTFWZjVKum9pAp X-Received: by 2002:a17:902:33c1:: with SMTP id b59mr10122427plc.220.1547125060460; Thu, 10 Jan 2019 04:57:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547125060; cv=none; d=google.com; s=arc-20160816; b=cyc6imnUOTbL2F7SnlL0RdoWZ1fF1GnBknn6mGARlKJKx+pmR6DB/kOuuhFfcAIzTj CGU7ZFdB0/5U2wJPYKr8hT9a84a9dYnAOZ4dZ3flHMcVxDRbG0BM2SOVkJCSAm7yIKMW XA2dZDh7ffGYok9yy1cGcp23fJFpKpTMDOaQzwzAFOPk8A7aaMjMQdYYzLw2AFZzAS/l NE8WNYfQJAG5b0Cz/3kH8VkYnhZr08gm/ZCetp8Fp529/4v1TX8LmGAZRkRtzXla7Zk3 at1TBEXKl8qZPTdVRkwt9DSwZaP1CU6NaD8d6iMqE+IHykueKoK6XQVD8jtSb6orBcN+ nkVA== 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=2cdP6/5Fqkqmb0tNkcbxeH7uHn1xjS+3ysDd2FphhiY=; b=zzsHO6iFPss1FztAI9ipCCabHchq/QuWNA980U0pRQa3hsSKJxA/rrq6C3fPQWG0eH cctrX6/bqJMRYhCptjC5lvphfmMgXXNbdbobpDxkZc7WPsfSUhvX3TXv0KUYo8++uEWi tH6/k7DOySzZ7j0NkJe1R1IE796kzopts7sDDYhuYtsJQ0mHqqirC+R/xOdsXPNzNiBr X/85GTOKw73HXw9dBBQAm+T/8ZbMriW74HAqYxeEJAligs6ycuWh970pz3XLFZeQDOU7 8NmvVBuJAIUz4QKPuRT05n1B++qqVpY5uo+WyipbPeaEbPogJceiX6e4Cy7HCxVwJ6fy JAvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WykBnvyU; 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 d4si9361902pls.348.2019.01.10.04.57.24; Thu, 10 Jan 2019 04:57:40 -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=WykBnvyU; 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 S1728702AbfAJMyz (ORCPT + 99 others); Thu, 10 Jan 2019 07:54:55 -0500 Received: from mail-it1-f194.google.com ([209.85.166.194]:33178 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726974AbfAJMyy (ORCPT ); Thu, 10 Jan 2019 07:54:54 -0500 Received: by mail-it1-f194.google.com with SMTP id m8so15378245itk.0 for ; Thu, 10 Jan 2019 04:54:53 -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=2cdP6/5Fqkqmb0tNkcbxeH7uHn1xjS+3ysDd2FphhiY=; b=WykBnvyUpG+/YoQVXAUZNJ3UjQECtxlhiDVgDTLwoz6dP13hcKmlAgVOzN0VQCJZGQ IWyg4/bDtZ+cUuchzsvdV6LyEBlwE0fvVCZ0UoU+Y0qhlVFaGceAc6Da7oT0gNQBfrZa 3bjqOoKKE3/GZQoGI91BeGWHV7jDReiam4xcpEOy1HzhisMG2WhlitCStLiFF9jUTlmk veiPymm0Ne0CD3ussP7wB93D2N3RYv716bLOHg6acEutOohZpuaQBnJZ+FSuw0Lv06X/ FUziqYsxRosnHfchlkB1AuEZqXjJ/VMQ5Xkbox/4v9PmXicm33FStE4lkac+gwIEAJ/2 9SUw== 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=2cdP6/5Fqkqmb0tNkcbxeH7uHn1xjS+3ysDd2FphhiY=; b=XI0quOYkgMmgXF3DBpCys61ERumsxttJaIZSVa12wLjQqh02ugWc1oCouNJa/04RQ/ L11HJxhml2hqW4+dDOVmmi43RxbLFBBpIzCvje8Eus/eqe9fkR7B/TZWrlgmES2taJX6 JrbzrbMhj+9wAZAXifQ7cGPT8lJYahodjglEnpzbH+jYcpT4rE1MM877IxzG5TLpyuUY iXlboofKhgsJIrZB6Raiog/JMUlSsolyPtEalwYbE0wlGlihTWam0qP3ggYdTI1Tm1eQ 5wybDp2A/8/SHIASuPT9+PLKOIsX+Pcb6UYJnQFA5SSYvfLU2pYRPHWs8kClzmukO1uv cU8g== X-Gm-Message-State: AJcUukffctyrgPjzkT/3itj4TjXGg9RHWvtqI4Arc15aa/UUkQTdhz6I qrOMZPpAPdM4OxrP5XwD0VQ33muS6Ag9rs3FzUFhJw== X-Received: by 2002:a24:6511:: with SMTP id u17mr7094767itb.12.1547124892666; Thu, 10 Jan 2019 04:54:52 -0800 (PST) MIME-Version: 1.0 References: <20190110124427.GB21224@hirez.programming.kicks-ass.net> In-Reply-To: <20190110124427.GB21224@hirez.programming.kicks-ass.net> From: Dmitry Vyukov Date: Thu, 10 Jan 2019 13:54:41 +0100 Message-ID: Subject: Re: seqcount usage in xt_replace_table() To: Peter Zijlstra Cc: Anatol Pomozov , Florian Westphal , "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:44 PM Peter Zijlstra wrote: > > On Tue, Jan 08, 2019 at 11:33:39AM -0800, Anatol Pomozov wrote: > > Hello folks, > > > > A bit of context what I am doing. I am trying to port KTSAN (Kernel > > Thread Sanitizer) tool to v4.20. That tool tracks shared data usage > > and makes sure it is accessed in a thread-safe manner. > > > > seqlock is a synchronization primitive used by Linux kernel. KTSAN > > annotates read_seqbegin()/read_seqretry() and tracks what data been > > accessed in its critical section. > > > > During KTSAN port I found and interesting seqcount usage introduced in > > commit 80055dab5de0c8677bc148c4717ddfc753a9148e > > > > If I read this commit correctly xt_replace_table() does not use > > seqlock in a canonical way to specify a critical section. Instead the > > code reads the counter and waits until it gets to a specific value. > > (gets away from) > > > Now I want KTSAN to play with this code nicely. I need to tell KTSAN > > something like "this raw_read_seqcount() does not start a critical > > section, just ignore it". So temporary I introduced > > raw_read_seqcount_nocritical() function that is ignored by KTSAN. Is > > it a good solution? > > This code is special enough to just do: READ_ONCE(->sequence) and be > done with it. It doesn't need the smp_rmb() or anything else. Sounds good to me. From KTSAN perspective it then should work without any additional dance, it's always good when code works as-is.