Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2977757pxb; Sat, 30 Jan 2021 23:42:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6e6RHgwMe7bb35uQQRnLd00EXV9mgQwA7Bdq23oIiUyayuJ6C+f07woAKXnFPTy5nMcpY X-Received: by 2002:a17:906:1c42:: with SMTP id l2mr12189281ejg.390.1612078923625; Sat, 30 Jan 2021 23:42:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612078923; cv=none; d=google.com; s=arc-20160816; b=qjV6c4uGyFHtwr7QSFvv5T4HVtTLpWNY8EVYVmxIRC1LoVewtx/N1vZv+sRKFVhyjr x+BMkvn84iJrtprM7y+bDxI7/fYQfBV8qzhngqzet5wBMCupMYD956teKHZNeMZQLJJR wSW+kMDFhLHl3/GTDm+f7hd33dlTPfXpcGByzqpVRos4P1+eyedH00LC7eQL5OAgsreZ zQcZzfy/7ZSxr2xhYCfoGtel5yBaXRoJrk7fbS6iXBUzUpI0hlOiB5JlBIwLeMT3Is67 BZUqjr1NybAUw8f+sDzTmTXi6LAn+UHSQ8HmeFJbWpzHMVhmJCPxOidw1Tenju1mRQow hhIg== 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=WpAxZYTx1EFyyrp39KOuxr2vbAEfWN4+fpF0v6RI/hI=; b=v8KScc0v+XXzB0zlxxgJKeJAOb9wcxoe04IKuduLztdD/Zk6amLofieDuQeyuJEBGr bMqN2R0YTk/+9QQ6vKiDws1/i4je2a6LzCLC+mp/a3dof+KZ/3iQepgSb2Dob8rSDHsF ceXj0OilDO38ZW5NjSYjjxVB9k3X2iu+bTzvRQmLG7ehr/qylcjJhUfGMCq/aJSE7cj8 tBUOX4oLUnOcL/nMk+e4gy0Zb6XfqQsGxGrs3vB9xqEwnoA8L+6EFSasWXZBnQiIwJ43 yqPKdPkwvv5oH164WWdqgNCySKD1UbWLVRZ2wPZ+4epQRErzPpE+6bNEDkgNfWDb1ehZ i4sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="MWbOIR/K"; 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 gy4si7726474ejb.4.2021.01.30.23.41.39; Sat, 30 Jan 2021 23:42:03 -0800 (PST) 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="MWbOIR/K"; 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 S229910AbhAaHgh (ORCPT + 99 others); Sun, 31 Jan 2021 02:36:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:54346 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229474AbhAaHgJ (ORCPT ); Sun, 31 Jan 2021 02:36:09 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AD7C664E24; Sun, 31 Jan 2021 07:35:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612078528; bh=hfWoFSzQSusZX74pIPkuz0bi7jBqX9foozhC+sJESbI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MWbOIR/KKjXuDPQ0SFqFzHGsrvekMNeiDHAJLQr/ZVNj8HWfcuSKJ1IiZD8TER9JB yWTtLBR4OSnkCwyhCYFHnL2SG4fK/nPW51HV1+UKTnVn2WbDTYMj0i1cFipK1yv8be j8bJ5TCF8w2ZoBszwXv6QZu+qNO0LA7ql4qJijYA= Date: Sun, 31 Jan 2021 08:35:24 +0100 From: Greg KH To: Avri Altman Cc: "James E . J . Bottomley" , "Martin K . Petersen" , "linux-scsi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Bart Van Assche , yongmyung lee , Daejun Park , "alim.akhtar@samsung.com" , "asutoshd@codeaurora.org" , Zang Leigang , Avi Shchislowski , Bean Huo , "cang@codeaurora.org" , "stanley.chu@mediatek.com" Subject: Re: [PATCH 3/8] scsi: ufshpb: Add region's reads counter Message-ID: References: <20210127151217.24760-1-avri.altman@wdc.com> <20210127151217.24760-4-avri.altman@wdc.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 Sun, Jan 31, 2021 at 07:25:37AM +0000, Avri Altman wrote: > > > > > > + if (ufshpb_mode == HPB_HOST_CONTROL) > > > + reads = atomic64_inc_return(&rgn->reads); > > > + > > > if (!ufshpb_is_support_chunk(transfer_len)) > > > return; > > > > > > + if (ufshpb_mode == HPB_HOST_CONTROL) { > > > + /* > > > + * in host control mode, reads are the main source for > > > + * activation trials. > > > + */ > > > + if (reads == ACTIVATION_THRSHLD) { > Oops - this is a bug... > > > > + > > > + /* region reads - for host mode */ > > > + atomic64_t reads; > > > > Why do you need an atomic variable for this? What are you trying to > > "protect" here by flushing the cpus all the time? What protects this > > variable from changing right after you have read from it (hint, you do > > that above...) > > > > atomics are not race-free, use a real lock if you need that. > We are on the data path here - this is called from queuecommand. > The "reads" counter is being symmetrically read and written, > so adding a spin lock here might become a source for contention. And an atomic varible is not? You do know what spinlocks are made of, right? :) > Also I am not worried about the exact value of this counter, except of one place - > See above. Will fix it. So it's not really needed? thanks, greg k-h