Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3278138pxf; Mon, 22 Mar 2021 02:27:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVafOFRmeSPYgtIFLbHC3Vh/b85QwV71oGSPfW2xsfqABDbVehcZhntNaVm6h8m9kPglru X-Received: by 2002:a17:906:1a4b:: with SMTP id j11mr18307194ejf.55.1616405276734; Mon, 22 Mar 2021 02:27:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616405276; cv=none; d=google.com; s=arc-20160816; b=W6eAn4oQMO+/cB9g+GwwPG0ID0lDoOFcMeSiM6gPkUexPJFVKdbcQZ1K9zOadG1Cvq IB0DHE52M1nJYWB/O0y3t/qfrZ7cZZw3dlEMtPjrGPYamnG249pJiMVk+qmDyLvjmZ54 dOlLapbPg/YFGW9h7zWCNiMPVJcBZM5NqnvhTWY1WLtuYRH/WMu6TGzNyeD0DyxKA/ta gReuBiuNW0iqh0qCZkEV6CMufSi9SO4HqZGf2wGBEzu8K16BQBgHgDI8yR42G1iaQlXp w+BCSurmwz+gtiR/b/POopYYhovLLHBnbmX6FBKA170tj4ZT997WeERCPtQL+0Fr2y5B QbVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:message-id:to:from:cc:subject:references :in-reply-to:content-transfer-encoding:mime-version:dkim-signature; bh=k4eD5nMMgy+gGpMoELnzMq03lsJoWQ9kjHbL1B9QolE=; b=FAWwHnBlbX+rNWAZolOZzTphgt7wMz8pMDOSDkQ5H7LVIiwm3Jq/KLZjgOxW7MHHj+ eX62My6m+ZKOMA3vGk10gjGOX+1upD09bUEIqB016/hW3B2VkLNvN+oO82wlS20Ccgjz jlk6uz2fJvDCL/MSPtcEg1aVfAleRqU+lzdG+taJ2zXWsxW8bLpGEVDsANj039/ooPCK bk7LVeWletAZ5ggDWY2jQ62pe1dAjlNENktfcy3vK1QIIo6rWqoYQrHmlxwCJF/ximKL fRGZ7UOdhxWsT/ZCVCRF9DkkPKQw9klYfrNV8ezwy4zsnvK9XzxUOWia/8cpJew9s+GP jJfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gnV0wWku; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ld16si11211494ejb.528.2021.03.22.02.27.34; Mon, 22 Mar 2021 02:27:56 -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=@kernel.org header.s=k20201202 header.b=gnV0wWku; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229915AbhCVJ0l (ORCPT + 99 others); Mon, 22 Mar 2021 05:26:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:39310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229771AbhCVJ0O (ORCPT ); Mon, 22 Mar 2021 05:26:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BD61A60233; Mon, 22 Mar 2021 09:26:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616405174; bh=E2bivXSoDRMs7r3zMZVSaMr3GBidjFUkYCkNU0ecnDs=; h=In-Reply-To:References:Subject:Cc:From:To:Date:From; b=gnV0wWkuwrUy4FWlG4rSqyC7z+OLCTzeqSL7gEv2kIA/p8ycJHV9+S0Dsklnv4QbU +SmVeBy8+KaUSfWOnGa+dQXgXZrNm4cyYNmOSRXisLoT+PLM4Zyt8WzubUgBldxEe/ M/mQdFQh8sPBOkPUbBz+Bkz0+xCC8aoq9Wx73xhNlQrt4JfyAZIXhArxZLTS/RZ5uj vjZ3quCo/y393PCXarHrJWBKOQFIJBNpBEZFQfpT2cVBbgFhDc6WaFNz6DyfDAs/T8 veh/Rx3ad7qNigCXWfVj73lRNZSbXbKv+SRlDG2QCpMWfXn9rhiUjQgw8w1vxXUhUe bV8Xid8fmCmQQ== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20210322090536.GK1719932@casper.infradead.org> References: <20210322083553.GI32426@xsang-OptiPlex-9020> <161640335063.3537.6668586361113979688@kwain.local> <20210322090536.GK1719932@casper.infradead.org> Subject: Re: [net] 5478fcd0f4: BUG:sleeping_function_called_from_invalid_context_at_include/linux/sched/mm.h 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 From: Antoine Tenart To: Matthew Wilcox Message-ID: <161640517096.3021.7957377947074787708@kwain.local> Date: Mon, 22 Mar 2021 10:26:11 +0100 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Matthew Wilcox (2021-03-22 10:05:36) > 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: > >=20 > > 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 =3D dev_maps ? dev_maps->nr_ids : > > (type =3D=3D XPS_CPUS ? nr_cpu_ids : dev->num_rx_queue= s); > > =20 > > - mask =3D bitmap_zalloc(nr_ids, GFP_KERNEL); > > + mask =3D bitmap_zalloc(nr_ids, GFP_ATOMIC); > > if (!mask) { > > rcu_read_unlock(); > > return -ENOMEM; >=20 > sysfs isn't a good reason to use GFP_ATOMIC. >=20 > try something like this: >=20 > - mask =3D bitmap_zalloc(nr_ids, GFP_KERNEL); > + mask =3D bitmap_zalloc(nr_ids, GFP_NOWAIT); > if (!mask) { > + int new_nr_ids; > + > rcu_read_unlock(); > - return -ENOMEM; > + mask =3D bitmap_zalloc(nr_ids, GFP_KERNEL); > + if (!mask) > + return -ENOMEM; > + rcu_read_lock(); > + dev_maps =3D 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 =3D dev_maps ? dev_maps->nr_ids : > + (type =3D=3D XPS_CPUS ? nr_cpu_ids : dev->num_rx_= queues); > + if (new_nr_ids < nr_ids) > + nr_ids =3D new_nr_ids; Thanks for the suggestion, I'll look into that. We could also just return -ENOMEM if the first allocation fails, retrying adds a lot of complexity. Antoine