]> git.baikalelectronics.ru Git - kernel.git/commitdiff
genetlink: use idr_alloc_cyclic for family->id assignment
authorMarcel Holtmann <marcel@holtmann.org>
Wed, 24 Apr 2019 20:18:53 +0000 (22:18 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 26 Apr 2019 15:59:58 +0000 (11:59 -0400)
When allocating the next family->id it makes more sense to use
idr_alloc_cyclic to avoid re-using a previously used family->id as much
as possible.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/netlink/genetlink.c

index f0ec068e1d02fc0ebd39c2b1ecd935a301647ab1..cb69d35c8e6adc31e07c07f58170c48b6d9e9c3a 100644 (file)
@@ -362,8 +362,8 @@ int genl_register_family(struct genl_family *family)
        } else
                family->attrbuf = NULL;
 
-       family->id = idr_alloc(&genl_fam_idr, family,
-                              start, end + 1, GFP_KERNEL);
+       family->id = idr_alloc_cyclic(&genl_fam_idr, family,
+                                     start, end + 1, GFP_KERNEL);
        if (family->id < 0) {
                err = family->id;
                goto errout_free;