Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3267698pxf; Mon, 22 Mar 2021 02:07:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsI7kwAJ/oDaBb25ziZxQPfvF9ZVjP/C8Si3O9ZJxPRZ2S8FOe6Y/PDcJbzg+r4Y6fw1EH X-Received: by 2002:a50:ef11:: with SMTP id m17mr24476885eds.151.1616404071626; Mon, 22 Mar 2021 02:07:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616404071; cv=none; d=google.com; s=arc-20160816; b=k9J39xm2f+SKvQUuApDtSDzxWae2aP89kmGQrWZ3hKLKP80EvbhYTXqhZ0vNLNcdPg X/uQXYxZljTOPHyABdPwiQ+ex+tPYAddGePEOr9X+7F8JkPhtgTsQc6CiOLI9Y0L3F+X fw/clk+25akvPxtYPxilCbuR/hbN2AnYToeWwCA9+wsB9J8EfwWktkR9ZIoiikZAwMdU HuaW3wrSBylOhn+IN4Du/WiGHzd5o6HKOBCPxUsirbw3APqbubEipkOK8lypuEIa6IoL DGsMgI+CAB6FV1CPg2RlULGAX6Xti8k++DWjr6HqM2Sv8M5eaZ3RcE+I4wkbGJ6WYSKK AfgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=y88xpMhgq5zhCFUMWKJhYJpArZg4gL5FM5u/M3LEbN0=; b=ng4aAJbQnQv6SAK9li5ytGgEZnnlxXyTQQltzHjfkg+hWB3XAPyg7hVbVMdeDcHHSh eKKLKeWYCfCyJxBAE3mwh39QuFjnEs4FKW4MJ2bjihudbx+alB5inwWTO16GrSUveCKW tTHTY+dQ07DJU+y4xDA7e3qfMxQsfP/eaqLcP1qvySLu60t0YtDtkUkZ4NRnFcJiQvFU /8zNrwvOQX3Z0Qz08+DcPSrFzBrlsOO3jpUDqNYor2duARKEzhq/h2t5vidbXicOIY3T yIXxjeE/VIEt0ygDr9Vt7Lrcxk9+HLEob2MwOXGnI4OSpG4xOuHEfsLCdvdgXSLtpQf8 CCaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=NG7ypSSQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rn17si3709074ejb.183.2021.03.22.02.07.29; Mon, 22 Mar 2021 02:07:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=NG7ypSSQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229472AbhCVJGe (ORCPT + 99 others); Mon, 22 Mar 2021 05:06:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229883AbhCVJGM (ORCPT ); Mon, 22 Mar 2021 05:06:12 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 484D6C061574 for ; Mon, 22 Mar 2021 02:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=y88xpMhgq5zhCFUMWKJhYJpArZg4gL5FM5u/M3LEbN0=; b=NG7ypSSQhKuIShw+4yjVov+Uxw ISo3H4b1YKU3thK66l5MuRg0hA+qGX28eHgUkWAqXnr6H7kJkR49zQZm6gwwerdOKX3IAERKulGlE F4RMGCb3Yt+ntR3VgoME/FqF56PbW/3r4fMpeOWeTM2xdemPZ4a44hy2gRF6GV6xNivkWUVWIhdlB 9zWvM1l/sSUOoFQaDmzsk03dU7qwJIYn3ciZx/k9gqv0tpuU4VicwKSkpz7vxw2OfMiLaWbkS6rE/ BRi4quh4eQAjEnISiOtj13/H57MnU7ntDPVPE7TN/FX804oY2h6pvPI3kvRhIYjiAHWwdy4jVFEHQ OC/R89Rw==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lOGVE-008FGi-S6; Mon, 22 Mar 2021 09:05:41 +0000 Date: Mon, 22 Mar 2021 09:05:36 +0000 From: Matthew Wilcox To: Antoine Tenart Cc: kernel test robot , "David S. Miller" , Alexander Duyck , LKML , Linux Memory Management List , 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 Message-ID: <20210322090536.GK1719932@casper.infradead.org> References: <20210322083553.GI32426@xsang-OptiPlex-9020> <161640335063.3537.6668586361113979688@kwain.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <161640335063.3537.6668586361113979688@kwain.local> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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;