Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1062451pxk; Thu, 3 Sep 2020 22:19:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyTNl0mOyFN4P/J+DBAxK6t8+Ps7WZHfOdU2VYfPyAAbHY97tLbFwPsQ2lZKVkUz2kmP4d X-Received: by 2002:aa7:dd01:: with SMTP id i1mr6803398edv.121.1599196748494; Thu, 03 Sep 2020 22:19:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599196748; cv=none; d=google.com; s=arc-20160816; b=mDU+24B1P2USo9jN/nNui4nCKK53qXT9/fgD2WsJjANrmwD99885mV6zklUKJFG8ms v/jVJTHtYH6A8UoCzWVHY2HXxNyvhvmOgsqJ4uAfeRxNwQ1ZvCIoiuiX1nXH6YINcXpA izEJ1qBlm9cJf0PP8YR5phXC8UnGSv7f3qKDShcqh/QmaIG+d8/Tm3r4426oGvqYnDzC n1ELXxJcq5r19WWmoqwkG+AiJkQL+VC4LtcwWuABxCTN2vxzahrSAJDA+eG+CY9ybE03 7jCTA3KycKpQxIcTeup4yV96htfxkTQsXnrwURWsOo91tHXxzhXrLa+jd30nOTuhP9Az ekrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=MvP/IwhIB+fRpOitAK3V98VJTFSQ6X3yGMBy4u4mWKo=; b=R2xFdXZNMMzYWJGSXxIedcMFNfu+HMFpxsspUk+VJUHJ6B4XUAjb61Onmxh0x3Cxmt nM3XUyApTJJG0R1NFbJYT7CWxgtnhjvPhNwV+uryRXTR3PZQqj9a5ow6+d3bjrIASPqI 2Tvdx439UsvYQdA8YHBX0+gyj87xl7z8/Mc22BOilehBM6iTVf9g271xJmjCyaJdb4Vt Fb6csPIJYE8hajh9aklw6nnGsS1bX57N/RH+YOldGvJrGNu7jbz5DHuECNLWLa8S8NtS AKQCiEeU3JrDldJzm5rx/sYMbGh/jDvPl043/FZR0zD7FC2WqOoRZWYs9A00atnNHAJ5 M++g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a6tlkrcv; 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=fail (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 dr7si2737693ejc.447.2020.09.03.22.18.44; Thu, 03 Sep 2020 22: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=@kernel.org header.s=default header.b=a6tlkrcv; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726127AbgIDFSK (ORCPT + 99 others); Fri, 4 Sep 2020 01:18:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:53368 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725812AbgIDFSJ (ORCPT ); Fri, 4 Sep 2020 01:18:09 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A540A206F2; Fri, 4 Sep 2020 05:18:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599196689; bh=8WMM6ebQyBfAmzNXp8LFPgkcHhEeM2jeF3KXNZePTII=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=a6tlkrcv5egcCzWCQdxwiBbij1LxIf70Ln1u5wpQJWPFstF1nDB4Rf57PGeJlrcrJ haWTxIQtnIK6XP75na0gLy/2hAwiIKZ25k4906FIhaCher+UnvHjYzRhCQAvPRmrGr yA0Mewhi8N9BMt5zfUrZU2kZeGra+1NzgZt8/D58= Date: Fri, 4 Sep 2020 07:18:30 +0200 From: Greg KH To: Iouri Tarassov Cc: Pavel Machek , Sasha Levin , kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org, iourit@microsoft.com, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, spronovo@microsoft.com Subject: Re: [PATCH 1/4] drivers: hv: dxgkrnl: core code Message-ID: <20200904051830.GA2231475@kroah.com> References: <20200814123856.3880009-1-sashal@kernel.org> <20200814123856.3880009-2-sashal@kernel.org> <20200821135340.GA4067@bug> <054abab3-748e-c56b-526a-1b1734a9eaf7@linux.microsoft.com> <20200828061840.GE56396@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 03, 2020 at 02:39:05PM -0700, Iouri Tarassov wrote: > Hi Greg, > > On 8/27/2020 11:18 PM, Greg KH wrote: > > On Thu, Aug 27, 2020 at 05:25:23PM -0700, Iouri Tarassov wrote: > > > > > +bool dxghwqueue_acquire_reference(struct dxghwqueue *hwqueue) > > > > > +{ > > > > > + return refcount_inc_not_zero(&hwqueue->refcount); > > > > > +} > > > > > > Midlayers are evil. > > > I strongly agree in general, but think that in our case the layers are very > > > small. It allows to quickly find all places where a reference/dereference on > > > an object is done and addition of debug tracing to catch errors. > > > > Again, no, please remove all layers like this. They just make it > > impossible for others to review and understand the code over time. > > > > Also, in this specific case, it would have allowed me to easily realize > > that you are doing this type of call incorrectly and should be using a > > different data structure :) > > Are you suggesting that the current code is incorrect? Could you comment > what changes need to be done? You should be using the built-in reference counting object (a kref) and not trying to roll your own as you did here. That way we "know" you got the logic right and do not have to audit your codebase to prove that your hand-made one is correct. thanks, greg k-h