All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Jesse Brandeburg <jesse.brandeburg@intel.com>,
	Tony Nguyen <anthony.l.nguyen@intel.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Shiraz Saleem <shiraz.saleem@intel.com>,
	Dave Ertman <david.m.ertman@intel.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org
Subject: Re: [PATCH] ice: Don't use GFP_KERNEL in atomic context
Date: Sun, 16 Jan 2022 22:42:41 +0100	[thread overview]
Message-ID: <YeSRUVmrdmlUXHDn@lunn.ch> (raw)
In-Reply-To: <40c94af2f9140794351593047abc95ca65e4e576.1642358759.git.christophe.jaillet@wanadoo.fr>

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

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Lunn <andrew@lunn.ch>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH] ice: Don't use GFP_KERNEL in atomic context
Date: Sun, 16 Jan 2022 22:42:41 +0100	[thread overview]
Message-ID: <YeSRUVmrdmlUXHDn@lunn.ch> (raw)
In-Reply-To: <40c94af2f9140794351593047abc95ca65e4e576.1642358759.git.christophe.jaillet@wanadoo.fr>

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

  reply	other threads:[~2022-01-16 21:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-16 18:46 [PATCH] ice: Don't use GFP_KERNEL in atomic context Christophe JAILLET
2022-01-16 18:46 ` [Intel-wired-lan] " Christophe JAILLET
2022-01-16 21:42 ` Andrew Lunn [this message]
2022-01-16 21:42   ` Andrew Lunn
2022-01-18 20:01   ` Christophe JAILLET
2022-01-18 20:01     ` [Intel-wired-lan] " Christophe JAILLET
2022-02-28 15:07 ` Kaliszczuk, Leszek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YeSRUVmrdmlUXHDn@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=davem@davemloft.net \
    --cc=david.m.ertman@intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jesse.brandeburg@intel.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=shiraz.saleem@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.