[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZXwkezPrcHlFdiS9@nanopsycho>
Date: Fri, 15 Dec 2023 11:03:39 +0100
From: Jiri Pirko <jiri@...nulli.us>
To: Jakub Kicinski <kuba@...nel.org>
Cc: netdev@...r.kernel.org, pabeni@...hat.com, davem@...emloft.net,
edumazet@...gle.com, jacob.e.keller@...el.com, jhs@...atatu.com,
johannes@...solutions.net, andriy.shevchenko@...ux.intel.com,
amritha.nambiar@...el.com, sdf@...gle.com, horms@...nel.org,
przemyslaw.kitszel@...el.com
Subject: Re: [patch net-next v7 5/9] genetlink: introduce per-sock family
private storage
Fri, Dec 15, 2023 at 04:23:58AM CET, kuba@...nel.org wrote:
>On Thu, 14 Dec 2023 19:15:45 +0100 Jiri Pirko wrote:
>> - converted family->sock_priv_list to family->sock_privs xarray
>> and use it to store the per-socket privs, use sock pointer as
>> an xarrar index. This made the code much simpler
>
>Nice!
>
>FWIW I think I remember Willy saying that storing pointers in xarray is
>comparatively inefficient / slow, but we can cross that bridge later.
I see an alternative in using rhashtable with sk pointer as a key. Not
sure if it is more efficient. Any other ideas?
But as you say, this can be addressed as a follow-up.
>
>> +void *__genl_sk_priv_get(struct genl_family *family, struct sock *sk)
>> +{
>> + if (WARN_ON_ONCE(!family->sock_privs))
>> + return NULL;
>> + return xa_load(family->sock_privs, (unsigned long) sk);
>> +}
>> +
>> +/**
>> + * genl_sk_priv_get - Get family private pointer for socket
>> + *
>> + * @family: family
>> + * @sk: socket
>> + *
>> + * Lookup a private memory for a Generic netlink family and specified socket.
>> + * Allocate the private memory in case it was not already done.
>> + *
>> + * Return: valid pointer on success, otherwise negative error value
>> + * encoded by ERR_PTR().
>
>nit: probably better if __genl_sk_priv_get() returned an error pointer
> if family is broken, save ourselves the bot-generated "fixes"..
Okay, will fix and send v8 (hopefully the last one, uff).
>
>> + */
>> +void *genl_sk_priv_get(struct genl_family *family, struct sock *sk)
>> +{
>> + void *priv, *old_priv;
>> +
>> + priv = __genl_sk_priv_get(family, sk);
>> + if (priv)
>> + return priv;
>
Powered by blists - more mailing lists