Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3D98C32789 for ; Mon, 22 Aug 2022 18:31:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237493AbiHVSbQ (ORCPT ); Mon, 22 Aug 2022 14:31:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237686AbiHVSbG (ORCPT ); Mon, 22 Aug 2022 14:31:06 -0400 Received: from smtp-fw-6002.amazon.com (smtp-fw-6002.amazon.com [52.95.49.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DC9B167E8 for ; Mon, 22 Aug 2022 11:31:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1661193065; x=1692729065; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xKjoHPHfT3SNjM3GEPH8NfjEMrG8ZlBmiIDh4EolsrY=; b=vX7VFRTayCNR/i1ReW6L9kXgYDCMGoRNxl138xaYh5Kyzv5c4LkAISUL N3Fr3zVpbNROEa24uAMy+U9YKKXukB9jKsZ5R3UvXahzV+j9uI9HtSFmJ 1uaBLajHU5jzS58wRGFrExq+S9Z5DGS8gnduqsrbIm3jgWylTqmH5xm3u I=; X-IronPort-AV: E=Sophos;i="5.93,255,1654560000"; d="scan'208";a="236167246" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-iad-1box-d-0e176545.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2022 18:30:53 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1box-d-0e176545.us-east-1.amazon.com (Postfix) with ESMTPS id 0E3509341B; Mon, 22 Aug 2022 18:30:51 +0000 (UTC) Received: from EX19D004ANA001.ant.amazon.com (10.37.240.138) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Mon, 22 Aug 2022 18:30:50 +0000 Received: from 88665a182662.ant.amazon.com (10.43.162.140) by EX19D004ANA001.ant.amazon.com (10.37.240.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1118.12; Mon, 22 Aug 2022 18:30:48 +0000 From: Kuniyuki Iwashima To: CC: , , , , , , Subject: Re: [PATCH v3 net 02/17] net: Fix data-races around weight_p and dev_weight_[rt]x_bias. Date: Mon, 22 Aug 2022 11:30:41 -0700 Message-ID: <20220822183041.19637-1-kuniyu@amazon.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220819170301.43675f1a@kernel.org> References: <20220819170301.43675f1a@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.43.162.140] X-ClientProxiedBy: EX13D17UWB003.ant.amazon.com (10.43.161.42) To EX19D004ANA001.ant.amazon.com (10.37.240.138) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jakub Kicinski Date: Fri, 19 Aug 2022 17:03:01 -0700 > On Thu, 18 Aug 2022 11:26:38 -0700 Kuniyuki Iwashima wrote: > > - dev_rx_weight = weight_p * dev_weight_rx_bias; > > - dev_tx_weight = weight_p * dev_weight_tx_bias; > > + WRITE_ONCE(dev_rx_weight, > > + READ_ONCE(weight_p) * READ_ONCE(dev_weight_rx_bias)); > > + WRITE_ONCE(dev_tx_weight, > > + READ_ONCE(weight_p) * READ_ONCE(dev_weight_tx_bias)); > > Is there some locking on procfs writes? Otherwise one interrupted write > may get overtaken by another and we'll end up with inconsistent values. Thanks for catching! procfs doesn't provide locking for writes, so we need a mutex like other knobs. > OTOH if there is some locking we shouldn't have to protect weight_p > here.