From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: Re: [PATCH 2/2] kvm tools: Modify ioport to use interval rbtree Date: Sat, 21 May 2011 13:55:38 +0300 Message-ID: <1305975338.3205.23.camel@lappy> References: <1305967911-30045-1-git-send-email-levinsasha928@gmail.com> <1305967911-30045-2-git-send-email-levinsasha928@gmail.com> <4DD79478.6040602@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: penberg@kernel.org, mingo@elte.hu, asias.hejun@gmail.com, prasadjoshi124@gmail.com, kvm@vger.kernel.org To: Cyrill Gorcunov Return-path: Received: from mail-ww0-f44.google.com ([74.125.82.44]:34636 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754634Ab1EUKzv (ORCPT ); Sat, 21 May 2011 06:55:51 -0400 Received: by wwa36 with SMTP id 36so4766003wwa.1 for ; Sat, 21 May 2011 03:55:49 -0700 (PDT) In-Reply-To: <4DD79478.6040602@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: On Sat, 2011-05-21 at 14:31 +0400, Cyrill Gorcunov wrote: > On 05/21/2011 12:51 PM, Sasha Levin wrote: > > Currently the ioport implementation is based on a USHRT_MAX length > > array of ptrs to ioport_operations. > > > > Instead, use an interval rbtree to map the ioports to > > ioport_operations. > > > > Signed-off-by: Sasha Levin > > --- > ... > > -static struct ioport_operations *ioport_ops[USHRT_MAX]; > > - > > void ioport__register(u16 port, struct ioport_operations *ops, int count) > > { > > - int i; > > + struct ioport_entry *entry; > > > > - for (i = 0; i < count; i++) > > - ioport_ops[port + i] = ops; > > + entry = ioport_search(&ioport_tree, port); > > + if (entry) > > + rb_int_erase(&ioport_tree, &entry->node); > > + > > Hi Sasha, if I understand this correct we're simply drop old registartion, right? I think > it should not be like that, if one port get used for several drivers/purposes we need a > ref-counting, but at moment I think we simply should not allow to re-register port without > previously unregister it. Or I miss something? Currently we register some ports as dummy ports in the ioport initialization, and re-register them once they get someone who can use them (for example, serial device). Not allowing ports to re-register would mean we can't reassign ports to serial console when the serial console module gets loaded. -- Sasha.