From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50126C433C1 for ; Mon, 22 Mar 2021 14:33:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D6ACC6196C for ; Mon, 22 Mar 2021 14:33:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6ACC6196C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A49D06B00D4; Mon, 22 Mar 2021 10:14:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A20CE6B00D6; Mon, 22 Mar 2021 10:14:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8EBB46B00D7; Mon, 22 Mar 2021 10:14:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 6CDBA6B00D4 for ; Mon, 22 Mar 2021 10:14:42 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id D0B698249980 for ; Mon, 22 Mar 2021 14:33:32 +0000 (UTC) X-FDA: 77947753464.13.1BB06E9 Received: from mail-il1-f175.google.com (mail-il1-f175.google.com [209.85.166.175]) by imf01.hostedemail.com (Postfix) with ESMTP id 0FBED5001526 for ; Mon, 22 Mar 2021 14:33:11 +0000 (UTC) Received: by mail-il1-f175.google.com with SMTP id v3so15033516ilj.12 for ; Mon, 22 Mar 2021 07:33:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=N/cDRTAC1Vc+ZRykhyHXSrcA5favyfg0y6H7wgohyAQ=; b=gDrmLkEXOSWQNDk845SNHYSbKVwMnhfJCAiqRKHj6GIAhmr2f6RqYDrPhypk95aXzF gUZzLIQo/CbSNasomeR4f1RHkj9GuuMnvMke7FuxRZnTFlsCwijuue7VtzioqT5pvjUc 8LkexkLrPYrS304Y3wK8pTSRdZ2+HiNmbPtTzkHtJWB8LOtTp4aIScaiW+hXwkvEG7Kj Ui3RBcOK7nBbw1HqdRvRN9RG9iFF2unZT+AOWUSHqMDyseDOnFP4AIdcDicD3vDxGGOI DRa05+6dPerE1lBeSMObDtwekYhMmeL8E/Xkw5jHahlH8/kCqzYN1iAsP052Cd3r9uzX Uvgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=N/cDRTAC1Vc+ZRykhyHXSrcA5favyfg0y6H7wgohyAQ=; b=d0CioLS3uIvzM8uKKwg0sMSJDurar3/2/EbOBj/uuSVmN9UydJsRqXaDjpnleJAVFf SNT01NXns6zqsfwcCrUx5FGeragZ/Dj+YNjSCkwO7q3PALZo0bqvxNZyXzifPNOV88r6 o0rudd5tuhkaz0xxccS+/ycU558rBrmlwsGL7czbf+aFYkDe1J1HmR5z8wLQIEZ5sz0A OWvnr3rrGN2dMDXoYzS3XQ9tP+zH0GVa6FDRXyNaGkj6Sj+TWZ1nyYbp3oRLxldGQj6s TRFceGfA6QfADLJtYGK4MUNAxi/fggpktXKssXrlMPi5hDHBRXE9TBnxsALrWmB+anoD 4+rw== X-Gm-Message-State: AOAM532UGINpUxczjWlInfTlAs7FuLNvdwEcRTyE+QvkSTRSLK7Ndhlg HoRMn+5HvaEvXkFxyvK3NU/K5wbQpuLOPxCTcdM= X-Google-Smtp-Source: ABdhPJzzfiZ/qMRGQpJASxVzwtYpebwPvOmU60CU34jlZ8o1+2sYKqsFR/TDMIRtROiECm4+bDqDmQ7siEEoSJyHzfo= X-Received: by 2002:a05:6e02:1069:: with SMTP id q9mr241580ilj.97.1616423587457; Mon, 22 Mar 2021 07:33:07 -0700 (PDT) MIME-Version: 1.0 References: <20210322083553.GI32426@xsang-OptiPlex-9020> <161640335063.3537.6668586361113979688@kwain.local> <20210322090536.GK1719932@casper.infradead.org> <161640517096.3021.7957377947074787708@kwain.local> In-Reply-To: <161640517096.3021.7957377947074787708@kwain.local> From: Alexander Duyck Date: Mon, 22 Mar 2021 07:32:56 -0700 Message-ID: Subject: Re: [net] 5478fcd0f4: BUG:sleeping_function_called_from_invalid_context_at_include/linux/sched/mm.h To: Antoine Tenart Cc: Matthew Wilcox , kernel test robot , "David S. Miller" , LKML , Linux Memory Management List , lkp@lists.01.org, kbuild test robot , ltp@lists.linux.it Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: y5j576bci3y95jbfxegirj7cwaqysq18 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 0FBED5001526 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf01; identity=mailfrom; envelope-from=""; helo=mail-il1-f175.google.com; client-ip=209.85.166.175 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616423591-270087 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Mar 22, 2021 at 2:26 AM Antoine Tenart wrote: > > 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: > > > > > > 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; > > 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 I agree that the retry logic is probably unneeded. In addition we probably don't need GFP_ATOMIC as GFP_NOWAIT will probably be good enough as the allocation can fail and just return an -ENOMEM in the case of low memory. Thanks. - Alex