netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] genetlink: use idr_alloc_cyclic for family->id assignment
@ 2019-04-24 20:18 Marcel Holtmann
  2019-04-26 16:00 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Marcel Holtmann @ 2019-04-24 20:18 UTC (permalink / raw)
  To: netdev

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>
---
 net/netlink/genetlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 288456090710..f1f2cbd7874e 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -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;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] genetlink: use idr_alloc_cyclic for family->id assignment
  2019-04-24 20:18 [PATCH] genetlink: use idr_alloc_cyclic for family->id assignment Marcel Holtmann
@ 2019-04-26 16:00 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-04-26 16:00 UTC (permalink / raw)
  To: marcel; +Cc: netdev

From: Marcel Holtmann <marcel@holtmann.org>
Date: Wed, 24 Apr 2019 22:18:53 +0200

> 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>

Applied, thanks Marcel.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-26 16:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-24 20:18 [PATCH] genetlink: use idr_alloc_cyclic for family->id assignment Marcel Holtmann
2019-04-26 16:00 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).