Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5113098imu; Tue, 8 Jan 2019 11:45:06 -0800 (PST) X-Google-Smtp-Source: ALg8bN58QLisf2cufTZXO/IoviaF+HvJDtUq0o8OjvBsLnkElT24oIYM1L6ToAgelERxS3OyXRBI X-Received: by 2002:a62:5dd1:: with SMTP id n78mr2989009pfj.58.1546976706012; Tue, 08 Jan 2019 11:45:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546976705; cv=none; d=google.com; s=arc-20160816; b=OdPE/MzhVabwI1cvIap+U7MkXFL7F7+9SLAr+UFT5uQhaWwpKli+9gHlYEAGyxW8lg O8P34vIh58Bi4YjmlbrRmaTn9SJEk7J5qdzRuMEnvMSTqORk3+6lAGTuqzMxAUtFrZ3J MGjyHD1inRmuO8KsR447nq0facUTeNZZZTLFaE7g+46VF5ja4K2Uv3HyQdt8U+uN72nI ywqlbr50gBM9hyhP8FdPWrFec8bvQmrRZ6YAXI/9WpxiNRG27pDCPmNsmBqV8C8rpL37 NQb5H9L4TiUrocBTKco/rImN/kEMzW6+L3E9eJoaq16thCD+NqGh1G6DPSM/R3PIL0az 07+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :mime-version:dkim-signature; bh=hHgjSR+cFz9cVJF2AiQcA/E5dfRyPx4pM1LbWcyflfs=; b=JltsFrRchZgwLLvB4xxCshxJrmELwiTthLswaLTjAiCAJP9LxDrECD93HyVOuhb4OD 9FtZaaGM2CwCbc5JAdL2iavVoEPDwNJoycx/3fj0IUN8FMUBb5Pai0isAV9rPmOaD7fX +SbBxta/nxjp7a9U5VG0nO9MgCag+O6YzrC1AvgmWLI39+6tSqv4k5opGAd28qfupB8r ccQ0VtkUw8BvgA4wlQHUFGFduTYanhNlt+ij0N4kDllpTMu8MN/CGyCtFjKMHRk0lGfC QQZY4ZaYIaYjPJresEsgBMHmNrRvxHoXNpuesd51N2zcRUGgH2BYDuP4Hd8BoVS27e8g yN8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gDfKWdW0; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l36si29232631plb.433.2019.01.08.11.44.51; Tue, 08 Jan 2019 11:45:05 -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=@gmail.com header.s=20161025 header.b=gDfKWdW0; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732414AbfAHTnA (ORCPT + 99 others); Tue, 8 Jan 2019 14:43:00 -0500 Received: from mail-ua1-f53.google.com ([209.85.222.53]:36609 "EHLO mail-ua1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731824AbfAHTdx (ORCPT ); Tue, 8 Jan 2019 14:33:53 -0500 Received: by mail-ua1-f53.google.com with SMTP id j3so1659982uap.3 for ; Tue, 08 Jan 2019 11:33:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=hHgjSR+cFz9cVJF2AiQcA/E5dfRyPx4pM1LbWcyflfs=; b=gDfKWdW0lqlrLLLrqdDzCMLtCb8AjYetd4Vk23ASrEWs1qKuABGK1/mK33z7x9vFPb 22OWP4HWo+s/avWZLHY7L5vBntK1MB6SA3an9PvDSzNykH+LlRkB80kx5meN/ISKUZJE SnWFmp+tjECaE8XtZFTA+2WKKVcsmdbnMWVXSzIV1G3bEYGzoa4eGW0MPoTAXJliOQaS 64RAwtPViHTdmkiCtBclRzE3LHlcMCPKgDn/LPuQcU4l1PFtA4p1LCXORuWMhl8xULKe W700pRZ+Q0eCebFojIsBxG1IeuZ1aRC0WhgGVk7dI+iiegG0sS/AtT2NUCLZUvM63mqU JHZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=hHgjSR+cFz9cVJF2AiQcA/E5dfRyPx4pM1LbWcyflfs=; b=oIL777NvVN9nt6X+V35gctEzHeU6OHZ8XBGttI69adtd+cMgTN78QRFnILoU5EGP5/ JPUkiEggk9s8mI9WpsBV28xOm5RFMH+1VVK5ZGojg3Z/m0QS8AKTGagUn+lElHyQ7oub LAafuCcGVKBKxMBZmHL00bppFjBbSrN6ZpB4K0Z9QUXo0YH6utWYWN3xL9hpfKFcqln+ 15YLPdX5Ta2PqA21YXFF59s57jVtoigM7lf2KOY/QGfDGzsF6T+CK2Ww8vqrj7xxHY3S RQj6njxIIzvHriAfBraF/KGC5K3TkIB+QtuiEtB8+eQzmNSabGqrBompI36UrWkygadc +mmg== X-Gm-Message-State: AJcUukfd6vHAqH31FAg6sw50A/1uEU4setK+Uxx3b8+tBvfmG0bUAlBO lJDJpjZ5cXLhZ2V6Xmj0CtIfPL3Sg6DUnp+QHJk= X-Received: by 2002:ab0:9d4:: with SMTP id e20mr1068521uah.22.1546976031529; Tue, 08 Jan 2019 11:33:51 -0800 (PST) MIME-Version: 1.0 From: Anatol Pomozov Date: Tue, 8 Jan 2019 11:33:39 -0800 Message-ID: Subject: seqcount usage in xt_replace_table() To: fw@strlen.de, Dmitry Vyukov , paulmck@linux.ibm.com, 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 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. 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? 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? WDYT?