linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Antoine Tenart <atenart@kernel.org>
Cc: kernel test robot <oliver.sang@intel.com>,
	"David S. Miller" <davem@davemloft.net>,
	Alexander Duyck <alexander.duyck@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux Memory Management List <linux-mm@kvack.org>,
	lkp@lists.01.org, lkp@intel.com, ltp@lists.linux.it
Subject: Re: [net]  5478fcd0f4: BUG:sleeping_function_called_from_invalid_context_at_include/linux/sched/mm.h
Date: Mon, 22 Mar 2021 09:05:36 +0000	[thread overview]
Message-ID: <20210322090536.GK1719932@casper.infradead.org> (raw)
In-Reply-To: <161640335063.3537.6668586361113979688@kwain.local>

On Mon, Mar 22, 2021 at 09:55:50AM +0100, Antoine Tenart wrote:
> I only had a quick look at this, but I think the issue should be fixed
> with:
> 
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index e16d54aabd4c..3ae3c20eb64c 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -1378,7 +1378,7 @@ static ssize_t xps_queue_show(struct net_device *dev, unsigned int index,
>         nr_ids = dev_maps ? dev_maps->nr_ids :
>                  (type == XPS_CPUS ? nr_cpu_ids : dev->num_rx_queues);
>  
> -       mask = bitmap_zalloc(nr_ids, GFP_KERNEL);
> +       mask = bitmap_zalloc(nr_ids, GFP_ATOMIC);
>         if (!mask) {
>                 rcu_read_unlock();
>                 return -ENOMEM;

sysfs isn't a good reason to use GFP_ATOMIC.

try something like this:

-       mask = bitmap_zalloc(nr_ids, GFP_KERNEL);
+       mask = bitmap_zalloc(nr_ids, GFP_NOWAIT);
        if (!mask) {
+               int new_nr_ids;
+
                rcu_read_unlock();
-               return -ENOMEM;
+               mask = bitmap_zalloc(nr_ids, GFP_KERNEL);
+               if (!mask)
+                       return -ENOMEM;
+               rcu_read_lock();
+               dev_maps = rcu_dereference(dev->xps_maps[type]);
+               /* if nr_ids shrank while we slept, do not overrun array.
+                * if it increased, we just won't show the new ones
+                */
+               new_nr_ids = dev_maps ? dev_maps->nr_ids :
+                       (type == XPS_CPUS ? nr_cpu_ids : dev->num_rx_queues);
+               if (new_nr_ids < nr_ids)
+                       nr_ids = new_nr_ids;



  reply	other threads:[~2021-03-22  9:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22  8:35 kernel test robot
2021-03-22  8:55 ` Antoine Tenart
2021-03-22  9:05   ` Matthew Wilcox [this message]
2021-03-22  9:26     ` Antoine Tenart
2021-03-22 14:32       ` Alexander Duyck

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=20210322090536.GK1719932@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=alexander.duyck@gmail.com \
    --cc=atenart@kernel.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=lkp@lists.01.org \
    --cc=ltp@lists.linux.it \
    --cc=oliver.sang@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox