Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753128AbdHBUQk (ORCPT ); Wed, 2 Aug 2017 16:16:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50206 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753067AbdHBUQi (ORCPT ); Wed, 2 Aug 2017 16:16:38 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AB2F081227 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=rkrcmar@redhat.com Date: Wed, 2 Aug 2017 22:16:33 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, borntraeger@de.ibm.com Subject: Re: [PATCH] KVM: avoid using rcu_dereference_protected Message-ID: <20170802201633.GA32403@flask> References: <1501689354-18699-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1501689354-18699-1-git-send-email-pbonzini@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 02 Aug 2017 20:16:38 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 588 Lines: 17 2017-08-02 17:55+0200, Paolo Bonzini: > During teardown, accesses to memslots and buses are using > rcu_dereference_protected with an always-true condition because > these accesses are done outside the usual mutexes. This > is because the last reference is gone and there cannot be any > concurrent modifications, but rcu_dereference_protected is > ugly and unobvious. > > Instead, check the refcount in kvm_get_bus and __kvm_memslots. > > Signed-off-by: Paolo Bonzini > --- Probably looks nicer than temporarily taking the slots_lock. Queued for 4.13, thanks.