Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp381436pxj; Fri, 11 Jun 2021 01:19:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpNb63i3cFS3EXBruFVmskaR0i02hnnE4+Zdl6RviCefS3HSZ4c9yMqHTh4CTCAFlh4DNh X-Received: by 2002:a17:907:7b97:: with SMTP id ne23mr2512963ejc.499.1623399548698; Fri, 11 Jun 2021 01:19:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623399548; cv=none; d=google.com; s=arc-20160816; b=oVp8V9Pcanpx5UIF5rYZwlW3AKAyzEHf7JDhUPfEH7A6oRewjAH6sQucTg1/0hbmzZ qys0WMS6x6ocnLaa8+tok/WvwVx7aDTUDaoynNJ1gs6ZZdIkK1yNVWCZdEwP99lWJuxz hEXKCdUwHKHm5XjamU34Dsk1rKlpvpoQS+P2PPjggk0UG+H/d0kpCxQ4WeEXeskEseT3 kRrQnXkswgMzGkTgcey8TVZydEqmpnl7fbXUHq7GE8U48qjWsfL1RK/ISxQNRCx1piXk zY34O4O5IEHytYetB+mRyyR/+uhwPSBmagkgMSIR9En54uI7B3gG41nPriufGeHMAT5h djvw== 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=IfqBED59JqqdiqLrrLhe1uNxFPk0Whz2l0UKYj0+vOA=; b=IlG1DSiJr55tc2DRT2bkCUeqzS4pBIai9vUAJzAyXJkadpsliv603CJ07aNpg7Pcsa +yMelXfaUEOwHpvpgqErepieCfDyppu2yzM8rveVi4izsGWoSgTXovolcGqmn2EAJLYM TDp57H4x6KsaS9a9xAAxZBYI7i4a1Npu9MYuIKEPdclqH1BUFv9drtKrxJs5GKc/1SY1 3p7Je0kbSRY3x3+VgOY6JNA5svLs21OGIQwX7Ly4nezUDKYE6RZVUXa1wrUJCVu56p6w L0+gAXVcEiz2b4FMMZVyFbtAjaLt95bndmhAyMHrDoeT98Wq3QzudX47Zx72YeFz+OFw R5Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Xt0tQ0EZ; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id di7si4616926ejc.71.2021.06.11.01.18.44; Fri, 11 Jun 2021 01:19:08 -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=@linuxfoundation.org header.s=korg header.b=Xt0tQ0EZ; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231150AbhFKITJ (ORCPT + 99 others); Fri, 11 Jun 2021 04:19:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:53210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229584AbhFKITI (ORCPT ); Fri, 11 Jun 2021 04:19:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 16EF2611CC; Fri, 11 Jun 2021 08:16:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623399414; bh=cWwKCFMCJZXC7X39YT4XaDgF/u/unVgrt2qdsyuvX/Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Xt0tQ0EZ3L1Uc6ZLt+TnhpilBoj7+aGt+YvG8XLZp3M4n1yUdXA1AFWFQhF4QoNZv 4YINnx/ZQv4JDg7TEKF0oXMkshtdFhmzcsrUlbFgCfGINFkwjTFHki7y/g3AVbZl+8 di1FKeb9+ImtgtOuyC910MYyCcn24L4arHrF/P4s= Date: Fri, 11 Jun 2021 10:16:52 +0200 From: Greg KH To: Haakon Bugge Cc: Jason Gunthorpe , Leon Romanovsky , Doug Ledford , 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" , OFED mailing list , 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> <20210607121411.GC1002214@nvidia.com> <20210607125012.GE1002214@nvidia.com> <8685A354-4D41-4805-BDC5-365216CEAF40@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8685A354-4D41-4805-BDC5-365216CEAF40@oracle.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 11, 2021 at 07:25:46AM +0000, Haakon Bugge wrote: > > > > On 7 Jun 2021, at 14:50, Jason Gunthorpe wrote: > > > > On Mon, Jun 07, 2021 at 02:39:45PM +0200, Greg KH wrote: > >> On Mon, Jun 07, 2021 at 09:14:11AM -0300, Jason Gunthorpe 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? > >>> > >>> The write side of the counter is being updated from concurrent kernel > >>> threads without locking, so this is an atomic because the write side > >>> needs atomic_add(). > >> > >> So the atomic write forces a lock :( > > > > Of course, but a single atomic is cheaper than the double atomic in a > > full spinlock. > > > >>> Making them a naked u64 will cause significant corruption on the write > >>> side, and packet counters that are not accurate after quiescence are > >>> not very useful things. > >> > >> How "accurate" do these have to be? > > > > They have to be accurate. They are networking packet counters. What is > > the point of burning CPU cycles keeping track of inaccurate data? > > Consider a CPU with a 32-bit wide datapath to memory, which reads and writes the most significant 4-byte word first: What CPU is that? > Memory CPU1 CPU2 > MSW LSW MSW LSW MSW LSW > 0x0 0xffffffff > 0x0 0xffffffff 0x0 > 0x0 0xffffffff 0x0 0xffffffff > 0x0 0xffffffff 0x1 0x0 cpu1 has incremented its register > 0x1 0xffffffff 0x1 0x0 cpu1 has written msw > 0x1 0xffffffff 0x1 0x0 0x1 cpu2 has read msw > 0x1 0xffffffff 0x1 0x0 0x1 0xffffffff > 0x1 0x0 0x1 0x0 0x2 0x0 > 0x2 0x0 0x1 0x0 0x2 0x0 > 0x2 0x0 0x1 0x0 0x2 0x0 > > > I would say that 0x200000000 vs. 0x100000001 is more than inaccurate! True, then maybe these should just be 32bit counters :) thanks, greg k-h