* [Intel-wired-lan] [PATCH] ice: Don't use GFP_KERNEL in atomic context
@ 2022-01-16 18:46 ` Christophe JAILLET
0 siblings, 0 replies; 7+ messages in thread
From: Christophe JAILLET @ 2022-01-16 18:46 UTC (permalink / raw)
To: intel-wired-lan
ice_misc_intr() is an irq handler. It should not sleep.
Use GFP_ATOMIC instead of GFP_KERNEL when allocating some memory.
Fixes: 348048e724a0 ("ice: Implement iidc operations")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
I've never played a lot with irq handler. My understanding is that they
should never sleep. So GFP_KERNEL must be avoided. So I guess that this
patch is correct.
However, I don't know if some special cases allow such allocation.
Any feedback/pointer to a good doc/explanation is welcome :)
---
drivers/net/ethernet/intel/ice/ice_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 30814435f779..65de01f3a504 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -3018,7 +3018,7 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)
struct iidc_event *event;
ena_mask &= ~ICE_AUX_CRIT_ERR;
- event = kzalloc(sizeof(*event), GFP_KERNEL);
+ event = kzalloc(sizeof(*event), GFP_ATOMIC);
if (event) {
set_bit(IIDC_EVENT_CRIT_ERR, event->type);
/* report the entire OICR value to AUX driver */
--
2.32.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH] ice: Don't use GFP_KERNEL in atomic context @ 2022-01-16 18:46 ` Christophe JAILLET 0 siblings, 0 replies; 7+ messages in thread From: Christophe JAILLET @ 2022-01-16 18:46 UTC (permalink / raw) To: Jesse Brandeburg, Tony Nguyen, David S. Miller, Jakub Kicinski, Shiraz Saleem, Dave Ertman Cc: linux-kernel, kernel-janitors, Christophe JAILLET, intel-wired-lan, netdev ice_misc_intr() is an irq handler. It should not sleep. Use GFP_ATOMIC instead of GFP_KERNEL when allocating some memory. Fixes: 348048e724a0 ("ice: Implement iidc operations") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> --- I've never played a lot with irq handler. My understanding is that they should never sleep. So GFP_KERNEL must be avoided. So I guess that this patch is correct. However, I don't know if some special cases allow such allocation. Any feedback/pointer to a good doc/explanation is welcome :) --- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 30814435f779..65de01f3a504 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -3018,7 +3018,7 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data) struct iidc_event *event; ena_mask &= ~ICE_AUX_CRIT_ERR; - event = kzalloc(sizeof(*event), GFP_KERNEL); + event = kzalloc(sizeof(*event), GFP_ATOMIC); if (event) { set_bit(IIDC_EVENT_CRIT_ERR, event->type); /* report the entire OICR value to AUX driver */ -- 2.32.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Intel-wired-lan] [PATCH] ice: Don't use GFP_KERNEL in atomic context 2022-01-16 18:46 ` Christophe JAILLET @ 2022-01-16 21:42 ` Andrew Lunn -1 siblings, 0 replies; 7+ messages in thread From: Andrew Lunn @ 2022-01-16 21:42 UTC (permalink / raw) To: intel-wired-lan On Sun, Jan 16, 2022 at 07:46:20PM +0100, Christophe JAILLET wrote: > ice_misc_intr() is an irq handler. It should not sleep. > > Use GFP_ATOMIC instead of GFP_KERNEL when allocating some memory. > > Fixes: 348048e724a0 ("ice: Implement iidc operations") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > I've never played a lot with irq handler. My understanding is that they > should never sleep. Hi Christophe Threaded interrupt handlers are allowed to sleep. However, this handler is not being used in such a way. So your are probably correct about GFP_KERNEL vs GFP_ATOMIC. > --- > drivers/net/ethernet/intel/ice/ice_main.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c > index 30814435f779..65de01f3a504 100644 > --- a/drivers/net/ethernet/intel/ice/ice_main.c > +++ b/drivers/net/ethernet/intel/ice/ice_main.c > @@ -3018,7 +3018,7 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data) > struct iidc_event *event; > > ena_mask &= ~ICE_AUX_CRIT_ERR; > - event = kzalloc(sizeof(*event), GFP_KERNEL); > + event = kzalloc(sizeof(*event), GFP_ATOMIC); > if (event) { > set_bit(IIDC_EVENT_CRIT_ERR, event->type); > /* report the entire OICR value to AUX driver */ What happens next is interesting... event->reg = oicr; ice_send_event_to_aux(pf, event); where: void ice_send_event_to_aux(struct ice_pf *pf, struct iidc_event *event) { struct iidc_auxiliary_drv *iadrv; if (!pf->adev) return; device_lock(&pf->adev->dev); iadrv = ice_get_auxiliary_drv(pf); if (iadrv && iadrv->event_handler) iadrv->event_handler(pf, event); device_unlock(&pf->adev->dev); } device_lock() takes a mutex, not something you should be doing in atomic context. So it looks to me, this handler really should be running in thread context... Andrew ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ice: Don't use GFP_KERNEL in atomic context @ 2022-01-16 21:42 ` Andrew Lunn 0 siblings, 0 replies; 7+ messages in thread From: Andrew Lunn @ 2022-01-16 21:42 UTC (permalink / raw) To: Christophe JAILLET Cc: Jesse Brandeburg, Tony Nguyen, David S. Miller, Jakub Kicinski, Shiraz Saleem, Dave Ertman, linux-kernel, kernel-janitors, intel-wired-lan, netdev On Sun, Jan 16, 2022 at 07:46:20PM +0100, Christophe JAILLET wrote: > ice_misc_intr() is an irq handler. It should not sleep. > > Use GFP_ATOMIC instead of GFP_KERNEL when allocating some memory. > > Fixes: 348048e724a0 ("ice: Implement iidc operations") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > I've never played a lot with irq handler. My understanding is that they > should never sleep. Hi Christophe Threaded interrupt handlers are allowed to sleep. However, this handler is not being used in such a way. So your are probably correct about GFP_KERNEL vs GFP_ATOMIC. > --- > drivers/net/ethernet/intel/ice/ice_main.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c > index 30814435f779..65de01f3a504 100644 > --- a/drivers/net/ethernet/intel/ice/ice_main.c > +++ b/drivers/net/ethernet/intel/ice/ice_main.c > @@ -3018,7 +3018,7 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data) > struct iidc_event *event; > > ena_mask &= ~ICE_AUX_CRIT_ERR; > - event = kzalloc(sizeof(*event), GFP_KERNEL); > + event = kzalloc(sizeof(*event), GFP_ATOMIC); > if (event) { > set_bit(IIDC_EVENT_CRIT_ERR, event->type); > /* report the entire OICR value to AUX driver */ What happens next is interesting... event->reg = oicr; ice_send_event_to_aux(pf, event); where: void ice_send_event_to_aux(struct ice_pf *pf, struct iidc_event *event) { struct iidc_auxiliary_drv *iadrv; if (!pf->adev) return; device_lock(&pf->adev->dev); iadrv = ice_get_auxiliary_drv(pf); if (iadrv && iadrv->event_handler) iadrv->event_handler(pf, event); device_unlock(&pf->adev->dev); } device_lock() takes a mutex, not something you should be doing in atomic context. So it looks to me, this handler really should be running in thread context... Andrew ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Intel-wired-lan] [PATCH] ice: Don't use GFP_KERNEL in atomic context 2022-01-16 21:42 ` Andrew Lunn @ 2022-01-18 20:01 ` Christophe JAILLET -1 siblings, 0 replies; 7+ messages in thread From: Christophe JAILLET @ 2022-01-18 20:01 UTC (permalink / raw) To: intel-wired-lan Le 16/01/2022 ? 22:42, Andrew Lunn a ?crit?: > On Sun, Jan 16, 2022 at 07:46:20PM +0100, Christophe JAILLET wrote: >> ice_misc_intr() is an irq handler. It should not sleep. >> >> Use GFP_ATOMIC instead of GFP_KERNEL when allocating some memory. >> >> Fixes: 348048e724a0 ("ice: Implement iidc operations") >> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> >> --- >> I've never played a lot with irq handler. My understanding is that they >> should never sleep. > > Hi Christophe > > Threaded interrupt handlers are allowed to sleep. However, this > handler is not being used in such a way. So your are probably correct > about GFP_KERNEL vs GFP_ATOMIC. > >> --- >> drivers/net/ethernet/intel/ice/ice_main.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c >> index 30814435f779..65de01f3a504 100644 >> --- a/drivers/net/ethernet/intel/ice/ice_main.c >> +++ b/drivers/net/ethernet/intel/ice/ice_main.c >> @@ -3018,7 +3018,7 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data) >> struct iidc_event *event; >> >> ena_mask &= ~ICE_AUX_CRIT_ERR; >> - event = kzalloc(sizeof(*event), GFP_KERNEL); >> + event = kzalloc(sizeof(*event), GFP_ATOMIC); >> if (event) { >> set_bit(IIDC_EVENT_CRIT_ERR, event->type); >> /* report the entire OICR value to AUX driver */ > > What happens next is interesting... > > > event->reg = oicr; > ice_send_event_to_aux(pf, event); > > where: > > void ice_send_event_to_aux(struct ice_pf *pf, struct iidc_event *event) > { > struct iidc_auxiliary_drv *iadrv; > > if (!pf->adev) > return; > > device_lock(&pf->adev->dev); > iadrv = ice_get_auxiliary_drv(pf); > if (iadrv && iadrv->event_handler) > iadrv->event_handler(pf, event); > device_unlock(&pf->adev->dev); > } > > device_lock() takes a mutex, not something you should be doing in > atomic context. > > So it looks to me, this handler really should be running in thread > context... > > Andrew > Ok, thanks for the explanation. ice_misc_intr() is registered with devm_request_irq(), so it is a handler that can't sleep. I guess that more consideration should be taken into account than only: s/devm_request_irq(handler)/devm_request_threaded_irq(NULL, handler)/ So I'll leave this one to people with the expected know-how. If my s/GFP_KERNEL/GFP_ATOMIC/ makes enough sense as-is, that's fine for me, but it looks that another solution is needed to fix the 2nd issue. CJ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] ice: Don't use GFP_KERNEL in atomic context @ 2022-01-18 20:01 ` Christophe JAILLET 0 siblings, 0 replies; 7+ messages in thread From: Christophe JAILLET @ 2022-01-18 20:01 UTC (permalink / raw) To: Andrew Lunn Cc: Jesse Brandeburg, Tony Nguyen, David S. Miller, Jakub Kicinski, Shiraz Saleem, Dave Ertman, linux-kernel, kernel-janitors, intel-wired-lan, netdev Le 16/01/2022 à 22:42, Andrew Lunn a écrit : > On Sun, Jan 16, 2022 at 07:46:20PM +0100, Christophe JAILLET wrote: >> ice_misc_intr() is an irq handler. It should not sleep. >> >> Use GFP_ATOMIC instead of GFP_KERNEL when allocating some memory. >> >> Fixes: 348048e724a0 ("ice: Implement iidc operations") >> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> >> --- >> I've never played a lot with irq handler. My understanding is that they >> should never sleep. > > Hi Christophe > > Threaded interrupt handlers are allowed to sleep. However, this > handler is not being used in such a way. So your are probably correct > about GFP_KERNEL vs GFP_ATOMIC. > >> --- >> drivers/net/ethernet/intel/ice/ice_main.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c >> index 30814435f779..65de01f3a504 100644 >> --- a/drivers/net/ethernet/intel/ice/ice_main.c >> +++ b/drivers/net/ethernet/intel/ice/ice_main.c >> @@ -3018,7 +3018,7 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data) >> struct iidc_event *event; >> >> ena_mask &= ~ICE_AUX_CRIT_ERR; >> - event = kzalloc(sizeof(*event), GFP_KERNEL); >> + event = kzalloc(sizeof(*event), GFP_ATOMIC); >> if (event) { >> set_bit(IIDC_EVENT_CRIT_ERR, event->type); >> /* report the entire OICR value to AUX driver */ > > What happens next is interesting... > > > event->reg = oicr; > ice_send_event_to_aux(pf, event); > > where: > > void ice_send_event_to_aux(struct ice_pf *pf, struct iidc_event *event) > { > struct iidc_auxiliary_drv *iadrv; > > if (!pf->adev) > return; > > device_lock(&pf->adev->dev); > iadrv = ice_get_auxiliary_drv(pf); > if (iadrv && iadrv->event_handler) > iadrv->event_handler(pf, event); > device_unlock(&pf->adev->dev); > } > > device_lock() takes a mutex, not something you should be doing in > atomic context. > > So it looks to me, this handler really should be running in thread > context... > > Andrew > Ok, thanks for the explanation. ice_misc_intr() is registered with devm_request_irq(), so it is a handler that can't sleep. I guess that more consideration should be taken into account than only: s/devm_request_irq(handler)/devm_request_threaded_irq(NULL, handler)/ So I'll leave this one to people with the expected know-how. If my s/GFP_KERNEL/GFP_ATOMIC/ makes enough sense as-is, that's fine for me, but it looks that another solution is needed to fix the 2nd issue. CJ ^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH] ice: Don't use GFP_KERNEL in atomic context 2022-01-16 18:46 ` Christophe JAILLET (?) (?) @ 2022-02-28 15:07 ` Kaliszczuk, Leszek -1 siblings, 0 replies; 7+ messages in thread From: Kaliszczuk, Leszek @ 2022-02-28 15:07 UTC (permalink / raw) To: Christophe JAILLET, Brandeburg, Jesse, Nguyen, Anthony L, David S. Miller, Jakub Kicinski, Saleem, Shiraz, Ertman, David M Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org > -----Original Message----- > From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > Sent: Sunday, January 16, 2022 7:46 PM > To: Brandeburg, Jesse <jesse.brandeburg@intel.com>; Nguyen, Anthony L > <anthony.l.nguyen@intel.com>; David S. Miller <davem@davemloft.net>; Jakub > Kicinski <kuba@kernel.org>; Saleem, Shiraz <shiraz.saleem@intel.com>; Ertman, > David M <david.m.ertman@intel.com> > Cc: linux-kernel@vger.kernel.org; kernel-janitors@vger.kernel.org; Christophe > JAILLET <christophe.jaillet@wanadoo.fr>; intel-wired-lan@lists.osuosl.org; > netdev@vger.kernel.org > Subject: [PATCH] ice: Don't use GFP_KERNEL in atomic context > > ice_misc_intr() is an irq handler. It should not sleep. > > Use GFP_ATOMIC instead of GFP_KERNEL when allocating some memory. > > Fixes: 348048e724a0 ("ice: Implement iidc operations") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > I've never played a lot with irq handler. My understanding is that they should never > sleep. So GFP_KERNEL must be avoided. So I guess that this patch is correct. > > However, I don't know if some special cases allow such allocation. > Any feedback/pointer to a good doc/explanation is welcome :) > --- > drivers/net/ethernet/intel/ice/ice_main.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Tested-by: Leszek Kaliszczuk <leszek.kaliszczuk@intel.com> ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-02-28 15:07 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-01-16 18:46 [Intel-wired-lan] [PATCH] ice: Don't use GFP_KERNEL in atomic context Christophe JAILLET 2022-01-16 18:46 ` Christophe JAILLET 2022-01-16 21:42 ` [Intel-wired-lan] " Andrew Lunn 2022-01-16 21:42 ` Andrew Lunn 2022-01-18 20:01 ` [Intel-wired-lan] " Christophe JAILLET 2022-01-18 20:01 ` Christophe JAILLET 2022-02-28 15:07 ` Kaliszczuk, Leszek
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.