From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=192.198.163.17 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796469749; b=P/u64/wiBav+GpUWtqk2c0AU2bi7I8xsbjf0hnVEkxDKSpO91fNoaXdVbqq/VdPB9gW/ ZFS16euI9YCxvgN/K+cuLXsUiTeeT70rVg74sE1j8WhyYQTKVqhVTxmXWru9hfhdoR37p qA26mU19lpsUu4vd89gy3ODx3CJEDfNt8Wu2Z3LiEu6L4aukrL56+eKLT/IHex952X0Vy N6Za/qZjaMBl/b2evP91PaItnSfpFK60UwYfk7pfEEEqSn11yYmZki9IlQtLHdUzxPO0G X4+xNgzmjP+i+ljTvSar8H6Dy1pYleJKe7ujCOKSuy7ClSaD85LDaH8E0rKl8AeUkcQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796469749; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To:Organization; bh=SrqAuh5nwPUIVCug+Qi8/ehh/JVzdzAGFeDt3dz11HI=; b=lfd4U/BF0pnX7TepYvvWSJ284gmkdzXEI64Cn5g3LuGICnbIpA5G1P1DIjxTByE1hla7 AeenzCzYqKEZhGz7VXhqDYa013JSNgXUhEfgTcR2sZy2akPkMmIkjA7yaec1ZC/4kkJhQ 526EPmfaDzoBntkj9k/xBzyNkGPzIIo2itwuX8hNVyFvjIL4nKO+ohEyEbvsfzg1x2uqx oiF3FqrMajH2rZxlQWRECLNMTkege0Knyg+ytP6JF3p47qERQsydcNNNpU4Rg1jtZqvjJ sMrduXDUEjo3dNsj0QsxQxOGgO1I4JIQSMxP7cSEVbRn6S/cqwWb8ZRYBUMAP5lwesA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ZwerxESC; arc=none smtp.remote-ip=192.198.163.17 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7377A606A322; Sat, 5 Dec 2026 11:22:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7377A606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ZwerxESC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796469750; x=1828005750; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=SrqAuh5nwPUIVCug+Qi8/ehh/JVzdzAGFeDt3dz11HI=; b=ZwerxESC6tcIQpL0SuZk7XO0GOYgGmcoQTVEp7PY98HW1xKsD6HloEWp 2kK2CP6/msBF8eCMRfSvssBJacVw8WcVJoX+e4Is2TqhZevAsHUbTN+fd 6pdhu+B/IFm8BqTjLQlUwqI98D4MtciWAxUC4/HOgKkspy69wi6gOelJ+ BzB9YeQ1WR1DzYAtUNx9eyAlkSE9A6rDHp9Vi7UFfjD9xAD7718UiiN9r 8SDCvkufMa2zWfAZXBzLNBmWuW97FBfLyH07MBBoPAbtY08lVwcDCbZ98 ECNALpffcLx7MIec7vtE+hDxUOdjXq99hUZNK/CSh1xB0CeNyTZSNCNEf A==; X-CSE-ConnectionGUID: xG+1kdHKQJaCu0DjQocDHg== X-CSE-MsgGUID: HedjbcOTS42dRf4xwZ2qjw== X-IronPort-AV: E=McAfee;i="6800,10657,11987"; a="5451645" X-IronPort-AV: E=Sophos;i="6.29,80,1794902400"; d="scan'208";a="5451645" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Dec 2026 03:22:29 -0800 X-CSE-ConnectionGUID: /1V215F1TwekueawJhQfNw== X-CSE-MsgGUID: T/R6CiB9Ramjbs8C89aqSQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,80,1794902400"; d="scan'208";a="5753047" Received: from conormcd-mobl2.ger.corp.intel.com (HELO localhost) ([10.245.245.126]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Dec 2026 03:22:26 -0800 Date: Sat, 5 Dec 2026 13:22:22 +0200 From: Andy Shevchenko To: Jack Wang <163wangjack@gmail.com> Cc: vinicius.gomes@intel.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, victor@mojatatu.com, mhm.dawod@gmail.com, esalomatkina@ispras.ru, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net v5 2/2] net/sched: cbs: use atomic64_t for idleslope and sendslope Message-ID: References: <20261205073304.86227-1-163wangjack@gmail.com> <20261205073304.86227-3-163wangjack@gmail.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261205073304.86227-3-163wangjack@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo On Sat, Dec 05, 2026 at 03:33:04PM +0800, Jack Wang wrote: > q->idleslope and q->sendslope are s64 written locklessly in > cbs_change() and read concurrently in cbs_dequeue_soft() and cbs_dump(). > On 32-bit kernels, plain 64-bit accesses can tear, especially for > negative sendslope values. > > Convert both fields to atomic64_t, matching q->port_rate. ... > if (q->credits < 0) { > - credits = timediff_to_credits(now - q->last, q->idleslope); > + s64 idleslope = atomic64_read(&q->idleslope); > + > + credits = timediff_to_credits(now - q->last, idleslope); > > credits = q->credits + credits; So, what's wrong with combining these two now? credits = q->credits + timediff_to_credits(now - q->last, idleslope); ... > - credits = credits_from_len(len, q->sendslope, > + credits = credits_from_len(len, atomic64_read(&q->sendslope), > atomic64_read(&q->port_rate)); And how does this help? Any value read by atomic APIs immediately becomes outdated (yes, by luck if not synchronised, it may keep the same value for a while). -- With Best Regards, Andy Shevchenko