From patchwork Tue Feb 21 14:49:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 730591 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vSNhW4Tltz9s7K for ; Wed, 22 Feb 2017 01:50:19 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A765BB7C; Tue, 21 Feb 2017 14:49:49 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 4ACEDB76 for ; Tue, 21 Feb 2017 14:49:48 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id B8D5B22C for ; Tue, 21 Feb 2017 14:49:47 +0000 (UTC) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OLQ0096YBUXER70@mailout2.w1.samsung.com> for dev@openvswitch.org; Tue, 21 Feb 2017 14:49:45 +0000 (GMT) Received: from eusmges5.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170221144945eucas1p2e84f09c472d8d64be7ff2ae42610ce05~lVOLwe7V12194721947eucas1p25; Tue, 21 Feb 2017 14:49:45 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges5.samsung.com (EUCPMTA) with SMTP id D7.4B.17477.9835CA85; Tue, 21 Feb 2017 14:49:45 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170221144944eucas1p122e0874c9459476f9b71dd9e845c4426~lVOLFKh-21511215112eucas1p1c; Tue, 21 Feb 2017 14:49:44 +0000 (GMT) X-AuditID: cbfec7f5-f79d06d000004445-1b-58ac53894e59 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 98.49.06687.DD35CA85; Tue, 21 Feb 2017 14:51:09 +0000 (GMT) Received: from imaximets.rnd.samsung.ru ([106.109.129.180]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OLQ00411BUJST90@eusync3.samsung.com>; Tue, 21 Feb 2017 14:49:44 +0000 (GMT) From: Ilya Maximets To: dev@openvswitch.org, Daniele Di Proietto Date: Tue, 21 Feb 2017 17:49:25 +0300 Message-id: <1487688568-14820-2-git-send-email-i.maximets@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1487688568-14820-1-git-send-email-i.maximets@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGIsWRmVeSWpSXmKPExsWy7djPc7qdwWsiDJ7tE7F4NbmB0aKlfyaz xdHTe5gt7v5YwWQx7fNtdosr7T/ZLe7e/MPkwO6xeM9LJo9nN/8zejy/1sPi0bdlFWMASxSX TUpqTmZZapG+XQJXRvOsTywFZzgrfra1MTYwTmXvYuTkkBAwkTh4cgcrhC0mceHeerYuRi4O IYGljBKTNvxhgXA+M0r0XH7HBNOxeftORojEMkaJK1dWskI4zUwSF9ZvBZvFJqAjcWr1EUYQ W0TASeLh6lVgo5gFtjFKTJ1+HqxIWMBBouHzKzCbRUBVYvG5ThYQm1fATaLr3HOoA+Ukbp7r ZAaxOQXcJS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N8aAYV4UxIrq1KL8uOLSnNSiw8xmgIdNZFZSjQ5HxhheSXxhiaG5paGRsYWFuZGRkri vCUfroQLCaQnlqRmp6YWpBbB9DFxcEo1MJoGhD8tLfkrtaJfVCb/9fqnC65GzLx/gKG/9Rbv cuHKUHdH2b/n/0d949C0WqnAaPXypaBieY3n/b2hohfd/rpsTtb9+rPWYX2Hpmlm/OZH7DX/ /S0S1S+cOThLg3eWqva+Q6Z8KU+/hu9y6JiSvUbF7Vz4yV6mybrKIUsW1V36I1hVUfYwWIml OCPRUIu5qDgRAHkY5cd4AgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170221144944eucas1p122e0874c9459476f9b71dd9e845c4426 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?SWx5YSBNYXhpbWV0cxtTUlItVmlydHVhbGl6YXRpb24gTGFi?= =?UTF-8?B?G+yCvOyEseyghOyekBtFbmdpbmVlcg==?= X-Global-Sender: =?UTF-8?B?SWx5YSBNYXhpbWV0cxtTUlItVmlydHVhbGl6YXRpb24gTGFi?= =?UTF-8?B?G1NhbXN1bmcgRWxlY3Ryb25pY3MbRW5naW5lZXI=?= X-Sender-Code: =?UTF-8?B?QzEwG0NJU0hRG0MxMEdEMDFHRDAxMDE1NA==?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170221144944eucas1p122e0874c9459476f9b71dd9e845c4426 X-RootMTR: 20170221144944eucas1p122e0874c9459476f9b71dd9e845c4426 References: <1487688568-14820-1-git-send-email-i.maximets@samsung.com> X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ilya Maximets , Heetae Ahn Subject: [ovs-dev] [PATCH 1/4] id-pool: Allocate the lowest available ids. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org This simple change makes id-pool to always allocate the lowest possible id from the pool. No any other code affected because, actually, there is no users of 'id_pool_free_id' in OVS. This behaviour of id-pool will be used in the next patch. Signed-off-by: Ilya Maximets --- lib/id-pool.c | 3 +++ lib/id-pool.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/id-pool.c b/lib/id-pool.c index 62a6b33..8f005e0 100644 --- a/lib/id-pool.c +++ b/lib/id-pool.c @@ -148,6 +148,9 @@ id_pool_free_id(struct id_pool *pool, uint32_t id) id_node = id_pool_find(pool, id); if (id_node) { hmap_remove(&pool->map, &id_node->node); + if (id < pool->next_free_id) { + pool->next_free_id = id; + } free(id_node); } } diff --git a/lib/id-pool.h b/lib/id-pool.h index 93a49c3..8721f87 100644 --- a/lib/id-pool.h +++ b/lib/id-pool.h @@ -35,7 +35,7 @@ void id_pool_add(struct id_pool *, uint32_t id); * ======== * * Pool of unique 32bit ids. - * + * Allocation always returns the lowest available id. * * Thread-safety * =============