On Wed, 22 Jul 2020 18:57:11 +0300 Parav Pandit wrote: > Currently devlink instance is searched on all doit() operations. > But it is optionally stored into user_ptr[0]. This requires > rediscovering devlink again doing post_doit(). > > Few devlink commands related to port shared buffers needs 3 pointers > (devlink, devlink_port, and devlink_sb) while executing doit commands. > Though devlink pointer can be derived from the devlink_port during > post_doit() operation when doit() callback has acquired devlink > instance lock, relying on such scheme to access devlik pointer makes > code very fragile. > > Hence, to avoid ambiguity in post_doit() and to avoid searching > devlink instance again, simplify code by always storing devlink > instance in user_ptr[0] and derive devlink_sb pointer in their > respective callback routines. > > Signed-off-by: Parav Pandit <pa...@mellanox.com> > Reviewed-by: Jiri Pirko <j...@mellanox.com>
Other options include having some static variable (since doit is always under devlink_mutex AFAICS) or doing a tiny allocation to fit more pointers. But whatever: Acked-by: Jakub Kicinski <k...@kernel.org>