Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753108AbdH2MFr (ORCPT ); Tue, 29 Aug 2017 08:05:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58958 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752682AbdH2MFp (ORCPT ); Tue, 29 Aug 2017 08:05:45 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0F32685376 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=david@redhat.com Subject: Re: [PATCH RFC v3 1/9] KVM: s390: optimize detection of started vcpus To: Cornelia Huck Cc: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-mips@linux-mips.org, kvm-ppc@vger.kernel.org, linux-s390@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Paolo Bonzini , Christoffer Dall , Marc Zyngier , Christian Borntraeger , James Hogan , Paul Mackerras , Alexander Graf References: <20170821203530.9266-1-rkrcmar@redhat.com> <20170821203530.9266-2-rkrcmar@redhat.com> <67a8b09c-3e7a-943d-8684-f9ad6e70514b@redhat.com> <20170829132342.1ef25500.cohuck@redhat.com> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: Date: Tue, 29 Aug 2017 14:05:40 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170829132342.1ef25500.cohuck@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 29 Aug 2017 12:05:45 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1140 Lines: 34 On 29.08.2017 13:23, Cornelia Huck wrote: > On Tue, 22 Aug 2017 13:31:27 +0200 > David Hildenbrand wrote: > >> On 21.08.2017 22:35, Radim Krčmář wrote: >>> We can add a variable instead of scanning all online VCPUs to know how >>> many are started. We can't trivially tell which VCPU is the last one, >>> though. >> >> You could keep the started vcpus in a list. Then you might drop unsigned >> started_vcpus; >> >> No started vcpus: Start pointer NULL >> Single started vcpu: Only one element in the list (easy to check) >>> 1 started vcpus: More than one element int he list (easy to check) > > I'm not sure the added complication of keeping a list buys us much > here: We only have the "look for the last vcpu not stopped" operation > for the 2->1 transition. > That is wrong, we also have to know the last remaining (started) VCPU. For that, right now we have to iterate over all VCPUs. There shouldn't be much complexity. We already perform changes under a lock, so it is as simple as adding/removing from the list. Detecting the transitions boils down to looking at two pointers. -- Thanks, David