Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp860590iob; Fri, 13 May 2022 14:44:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoaqzcdMRsPm0DrcXdqxmmCRWH4i3Lq3N8iKpokPdzpoAbbnLfJSFOa3LLfAjj6B/plMpI X-Received: by 2002:a17:907:70c4:b0:6f3:d23f:d711 with SMTP id yk4-20020a17090770c400b006f3d23fd711mr5870690ejb.205.1652478268555; Fri, 13 May 2022 14:44:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652478268; cv=none; d=google.com; s=arc-20160816; b=gGMOVzn98ji7Cd2O+oGxVmJtSB1uvG8tKI+QvJNiCgApCllJn1qFcOLGHiTSWu5Nap AwuXOpwJeDcO8zap3A7J+fpvVVrbViM0v3pqbe5yFR4iIqkb3dwsA2kmgfaH32I1xUEa jC28aAi+XtX86ErIyQjGOcJSmtFdtTOqOnUCaDL2sH+rlq0JIa4Eh8AFVXhBBgHcGo9k khHqRYPcjiIp1QcjtdQl5ggw8kcIL9tV5KJcNOO9xCVDwRij/lTQVb0U9cWDCYSJaTti SkoDJfwKb4BBFNjOWMqc1+sGTHXSVO4vqeRXgrn/IYQjiXuU23sGIAIG/3oWRWf61bNd 4MWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=N+MpLUlaVpHkuuiUc6lyGjVUiffHSHmuxB6NPv5ECyw=; b=eTTcKVBT77DpiC4lIjLIiQCsLGgaBMxHNGHI59w+ml8R9h7QjASL4YqJiR6g3HZxcd tHicMqoOLqKbJlxpGyRchZy/x+Arj59DapK0vh6uUVlZtXR5I6qflIgY9R8koWdKmxS5 GrQJ2OR7XO4oveoCpy3WoFWKRVUPCRHwUkTqBaaZykO52GAL648rmzXdTwvDgL5MmPYc /HcwP6Tj4yR6GJ6Sv0BfuR6B2Svsn+TZd2DVRlDbaCNkkqp1+XpwdaLimZktXs+NKkzY x2cQ9QudJ6q6vRnPEgOc1pE5MsrpvjOp2LVI0LtJNkOJbjdBCv1rT8IL/kdrIFayKkqx 02vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=AAjsICel; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc10-20020a170907168a00b006f3ffc76930si3094703ejc.1007.2022.05.13.14.44.00; Fri, 13 May 2022 14:44:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=AAjsICel; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1359571AbiELXnf (ORCPT + 99 others); Thu, 12 May 2022 19:43:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240139AbiELXnd (ORCPT ); Thu, 12 May 2022 19:43:33 -0400 Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF50C1C0F34 for ; Thu, 12 May 2022 16:43:32 -0700 (PDT) Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-2f863469afbso74648427b3.0 for ; Thu, 12 May 2022 16:43:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=N+MpLUlaVpHkuuiUc6lyGjVUiffHSHmuxB6NPv5ECyw=; b=AAjsICelOCN6C8Ie6MZZxEzH/C5JKJPXQlS1LQ0jKkjgg3Vsvl15ahTuEBNuLn5Nxn ab+wWatKgnTKxYqqaLYGrGrctF/hKc0adsJZAp4kjARYCbmYbw52gDKXhnMYegj+9lEO SPIAZLywPhby5tO6eE4dB+RfIR4saw7mHbqqaw522A4RGuwiQONsZI2ZmGBGpO/SO6PN rX9ShC6U6MokvWDOU1VQsPhAkrLnuRnqFiYrMOA0PKjD5HjqFzG5yKoG+KrIVQyg403e jojpBJ331bmvL2k9vLvJ2Nlyod9tic6Y7xKDnY6mDqi9JTGjeT3M79ZI4UKkDHl0mvO0 Pdlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=N+MpLUlaVpHkuuiUc6lyGjVUiffHSHmuxB6NPv5ECyw=; b=tT5EnfyNN7n2mr3aGabNGxwRHdW1PYHN8CWlpL5IDuKdIpCYibLOy+syj7UPzUs8cy 6BIMgN3S89d+5I1qZA8A5sTjDhMekJoL3nbtX94f3/zaMra990Qlc/2zgYX4gT/n7fim pVoX8KvaaBTkIKpeATDm3HQ0DwZ9gwRezMm1m0C9+hoJchb3fw+5Uu2BMNQXEd2mSt2y 0bbWJoOryzjPo4Nua9asPZ16AkrypW1YWMPLUWWGyoI0OhZPXsTqFF7dg8plTFk608uQ I9inpQT7f/Y+78TaXJxq5gOPyl2ECp3MN4wfjBRPWLiA7snNfxFIfX3nfmfxsC0VUQ4w VlcA== X-Gm-Message-State: AOAM531/X1kKkqr1w5HBfnb7yY4SLJWkWfwY1i00dPu0D9T3ydbtX2Ze DODbUSk2NK+evRhhpNl4Ck+CAcdMCbXU8eh05SOokg== X-Received: by 2002:a81:234b:0:b0:2f8:4082:bbd3 with SMTP id j72-20020a81234b000000b002f84082bbd3mr2742677ywj.47.1652399011564; Thu, 12 May 2022 16:43:31 -0700 (PDT) MIME-Version: 1.0 References: <20220512103322.380405-1-liujian56@huawei.com> <20220512231031.GT1790663@paulmck-ThinkPad-P17-Gen-1> In-Reply-To: <20220512231031.GT1790663@paulmck-ThinkPad-P17-Gen-1> From: Eric Dumazet Date: Thu, 12 May 2022 16:43:20 -0700 Message-ID: Subject: Re: [PATCH net] tcp: Add READ_ONCE() to read tcp_orphan_count To: "Paul E. McKenney" Cc: Marco Elver , Liu Jian , Dmitry Vyukov , LKML , David Miller , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , Paolo Abeni , Neal Cardwell , netdev Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 12, 2022 at 4:10 PM Paul E. McKenney wrote: > > On Thu, May 12, 2022 at 02:31:48PM -0700, Eric Dumazet wrote: > > On Thu, May 12, 2022 at 2:18 PM Marco Elver wrote: > > > > > > > > I guess the question is, is it the norm that per_cpu() retrieves data > > > that can legally be modified concurrently, or not. If not, and in most > > > cases it's a bug, the annotations should be here. > > > > > > Paul, was there any guidance/documentation on this, but I fail to find > > > it right now? (access-marking.txt doesn't say much about per-CPU > > > data.) > > > > Normally, whenever we add a READ_ONCE(), we are supposed to add a comment. > > I am starting to think that comments are even more necessary for unmarked > accesses to shared variables, with the comments setting out why the > compiler cannot mess things up. ;-) > > > We could make an exception for per_cpu_once(), because the comment > > would be centralized > > at per_cpu_once() definition. > > This makes a lot of sense to me. > > > We will be stuck with READ_ONCE() in places we are using > > per_cpu_ptr(), for example > > in dev_fetch_sw_netstats() > > If this is strictly statistics, data_race() is another possibility. > But it does not constrain the compiler at all. Statistics are supposed to be monotonically increasing ;) Some SNMP agents would be very confused if they could observe 'garbage' there. I sense that we are going to add thousands of READ_ONCE() soon :/