Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1594670ybp; Fri, 4 Oct 2019 18:07:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqw85Jo2HpaGFPrf+m07VqtxJKHt2fvGjCZIPXf+swJp2xQI0V0rg8xi4odxB1n3Fi7dvhMZ X-Received: by 2002:a17:906:4e57:: with SMTP id g23mr1393310ejw.264.1570237631459; Fri, 04 Oct 2019 18:07:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570237631; cv=none; d=google.com; s=arc-20160816; b=iGkz/6FpOIT6ZT2/BuMF2bwElMqZhBClwNdeTVRvzaAn5NJokl7wlnEjR3zp32bLNP K+l0xqmtTFdyGi4LS9D+LEJkNAF7QQyHroHzgYNUqmeec0YKFoY2ooQJhMDECUbgF3pu pVN0Q5zcqwtqCpZRGS9SCeeb8NWqZQh+qIlYQlYgryQAcTJExGEUvdEFicmoqHTl5l3K i73kkGAqkT7esuU/5UfGhuAEIs1NQXHdVbgaq9Aws9XZAGSVrMhfejFg2wHkLrS1Bmj9 MChuKKUERZO0315yfzeCjzmBBkv72uZdW/0Ulupm0plpNr1Fycbi3djbJpFmAJfrZLtD HP6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=3GjI3HdpMykSY2+YmUKXAGRqWylFQzs02bDymLtXFRo=; b=nrOJrCPXdCX0KTIrOwI7ROC6GdTQLRYjg7iiwCqu6Ib/MrghdDmN4ZrZdWpzb5mpS+ hpmDj1lLR+Mem7xfoR6/NVumOcucJqhtR0RRxPYBS+DcwKOClyGFQLXVi2KgRPsAT5zn jxfdMdFwXjNmBC7bA6n+ipS2Dv5knb/JoouuqHIKajHG9//mdD+LxKkYRhafZaf53VSy 2DvyGFur3y16skWBKD1nFNoUJWYUDS35/AEqt70QuNXpBATQCx2PZMFGHW3e5FkPpdXE mWoeuW8Le6BFz8rgR3jtSZOAgKE59yCp9L3GQ5Nx2Dpy1VJRNHjWvSEmC9pUs1grsaaT PIOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S4Xe3j5U; 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 f21si4498615edb.379.2019.10.04.18.06.32; Fri, 04 Oct 2019 18:07:11 -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=@gmail.com header.s=20161025 header.b=S4Xe3j5U; 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 S1726289AbfJEA6i (ORCPT + 99 others); Fri, 4 Oct 2019 20:58:38 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37421 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725907AbfJEA6i (ORCPT ); Fri, 4 Oct 2019 20:58:38 -0400 Received: by mail-pg1-f193.google.com with SMTP id p1so2909282pgi.4 for ; Fri, 04 Oct 2019 17:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=3GjI3HdpMykSY2+YmUKXAGRqWylFQzs02bDymLtXFRo=; b=S4Xe3j5UFzuZy9Ry51hOVq8fxBmCZxkot3xa/TgwrqWxHYI4R01/XBxuyHV7jvMYTt d6ESb1Y8co6iV0yjNCMTiiG85glaKlitSt6v75329fHF28dw1lGK05f8q+jnEG1qgPch QSncUntBp4TPzJTPH/UovGjbxelGdWzz4wpbRRx+cavWzUPmwa9DsQ9f03u4njae4BG4 nc1dgg7Qtl1SqXWLS5gY6OXrJ2qLOXdwuiioSnCg11zP5u2efG2BqCgiDmHycPrwYFEB A9KNXIhBVU1f+RF85lT+Bpjno1bMyB5Z/rmYe8mbQybiVcbEulL9z1xSAu8SRnJ9KIG5 sMUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=3GjI3HdpMykSY2+YmUKXAGRqWylFQzs02bDymLtXFRo=; b=Q2l51eB6MLp0zXxxFBvXjqtBWdgPR2sShCAnXofgEOw1qrc9hbiHrCHOJAbshPhWbC r05V38kYnPlSlfsthPEtjMqmKn9CuodZaFD9jpDxbqtnmR/PMnr4QEeNWLVuawyvRbCX ONaQGrz2smM7f1PvnqOcWZfq0hhqCZ9rGKgaHOX8GdF40nbawTY4xXqwxtioWueZr6Kr q9uTXX0KYaWOMBHauUTswW7oNUvGRTqphVJIH8cDuTlbTbpaG3SuhxnvnNEC8vn9+sVe 3PGMENOOFoYg5UgZsorLRjbIAcO0IS5DMReHm2oKlfa5LOrUdN0cXlOLU2T4Qo11jl+8 I59A== X-Gm-Message-State: APjAAAUq6znS0ekfjhZo3zcc8nSBvPM8tEtphj/sTJqAWF3zwX4FrNSM 57bMjlb8v8AFzph16iS5dy4= X-Received: by 2002:a63:682:: with SMTP id 124mr18045104pgg.102.1570237117746; Fri, 04 Oct 2019 17:58:37 -0700 (PDT) Received: from [192.168.86.235] (c-73-241-150-70.hsd1.ca.comcast.net. [73.241.150.70]) by smtp.gmail.com with ESMTPSA id t11sm5611290pjy.10.2019.10.04.17.58.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Oct 2019 17:58:36 -0700 (PDT) Subject: Re: Kernel Concurrency Sanitizer (KCSAN) To: Will Deacon , Marco Elver Cc: kasan-dev , LKML , Dmitry Vyukov , Andrey Konovalov , Alexander Potapenko , paulmck@linux.ibm.com, Paul Turner , Daniel Axtens , Anatol Pomazau , Andrea Parri , stern@rowland.harvard.edu, akiyks@gmail.com, npiggin@gmail.com, boqun.feng@gmail.com, dlustig@nvidia.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr References: <20190920155420.rxiflqdrpzinncpy@willie-the-truck> From: Eric Dumazet Message-ID: <0715d98b-12e9-fd81-31d1-67bcb752b0a1@gmail.com> Date: Fri, 4 Oct 2019 17:58:33 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190920155420.rxiflqdrpzinncpy@willie-the-truck> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/20/19 8:54 AM, Will Deacon wrote: > > This one is tricky. What I think we need to avoid is an onslaught of > patches adding READ_ONCE/WRITE_ONCE without a concrete analysis of the > code being modified. My worry is that Joe Developer is eager to get their > first patch into the kernel, so runs this tool and starts spamming > maintainers with these things to the point that they start ignoring KCSAN > reports altogether because of the time they take up. > > I suppose one thing we could do is to require each new READ_ONCE/WRITE_ONCE > to have a comment describing the racy access, a bit like we do for memory > barriers. Another possibility would be to use atomic_t more widely if > there is genuine concurrency involved. > About READ_ONCE() and WRITE_ONCE(), we will probably need ADD_ONCE(var, value) for arches that can implement the RMW in a single instruction. WRITE_ONCE(var, var + value) does not look pretty, and increases register pressure. I had a look at first KCSAN reports, and I can tell that tcp_poll() being lockless means we need to add hundreds of READ_ONCE(), WRITE_ONCE() and ADD_ONCE() all over the places. -> Absolute nightmare for future backports to stable branches.