Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp3025534ybx; Fri, 8 Nov 2019 12:54:56 -0800 (PST) X-Google-Smtp-Source: APXvYqyNmj7nr0gmRTQcse1R9FFdvqQvhnsSWLrvVbZJge+/nKl1nIETRNd0qwN6NKYKNSSf5uaD X-Received: by 2002:aa7:c987:: with SMTP id c7mr12623735edt.232.1573246496657; Fri, 08 Nov 2019 12:54:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573246496; cv=none; d=google.com; s=arc-20160816; b=TKAZf9vyGK755pPf8UOLB1RPg/QqOZmLD5dm4f6UzUfsyA4XuDfgdEVgFq5N1DJsD7 de9hCINC1NQmOL4yya2i/Vz5tjP2GbAm3lXzL3Ykguaci+kejRjiLnLv2OgXNkNXmX2f 3R1wEgycnAMeI0flTvRB9uugmbiKp1VwZsPiI2ik+HA2KiIaF0+u5dMcaJTFf4YlycfP 555o84pwUAy04ne/vSmff9pipMF5ifKHhUmGG0iz8kgNRLxbjKQ2dsAb/zkY8tyUA62T 6PIVOLj+ACgUXIP4l/fpYqEPARgCy3i0jgXvzObkXBEMFVFds1Cxl6fntQ+0yaK4YFy9 l60A== 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=QP8RInZYsAMDu5pw7upwHybwYLWcynuRUEkP7xjdKws=; b=MPSEZnrozljsRAh21sqlUHVnltBMsUSAyntcEK3WAiBjt2i9GeHJ/C3Fx76zB7qHHW 2kRz3sy2wlcpr3yoDfuUbW2O3UIxmUiUc7Q+EbLH0ZVaNVmunW52t2p5ctOuFcfAvrCc sHPW+mlvuBg8tYYdljgUYUB9sZbUvsxPhm2nORcSyD7k1OIaB//V+yDm6O2UR5H3Cbll bRiNgjum62GjqhV9u0+pMN7H7zEzp1lo1jYpkjZl1dGBZM5ggMx7Vd1IxNT31qinW5DA 7mmk9ov3AzAWEFahcW4mZ5OBQG/EKEH9zmpSR2RfHwdLLj73L2sKt0o1RtdAYadndcBG i/2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=FKgTzWNM; 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 i24si4508169ejh.35.2019.11.08.12.54.33; Fri, 08 Nov 2019 12:54:56 -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=FKgTzWNM; 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 S1731181AbfKHUxv (ORCPT + 99 others); Fri, 8 Nov 2019 15:53:51 -0500 Received: from mail-il1-f170.google.com ([209.85.166.170]:33853 "EHLO mail-il1-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729981AbfKHUxv (ORCPT ); Fri, 8 Nov 2019 15:53:51 -0500 Received: by mail-il1-f170.google.com with SMTP id p6so6332006ilp.1 for ; Fri, 08 Nov 2019 12:53:50 -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=QP8RInZYsAMDu5pw7upwHybwYLWcynuRUEkP7xjdKws=; b=FKgTzWNMRiBtDkjkYNoecIIq2/5xMPTsKzTfSUHRLoXdSQeZjsbrb+bCzCw54yxeCa UQGOG7dVkvMFq53zok/QccRk66ER+fC9Jb+26+b4Rlo0z33KHqslXGCpQ8s03bxYj7f4 VyCUcnPchJ5vXtDoc5f0A1KAsuWjJbB/1Hg5Kv+F5EAzB7imF0Scub6gy8yKWa2MUVr6 7+ndgVnLXqrN5uNqWMHjfoclVzdQwqph547OY5ljE06BgSv0iL3ZeCT8zmKwPKXo1vYX Fn/0ZT2yq06dHLRCKV/znbyYhkR9S+lOSEuJXcugyI2L/5pcye8EsinqZ5k5luD6/7Ti tNaQ== 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=QP8RInZYsAMDu5pw7upwHybwYLWcynuRUEkP7xjdKws=; b=fuq3sQEoRiHFrEz6sE/D+RhJ5E6N/oL2xtSK4psyt9e7xg768gHkTZESdvsuhR+edR zv/4hUf4vB/mg6yvSDhDLzU8SOpZ0EMHhpOp8WwkRr+iOsJeCeavR6i887Yu2dtVLaqV INgbWv4Mbe9JQrMYM5eR1ehdTwb3kgYSpst225gK2uMf4cOo3P0IBxh88qJ55lp7rW1K hMeDudUFVgwMURES9LWe5zzXmbosH6/aDrkdBgz646wth/dqdabpnsSDyNAkj3MaKuOa a5/M6cDyk/JeQ22yb8xwkqmvb3d+MN4FFQAJqUIJUsGOz61rtuJr1IsP/rAaEvwtTzKp TOjQ== X-Gm-Message-State: APjAAAXpZoxvKfjAB5Z3/RTvFkvVvsEFPuCebRNOmdDmIrZE35IBvWTo 93F7WUpxi9QjFiLyHIhOrK7pMjHGJI5WGDu5PnFNoA== X-Received: by 2002:a92:99cb:: with SMTP id t72mr13199933ilk.218.1573246429652; Fri, 08 Nov 2019 12:53:49 -0800 (PST) MIME-Version: 1.0 References: <000000000000c422a80596d595ee@google.com> <6bddae34-93df-6820-0390-ac18dcbf0927@gmail.com> In-Reply-To: From: Eric Dumazet Date: Fri, 8 Nov 2019 12:53:38 -0800 Message-ID: Subject: Re: KCSAN: data-race in __alloc_file / __alloc_file To: Linus Torvalds Cc: Eric Dumazet , syzbot , Marco Elver , linux-fsdevel , Linux Kernel Mailing List , syzkaller-bugs , Al Viro 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 Fri, Nov 8, 2019 at 12:30 PM Linus Torvalds wrote: > > On Fri, Nov 8, 2019 at 9:56 AM Eric Dumazet wrote: > > > > BTW, I would love an efficient ADD_ONCE(variable, value) > > > > Using WRITE_ONCE(variable, variable + value) is not good, since it can > > not use the optimized instructions operating directly on memory. > > So I'm having a hard time seeing how this could possibly ever be valid. > > Is this a "writer is locked, readers are unlocked" case or something? per cpu SNMP counters mostly, with no IRQ safety requirements. Note that this could be implemented using local{64}_add() on arches like x86_64, while others might have to fallback to WRITE_ONCE(variable, variable + add) > > Because we don't really have any sane way to do that any more > efficiently, unless we'd have to add new architecture-specific > functions for it (like we do have fo the percpu ops). > > Anyway, if you have a really hot case you care about, maybe you could > convince the gcc people to just add it as a peephole optimization? > Right now, gcc ends up doing some strange things with volatiles, and > basically disables a lot of stuff over them. But with a test-case, > maybe you can convince somebody that certain optimizations are still > fine. A "read+add+write" really does the exact same accesses as an > add-to-memory instruction, but gcc has some logic to disable that > instruction fusion. > > Linus