Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3227096pxj; Mon, 7 Jun 2021 05:43:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyo8CeHenlKtjJMsoNWsfA+VLytn2Q6fF5G7Xg5a88pHQeanBuwCo7vAPuzrd8UAjgk6DW X-Received: by 2002:a17:906:1701:: with SMTP id c1mr17418294eje.425.1623069787163; Mon, 07 Jun 2021 05:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623069787; cv=none; d=google.com; s=arc-20160816; b=W234NtZ3+7XvWyaDJMmg00EfiNAWXXG827M0jQcCltluu+DxW7xNb+ggjSET3q2WKl fwMhytcxK4kyqbM3rDT7pbA/7hhC4QdcUvI6HHC7IJNqvBtbVu32qSFE9N4t2Xqpbu70 7KG+rwXejG1E9zAKLK3tXZ7k6SRxE5m+x+zWt9YZmScS2jxaFdHfpXBjO39lUz2yb3fM HzzAhKlOR+bwHbW1IzwU2wFHK6RKqd7ehpkLqjfkm38Uj934cg6/FADbfF7FUV8O7hP1 SEGRJF4GHLOUJXGfxE16G+QMjvUHDA24Q+0jPsJbpuYbJEdCryRdWleHWzbgL+q8ePxt yigA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=RXxg+R5GrVEYC2G4MVu5tM4s5nbr/L9DwiWiCoZnbMA=; b=Dn5DZw+U5Xdly09I8Ih3Xr9mWT3bByi5MFoOuHPsspu6x0bJJuZhJ7bDxA0LKJ33vY wEDJ/s04PjrMjL14T8GlJ6TRyJvslwGugqTzwd5akiildzpAZSjn6D5EXRwzlcKtSLE8 Ri2tq42zxwrHRlPNQRfeIQrgKT3BEK4cd5WB1xWGQggMN74Z6HK5UMoC54GNfOEJ9TqC q5Na0UojzVAxFBIRwU9ZiyHYNyIltnj/3fyv90q8SU+YXCTokaGIgz/d1UpbAvIOUKQp hgLATtT/pH5rBc9fR/ByfMJ1lzNtINiWCOQ5tjfrIp4r9EhPEdDHDqfPVxQhD3OYqEA9 KcsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BU+WD7cv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n7si11770729edr.392.2021.06.07.05.42.44; Mon, 07 Jun 2021 05:43:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BU+WD7cv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230254AbhFGMni (ORCPT + 99 others); Mon, 7 Jun 2021 08:43:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:58832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230212AbhFGMnc (ORCPT ); Mon, 7 Jun 2021 08:43:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 469136108C; Mon, 7 Jun 2021 12:41:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623069701; bh=lu2ZH+zANWlmtDzF/msjapOw9uj69eZMY5m11K67Rxg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BU+WD7cvjzRz1qIKJw94BmkSep/woow9BS2l3V+9yR94wwiE9aAlSzO7nj5OS+fG3 mqTIinkkY9pjBwYLQn9FCf+ctyq6oLwnyVoTpoRcWBZ8L5q68uWE2jiqLOCUB45rmt fhR6wu+MmOru9HRkelRrTFfa9RDCYid0o/XVpfYB13ezITJfrhSer+9/U9dkEcnHna CZW4ItXfscl/qD6DDhbS17wHDi3C+dRXzCq6oRgJ73t7QJ+xOzvFqrt5OtQDkpSmgs 39HMWIK+A0fFkmn9uUVkC606ZgrwMlcFh6HDVSyE9H6V9ewyLtcTV5LJuEWEMXSw+u uw5MGUfEG2xWQ== Date: Mon, 7 Jun 2021 15:41:37 +0300 From: Leon Romanovsky To: Greg KH Cc: Doug Ledford , Jason Gunthorpe , Kees Cook , Nathan Chancellor , Adit Ranadive , Ariel Elior , Christian Benvenuti , clang-built-linux@googlegroups.com, Dennis Dalessandro , Devesh Sharma , Gal Pressman , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, Michal Kalderon , Mike Marciniszyn , Mustafa Ismail , Naresh Kumar PBS , Nelson Escobar , Nick Desaulniers , Potnuri Bharat Teja , Selvin Xavier , Shiraz Saleem , VMware PV-Drivers , Yishai Hadas , Zhu Yanjun Subject: Re: [PATCH rdma-next v1 10/15] RDMA/cm: Use an attribute_group on the ib_port_attribute intead of kobj's Message-ID: References: <00e578937f557954d240bc0856f45b3f752d6cba.1623053078.git.leonro@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 07, 2021 at 02:08:27PM +0200, Greg KH wrote: > On Mon, Jun 07, 2021 at 02:37:16PM +0300, Leon Romanovsky wrote: > > On Mon, Jun 07, 2021 at 01:22:26PM +0200, Greg KH wrote: > > > On Mon, Jun 07, 2021 at 01:51:36PM +0300, Leon Romanovsky wrote: > > > > On Mon, Jun 07, 2021 at 12:25:03PM +0200, Greg KH wrote: > > > > > On Mon, Jun 07, 2021 at 11:17:35AM +0300, Leon Romanovsky wrote: > > > > > > From: Jason Gunthorpe > > > > > > > > > > > > This code is trying to attach a list of counters grouped into 4 groups to > > > > > > the ib_port sysfs. Instead of creating a bunch of kobjects simply express > > > > > > everything naturally as an ib_port_attribute and add a single > > > > > > attribute_groups list. > > > > > > > > > > > > Remove all the naked kobject manipulations. > > > > > > > > > > Much nicer. > > > > > > > > > > But why do you need your counters to be atomic in the first place? What > > > > > are they counting that requires this? Given that they are just a > > > > > statistic for userspace, making them be a u64 should work just the same, > > > > > right? > > > > > > > > The statistic counters are per-port, while the cm.c flows run in > > > > asynchronically in parallel for every CM connection. > > > > > > > > We need atomic variable to ensure that "write to u64" is not > > > > interrupted. > > > > > > On what system is "write to u64" interruptable? > > > > On 32 bits, and yes, we have a customer who still uses such system. > > So you will see what, a "tear"? Or a stale value? Does it really make any difference for the users? The end result is that value is incorrect. > > > > As these are per-port, do multiple threads try to increment these at > > > the same time? > > > > Yes, CM connection can be seen as thread. Bottom line everything in parallel. > > > > > And even if they do, what happens if one is 'dropped' somehow because of this? > > > > Probably nothing, we increment the statistics only. > > So you are hitting cache lines for no good reason, probably not a good > idea, you are wasting cpu cycles for nothing :( I prefer correctness over performance optimization in paths that far from being hot. The thing is that we have such correctness for free without any extra code complexity by simply using proper data structure. Why shouldn't we use atomics? Also, we aren't talking about some driver code, but about core infrastructure for whole RDMA subsystem. Thanks > > thanks, > > greg k-h