From owner-dev-commits-src-all@freebsd.org Thu Mar 11 21:07:14 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 745FF5ACDC4; Thu, 11 Mar 2021 21:07:14 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DxM2p2Fx1z3v29; Thu, 11 Mar 2021 21:07:14 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-lj1-x235.google.com with SMTP id f16so3985790ljm.1; Thu, 11 Mar 2021 13:07:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=jxxviOhMpR+zatahLOz7lsjVuNN2lCjSSN92wag8JA4=; b=huid5XpDTyfib/GC3t37OSavxZiajLWvgn2CozvGNIq3FCNXL0CrmcextsjEbDs4hg w0dCX3+gmigQn1hUUy/qTMOpsZKj0i/Z4MvcEgjt7MXgUtLR7RW5Hiu6H9dAWjA+1sRp iAOzWIriC35XlEl+IGzBcLba0iZYpah335ZjPUfX2ZJVU7p+MRv6dKCLHBqUVS/JK/e5 6bO44UvqPbiEsfv2e8tXVVvNpLH0VnRuL8nm1+n8DRZ4KhhfKtLPAva3dCPTe5BWLHDu Kk+rb66gC6LeHE2FYcP5FlJl+gfIDtK5ZNU4hmiOYRifUZfoNcRJfDsUQVofiyQT0UJh zdbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=jxxviOhMpR+zatahLOz7lsjVuNN2lCjSSN92wag8JA4=; b=tfTLqn8rDiKJ0Dch48AP1PR+7V84E/n75FJdwLgms3qF/kCtx3ONqs2K7F3feHjI2H dPWxfPsA0ufbVP/O3YFNQYW3gaJMFL6T37Dm8tgmhQccZX8xRd7cAw/HUmjGKNgfYJkq gbIS0oyxQz0B0nN8Bv0nry5SKqM841EEqg5mE+9HzhhTsEO5GjGXdPo7EdIOUrGVPvik VkbBk5aet+vFhsfAyz1ICycf+izIPMAQRntdLaK0bFvGEKHCiXB3bw3bCbS4FBm/gHGT DCoYKWrWtUOY9FQ4J7KrDk9CmCC4j/BVbQis45gq6bksSJ6F8lkoTxGg77WXMoTd/oXR hpXQ== X-Gm-Message-State: AOAM532u/OOpH6/8glQM270qOvuc7PhPGeFYHzEipISXmjk9HAqbWTh/ ACWEctzaVuxPrn0c+m2gjLKhCn9Tz58BlPiDUc3YfnlP7Ug= X-Google-Smtp-Source: ABdhPJw3NtTCmKS9zZZmzpEWzNO/RDgoh/QDU/H4qTzkrhDLcemFbxljHrSbFS+9ak3f4hcW4H2A8KXbkIoIgBgB3U4= X-Received: by 2002:a2e:534a:: with SMTP id t10mr426250ljd.499.1615496832143; Thu, 11 Mar 2021 13:07:12 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a2e:b54e:0:0:0:0:0 with HTTP; Thu, 11 Mar 2021 13:07:11 -0800 (PST) In-Reply-To: <8e37c710-bd9d-6fe0-0263-4efeabfd9beb@FreeBSD.org> References: <202103091117.129BHOZa042851@gitrepo.freebsd.org> <8e37c710-bd9d-6fe0-0263-4efeabfd9beb@FreeBSD.org> From: Mateusz Guzik Date: Thu, 11 Mar 2021 22:07:11 +0100 Message-ID: Subject: Re: git: 1ae20f7c70ea - main - kern: malloc: fix panic on M_WAITOK during THREAD_NO_SLEEPING() To: John Baldwin Cc: Kyle Evans , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4DxM2p2Fx1z3v29 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Mar 2021 21:07:14 -0000 On 3/11/21, John Baldwin wrote: > On 3/10/21 3:57 AM, Mateusz Guzik wrote: >> There is something very wrong going on here. >> >> Key thing to note is that malloc is ultimately a wrapper around >> uma_zalloc. Whatever asserts you may want to add to malloc to catch >> problems sooner, should also present in uma. >> >> uma has the following: >> >> if (flags & M_WAITOK) { >> WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, >> "uma_zalloc_debug: zone \"%s\"", zone->uz_name); >> } > > This warns about holding locks, not about TD_NO_SLEEPING. Witness' role > is to check lock orders and warn about invalid operations when holding > certain locks. It does not currently verify anything about other > inhibitions > like TD_NO_SLEEPING. See, e.g. the list of assertions in userret() which > includes a WITNESS_WARN in addition to several other checks (including > TD_NO_SLEEPING). Arguably we should just move the TD_NO_SLEEPING check > from malloc() to here along with the td_intr_nesting_level. Any case > where you can't use malloc() with M_WAITOK you can't use uma with M_WAITOK > either. > My point is that the witness check is clearly deficient even ignoring uma -- there are other places which do this and fail to properly check if going off cpu is allowed. In fact, looks like the TD_NO_SLEEPING stuff is already not properly checked for when taking sleepable locks. >> This code used to execute prior to this commit and fail to catch the >> problems which got reported already. >> >> In other words: >> - WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK is incomplete in terms of >> internals its internals >> - the above should be in malloc, perhaps after being abstracted into a >> an assert-helper >> - fixing witness deficiency will probably find a slew of new problems >> - this should remain as a warning (maybe rate-limited) for the foreseable >> future > > I don't know that we've had so many issues that we can't just fix them on > HEAD right now vs having to make this a warning instead of keeping it as > a panic. > > -- > John Baldwin > -- Mateusz Guzik