From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cyrill Gorcunov Subject: Re: [PATCH 2/2] kvm tools: Modify ioport to use interval rbtree Date: Sat, 21 May 2011 14:31:20 +0400 Message-ID: <4DD79478.6040602@gmail.com> References: <1305967911-30045-1-git-send-email-levinsasha928@gmail.com> <1305967911-30045-2-git-send-email-levinsasha928@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: penberg@kernel.org, mingo@elte.hu, asias.hejun@gmail.com, prasadjoshi124@gmail.com, kvm@vger.kernel.org To: Sasha Levin Return-path: Received: from mail-ey0-f174.google.com ([209.85.215.174]:62716 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752929Ab1EUKbY (ORCPT ); Sat, 21 May 2011 06:31:24 -0400 Received: by eyx24 with SMTP id 24so1379656eyx.19 for ; Sat, 21 May 2011 03:31:23 -0700 (PDT) In-Reply-To: <1305967911-30045-2-git-send-email-levinsasha928@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: 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? -- Cyrill