Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5585411pxb; Mon, 14 Feb 2022 02:42:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTD0p+26KeXR0vBPPNbvlwvoPrV6ME0rM6Ky624tYj1SBIA/ofZuCsJWfXDwQQe3TVHBW2 X-Received: by 2002:a17:903:2284:: with SMTP id b4mr13612228plh.91.1644835319860; Mon, 14 Feb 2022 02:41:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644835319; cv=none; d=google.com; s=arc-20160816; b=AnFCS2UYl/1o2HlkaLYs+RYY9vG9CY7QQjoFvyhzpxix7bKvdNL3naFT8z3X4eBsax 3f80GK1RgUQe1UwK1hB1JW4myBQ/IX8nb3am6g0fAYnmhGzv3Tt+SvAjb5/VkFMr4mId SM7cNNGDFRYP+uMWhwn10yrgnY293Spvd7VVNvp01lZM3ymqbKH863Hbn3xpJxQlLnye dwR+NOD2ryhfOlRQWc+g2qVEj9hfWEtPBrVH5f5fym3CszuEtX7gcu6u9svkhyt1lO3f P3bHuvCrQyZ9xdkXc2ntuvpfPkZGD+mV657AQVhV3JN7M0C3Jr/iVzqvtOm5SbO+RgVN JvNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=+Ti2nk4zjdGL9qCHPI+wkzn/Zj6E+wju9LT/x+vfYco=; b=I9QecEfQ+R0Cs0k7K1bJrBhO8QTGSFU+3aALTTWV39FTFEXy1KdLrg4HR12eS1dxhp 6d7j8GJ6HqHqm0F6+SIDOj2iSCJgHUuaNkUou5XBZckshfVFdtSaDdMIdjGKKwBldXiX BMwtlYUzDzDzv82OIIFpb4d9docRc/Y4ku2a0Hok8G4frzHLJqdhyijvhuoQb/r3WPqe VfBmWD2P362yWxbpCCfqwn5JwRkBCf5iwzRVTmC3XL+hAFQy2gashJ9chqu1IS3K0L/v fsIR4UPluDYvgCLdadj+0PvtZ7m1+a+pa23IkCsG83D0h7zcFV2Oe+NVMlNat2Ln6k7O gXtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SJ6s05Ho; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d5si13693524plg.395.2022.02.14.02.41.44; Mon, 14 Feb 2022 02:41:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SJ6s05Ho; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233375AbiBMESL (ORCPT + 99 others); Sat, 12 Feb 2022 23:18:11 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:57394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232021AbiBMESI (ORCPT ); Sat, 12 Feb 2022 23:18:08 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 990793BA7E; Sat, 12 Feb 2022 20:18:03 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id e7so26631367ejn.13; Sat, 12 Feb 2022 20:18:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+Ti2nk4zjdGL9qCHPI+wkzn/Zj6E+wju9LT/x+vfYco=; b=SJ6s05Ho3VIte1Mhbqxs8Q947UYeapNKgS4LOd6Axu7Z8VB6gv8gJZ9AINJY1KcmOH h36FRJQk0+lQUzhfc62qbJmbP+xH3+aWmiVe+Jj7U22WCA3UXwIEauB5ZElfOFAgryyx yfhhEwpu2SM4gF7Gq38FM8mJszOxGLFqOjEwq3Ll/qeMlQLbRvCsB3VkLDaovvSoRX87 jlaEfHDD8lmDMWXLrVl3dar/7CbcBtrd/EEss3XFvivZBEmZSd1IHF9YCRbSyE4biYiY kVy0u87wlNNfdYFK0DHxCsS0FEURSP9j5NVjvuHqdFRNUJ8GPXMOxkSXKonydSxM4Kiv xDCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+Ti2nk4zjdGL9qCHPI+wkzn/Zj6E+wju9LT/x+vfYco=; b=Ms8lVNNsS2yxSaYc106sSwPLETi+WJa5Ghdj0d9+BERcKNurpFpz4t3yumi6reXsGF JHrn3XnI6o1MAczVmBeZuhViLKASkdf60aU+EQTydvO9e0Rduw0ECkCJjZgbXihkxAf3 wyYaq9My9yag2sJTXcdwnc9DFc6nOq/RjyhewpcYPtmk6xUt7c6HUylOe/9RI0zd1jAL XmQMb+Hdj8t1200IHHW4f1zFFf/SGQP0LgH3sHDd2dpJqX2CwKsngP8NCT9e3FQHPEqs fi/2zadOJlnIY9xu2QULBHJuelDBvfqsG48ICSyfmgXwcuxiZtX5Vc3oQzpw/goNhv6e 3buw== X-Gm-Message-State: AOAM532aTrKpMf5t+InD2NeStAqWHVGM0WqOOw3T763I0zYtrivTND4d fDF37ZBPVzum+TWxJ3DW08rf93ZfVjI8ZCjv6Cs= X-Received: by 2002:a17:906:77d5:: with SMTP id m21mr1660225ejn.486.1644725882017; Sat, 12 Feb 2022 20:18:02 -0800 (PST) MIME-Version: 1.0 References: <244218af-df6a-236e-0a52-268247dd8271@molgen.mpg.de> In-Reply-To: From: Zhouyi Zhou Date: Sun, 13 Feb 2022 12:17:50 +0800 Message-ID: Subject: Re: BUG: sleeping function called from invalid context at include/linux/sched/mm.h:256 To: Matthew Wilcox Cc: Paul Menzel , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Linux-MM , Peter Zijlstra , Josh Poimboeuf , Jason Baron , rcu , LKML , "Paul E. McKenney" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thank Matthew for correcting me On Sun, Feb 13, 2022 at 12:09 PM Matthew Wilcox wrote: > > On Sun, Feb 13, 2022 at 11:19:09AM +0800, Zhouyi Zhou wrote: > > I think the key to the problem lies in your attached console.log > > (pasted below), at times 0.014987 and 0.015995, I see there are two > > locks (cpu_hotplug_lock and jump_label_mutex) holded while > > kmem_cache_alloc calls __might_resched (0.023356). > > Those are both sleeping locks (a percpu_rwsem and mutex, respectively). > There is no problem with sleeping while holding a mutex or rwsem. From console.log, I see [ 0.012154][ T1] BUG: sleeping function called from invalid context at include/linux/sched/mm.h:256 [ 0.013128][ T1] in_atomic(): 0, irqs_disabled(): 1, non_block: 0, pid: 1, name: swapper/0 From ___might_sleep, I see 9506 if ((preempt_count_equals(preempt_offset) && !irqs_disabled() && 9507 !is_idle_task(current) && !current->non_block_count) || 9508 system_state == SYSTEM_BOOTING || system_state > SYSTEM_RUNNING || 9509 oops_in_progress) 9510 return; I guess it is irq_disable which cause the bug. Thanks Zhouyi