Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1882317imu; Thu, 10 Jan 2019 04:46:52 -0800 (PST) X-Google-Smtp-Source: ALg8bN5br8OflSQNnXSq5m14jWwmQ1qBjvIWAqaxO+/I3W+V5FldrmFJxDqFJvoEvmL3avM4dS8P X-Received: by 2002:a63:9a52:: with SMTP id e18mr9222342pgo.14.1547124412039; Thu, 10 Jan 2019 04:46:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547124412; cv=none; d=google.com; s=arc-20160816; b=oVXrDzmRB7SBWUoZTF5B0rHb7JUKXZwQdvatyN/iQLjNYnRSBkKBTKHGJoCx06er1o D5AM+U3RtVD7Mf2sYsEAGfh1mzuhGys/rabbzX10PxCptm5tcW5eCWemGUfPPZtMEdQG VZB2oco8xKFdXvn+dbpuUZ2FlijH6D0FcbvVVIGTBwAoyBFSbuaZ1EOZPFjQjYWqAW1M gNhlMn9zkJf+cO2SrAu63bnITvXLCm1q/PGwlr9ea68eu+kf+LECW2OTKdkbea9wIy7p GC4afBZQOeY/JI02zBCKbvBgePtAjh4dPBsViPs0YjmgyHO6/nBK4IMGjZ3C8cpTa9nr ELyA== 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=1PRahedlOsql+wuU2s4Rc98OxLxk+oXeq1xkgxPu4TY=; b=T0SHTSlx/GJH/rQFGSaPm1YG1GyeLOclNJ/uy5Cd9E3/nkGDgYeFGm9h2NODBd4q48 W3lILB2mUHQDgdMp984EYMB3Z8JFBBECYu/Km2wvw/ygYEO2x3HsS7QwHbV+NSE8cJQV QEfzPxdybCKPr3wAD1pVIaxpGSXNleKG147HketGmFfXeoGnClo71qWMTQx/jHVDaAp3 R2EepqDo+zIH+moeSZu1O5WOzYS1lrIT+DclXbqai6EOU6UspCo9r88d1udJNWivYPh1 3Zwe7J/6klehmAx7ZZnomvQP34nDeoj+SU2bov+P4xPoKma6NqPyjjrQVifQaframvER SNiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=hg+VzPBO; 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 f21si47507454pgb.371.2019.01.10.04.46.36; Thu, 10 Jan 2019 04:46:51 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=hg+VzPBO; 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 S1728282AbfAJMod (ORCPT + 99 others); Thu, 10 Jan 2019 07:44:33 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:60484 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727391AbfAJMoc (ORCPT ); Thu, 10 Jan 2019 07:44:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=1PRahedlOsql+wuU2s4Rc98OxLxk+oXeq1xkgxPu4TY=; b=hg+VzPBOqiYmCiXjPoaO7i1HD vbL9U7P4Vt11ytLuDi91S8jOW5RRvTTEC0f+kpmjhAKL1MLworl0VycLaZrK2Vj5PY5k+S+mp9zns u8QNsx/fzmVSCRgTgzXj+Ia/3y8k0trVkxNFkjyAn/u7w5Wf+GwmJKgMTXQA1Gf4Ky5wUalCz9xHt 2ti3x3SLwX+cwLHAkosiTGQyt88MqazNrk25uFLK/ztdCPZtA2mBjQq0tXKZL0UHTe2KFKYt3hI6f l7HbleAW/wBl07GsEX7wotoWP3XaIv5VcpkTEe8ywTvUueP+vLXVFuMrjBzMUXVZNcnsP7iEAUCf9 Src/hUz5A==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1ghZhE-0003B4-UQ; Thu, 10 Jan 2019 12:44:29 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 6C2942081518D; Thu, 10 Jan 2019 13:44:27 +0100 (CET) Date: Thu, 10 Jan 2019 13:44:27 +0100 From: Peter Zijlstra To: Anatol Pomozov Cc: fw@strlen.de, Dmitry Vyukov , paulmck@linux.ibm.com, LKML Subject: Re: seqcount usage in xt_replace_table() Message-ID: <20190110124427.GB21224@hirez.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.