Message ID | 20240126054747.960172-1-alan.brady@intel.com (mailing list archive) |
---|---|
Headers | show |
Series | idpf: refactor virtchnl messages | expand |
From: Alan Brady <alan.brady@intel.com> Date: Thu, 25 Jan 2024 21:47:40 -0800 > The motivation for this series has two primary goals. We want to enable > support of multiple simultaneous messages and make the channel more > robust. The way it works right now, the driver can only send and receive > a single message at a time and if something goes really wrong, it can > lead to data corruption and strange bugs. [...] There are a fistful of functions in this series and IDPF's virtchnl code in general that allocate a memory chunk via kzalloc() family and then free it at the end of the function, i.e. the lifetime of those buffers are the lifetime of the function. Since recently, we have auto-variables in the kernel, so that the pieces I described could be converted to: struct x *ptr __free(kfree) = NULL; ptr = kzalloc(sizeof(*x), GPF_KERNEL); // some code return 0; // kfree() is not needed anymore err: return err; // here as well That would allow to simplify the code and reduce its size. I'd like you to convert such functions to use auto-variables. Thanks, Olek
> -----Original Message----- > From: Lobakin, Aleksander <aleksander.lobakin@intel.com> > Sent: Monday, January 29, 2024 5:24 AM > To: Brady, Alan <alan.brady@intel.com> > Cc: intel-wired-lan@lists.osuosl.org; netdev@vger.kernel.org; > willemdebruijn.kernel@gmail.com; Bagnucki, Igor > <igor.bagnucki@intel.com>; Kitszel, Przemyslaw > <przemyslaw.kitszel@intel.com> > Subject: Re: [Intel-wired-lan] [PATCH v2 0/7 iwl-next] idpf: refactor virtchnl > messages > > From: Alan Brady <alan.brady@intel.com> > Date: Thu, 25 Jan 2024 21:47:40 -0800 > > > The motivation for this series has two primary goals. We want to > > enable support of multiple simultaneous messages and make the channel > > more robust. The way it works right now, the driver can only send and > > receive a single message at a time and if something goes really wrong, > > it can lead to data corruption and strange bugs. > > [...] > > There are a fistful of functions in this series and IDPF's virtchnl code in general > that allocate a memory chunk via kzalloc() family and then free it at the end of > the function, i.e. the lifetime of those buffers are the lifetime of the function. > Since recently, we have auto-variables in the kernel, so that the pieces I > described could be converted to: > > struct x *ptr __free(kfree) = NULL; > > ptr = kzalloc(sizeof(*x), GPF_KERNEL); > > // some code > > return 0; // kfree() is not needed anymore > > err: > return err; // here as well > > That would allow to simplify the code and reduce its size. > I'd like you to convert such functions to use auto-variables. Certainly, should be straightforward and make the code much better, sounds good to me. Just to clarify I'm only going to mess with the virtchnl functions I've otherwise altered in this patch series to maintain appropriate scope, yes? -Alan > > Thanks, > Olek
From: Brady, Alan <alan.brady@intel.com> Date: Mon, 29 Jan 2024 16:12:06 +0100 >> -----Original Message----- >> From: Lobakin, Aleksander <aleksander.lobakin@intel.com> >> Sent: Monday, January 29, 2024 5:24 AM >> To: Brady, Alan <alan.brady@intel.com> >> Cc: intel-wired-lan@lists.osuosl.org; netdev@vger.kernel.org; >> willemdebruijn.kernel@gmail.com; Bagnucki, Igor >> <igor.bagnucki@intel.com>; Kitszel, Przemyslaw >> <przemyslaw.kitszel@intel.com> >> Subject: Re: [Intel-wired-lan] [PATCH v2 0/7 iwl-next] idpf: refactor virtchnl >> messages >> >> From: Alan Brady <alan.brady@intel.com> >> Date: Thu, 25 Jan 2024 21:47:40 -0800 >> >>> The motivation for this series has two primary goals. We want to >>> enable support of multiple simultaneous messages and make the channel >>> more robust. The way it works right now, the driver can only send and >>> receive a single message at a time and if something goes really wrong, >>> it can lead to data corruption and strange bugs. >> >> [...] >> >> There are a fistful of functions in this series and IDPF's virtchnl code in general >> that allocate a memory chunk via kzalloc() family and then free it at the end of >> the function, i.e. the lifetime of those buffers are the lifetime of the function. >> Since recently, we have auto-variables in the kernel, so that the pieces I >> described could be converted to: >> >> struct x *ptr __free(kfree) = NULL; >> >> ptr = kzalloc(sizeof(*x), GPF_KERNEL); >> >> // some code >> >> return 0; // kfree() is not needed anymore >> >> err: >> return err; // here as well >> >> That would allow to simplify the code and reduce its size. >> I'd like you to convert such functions to use auto-variables. > > Certainly, should be straightforward and make the code much better, sounds good to me. Just to clarify I'm only going to mess with the virtchnl functions I've otherwise altered in this patch series to maintain appropriate scope, yes? Yes, only virtchnl functions. New functions that you introduce 100%, the rest only if you touch them. > > -Alan > >> >> Thanks, >> Olek Thanks, Olek
On 1/29/2024 7:43 AM, Alexander Lobakin wrote: > From: Brady, Alan <alan.brady@intel.com> > Date: Mon, 29 Jan 2024 16:12:06 +0100 > >>> -----Original Message----- >>> From: Lobakin, Aleksander <aleksander.lobakin@intel.com> >>> Sent: Monday, January 29, 2024 5:24 AM >>> To: Brady, Alan <alan.brady@intel.com> >>> Cc: intel-wired-lan@lists.osuosl.org; netdev@vger.kernel.org; >>> willemdebruijn.kernel@gmail.com; Bagnucki, Igor >>> <igor.bagnucki@intel.com>; Kitszel, Przemyslaw >>> <przemyslaw.kitszel@intel.com> >>> Subject: Re: [Intel-wired-lan] [PATCH v2 0/7 iwl-next] idpf: refactor virtchnl >>> messages >>> >>> From: Alan Brady <alan.brady@intel.com> >>> Date: Thu, 25 Jan 2024 21:47:40 -0800 >>> >>>> The motivation for this series has two primary goals. We want to >>>> enable support of multiple simultaneous messages and make the channel >>>> more robust. The way it works right now, the driver can only send and >>>> receive a single message at a time and if something goes really wrong, >>>> it can lead to data corruption and strange bugs. >>> [...] >>> >>> There are a fistful of functions in this series and IDPF's virtchnl code in general >>> that allocate a memory chunk via kzalloc() family and then free it at the end of >>> the function, i.e. the lifetime of those buffers are the lifetime of the function. >>> Since recently, we have auto-variables in the kernel, so that the pieces I >>> described could be converted to: >>> >>> struct x *ptr __free(kfree) = NULL; >>> >>> ptr = kzalloc(sizeof(*x), GPF_KERNEL); >>> >>> // some code >>> >>> return 0; // kfree() is not needed anymore >>> >>> err: >>> return err; // here as well >>> >>> That would allow to simplify the code and reduce its size. >>> I'd like you to convert such functions to use auto-variables. >> Certainly, should be straightforward and make the code much better, sounds good to me. Just to clarify I'm only going to mess with the virtchnl functions I've otherwise altered in this patch series to maintain appropriate scope, yes? > Yes, only virtchnl functions. New functions that you introduce 100%, the > rest only if you touch them. I've gone ahead and submitted a v3 with the suggested changes. However, I would also like to follow this up with another series that addresses the entire idpf driver where we can not only use the automatic variables for kfree, but also make the various locks we have much better. I do end up touching some of the locks I introduced here, but I need to add a guard to include/linux/spinlock.h to convert all of it. I think it still makes sense to not include those changes in this series to avoid polluting it if possible, but there will be a dependency. Also thank you for pointing this out, I think it's a massive improvement to the driver code.