Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752056AbdFUS25 (ORCPT ); Wed, 21 Jun 2017 14:28:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55821 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751028AbdFUS24 (ORCPT ); Wed, 21 Jun 2017 14:28:56 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8F32F78523 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dvlasenk@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8F32F78523 To: Suravee Suthikulpanit Cc: LKML , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= From: Denys Vlasenko Subject: Can avic_vm_id_bitmap be made smaller? 2 mbytes feels too large Message-ID: <238915be-22f4-4ea3-addf-0e06700f3c1e@redhat.com> Date: Wed, 21 Jun 2017 20:28:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 21 Jun 2017 18:28:50 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 614 Lines: 17 #define AVIC_VM_ID_BITS 24 #define AVIC_VM_ID_NR (1 << AVIC_VM_ID_BITS) ... static DECLARE_BITMAP(avic_vm_id_bitmap, AVIC_VM_ID_NR); The above results in a data object which is 2 megabytes large. avic_vm_init() -> avic_get_next_vm_id() allocates a new vm_id by looking for a free bit there. That's the whole purpose for that bitmap existing. Is there a way to do this less wastefully? Say, such as iterating over all existing VMs and picking an id which is not taken. I imagine VM creation operation is not that frequent, no need to make new vm_id selection super fast.