From owner-dev-commits-src-all@freebsd.org Fri Jan 1 18:52:36 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 DCDFE4D0E5C; Fri, 1 Jan 2021 18:52:36 +0000 (UTC) (envelope-from rlibby@gmail.com) Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) (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 4D6vKJ131Tz3hpc; Fri, 1 Jan 2021 18:52:35 +0000 (UTC) (envelope-from rlibby@gmail.com) Received: by mail-qt1-f181.google.com with SMTP id y15so14646471qtv.5; Fri, 01 Jan 2021 10:52:35 -0800 (PST) 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=UmukHAZpllE1wTZ7WG6M/JOUT+Zg1HUfg0PavS3zVe8=; b=G0291ZXCrklO8cJFHqw0MkjCLL1WZTulR0XvRhB/+GcruRZr1tilLmY4ekezTwtcm3 vHEEJy7R1HS1ieQRnzaOo3ZincDfWcUp9EYRtcgwImS4E9CpEA7rvD1obxYeDoFy2gga 1NkUJ/hBVOPmUAS2UjeIlR96Y40vR3+0igIzYct+/UkuYqbTt/I15gK6tBVbrUbRtyzZ W3Y6A7rT3mCp1RS4gN4IbPVEYWpKPgb9XiLOvWmUiXQj043FMKNFOa7XHGWpip8jMiW7 D34LG0UXhEa5svuPiveOd2BdS79NHIM8nwWWDtnLWSs2Vlk6BuKen1yWYPFtLsk0q3ZY qTJA== X-Gm-Message-State: AOAM531stTglPCikU5e4x74QDNs1m2lQ+zTWCgtd3x8Z5KcbqvBDPJi+ 9C78XpHWLKFgtNqlYKlWM3CzxLHLBsg= X-Google-Smtp-Source: ABdhPJw//ZpfT1t9XGDp1454byyP3OQEuPsgNTTLVRqjAzc+aT4n4Xfa/h1uUdpNdVrRLozL7RnVYQ== X-Received: by 2002:ac8:5c93:: with SMTP id r19mr61868331qta.107.1609527154967; Fri, 01 Jan 2021 10:52:34 -0800 (PST) Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com. [209.85.160.175]) by smtp.gmail.com with ESMTPSA id o29sm32776175qtl.7.2021.01.01.10.52.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 Jan 2021 10:52:34 -0800 (PST) Received: by mail-qt1-f175.google.com with SMTP id h19so14622982qtq.13; Fri, 01 Jan 2021 10:52:34 -0800 (PST) X-Received: by 2002:aed:2088:: with SMTP id 8mr48003996qtb.174.1609527154155; Fri, 01 Jan 2021 10:52:34 -0800 (PST) MIME-Version: 1.0 References: <202012312103.0BVL3dGu073808@gitrepo.freebsd.org> In-Reply-To: From: Ryan Libby Date: Fri, 1 Jan 2021 10:52:23 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: git: 942951ba46ec - main - uma dbg: catch more corruption with atomics To: meloun.michal@gmail.com Cc: src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: multipart/mixed; boundary="00000000000047bf4105b7db3eab" X-Rspamd-Queue-Id: 4D6vKJ131Tz3hpc X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of rlibby@gmail.com designates 209.85.160.181 as permitted sender) smtp.mailfrom=rlibby@gmail.com X-Spamd-Result: default: False [-0.83 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; HAS_ATTACHMENT(0.00)[]; MIME_BASE64_TEXT_BOGUS(1.00)[]; RCVD_COUNT_THREE(0.00)[4]; RWL_MAILSPIKE_GOOD(0.00)[209.85.160.181:from]; MIME_BASE64_TEXT(0.10)[]; FREEMAIL_TO(0.00)[gmail.com]; FORGED_SENDER(0.30)[rlibby@freebsd.org,rlibby@gmail.com]; MIME_TRACE(0.00)[0:+,1:+,2:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; R_DKIM_NA(0.00)[]; FROM_NEQ_ENVFROM(0.00)[rlibby@freebsd.org,rlibby@gmail.com]; ARC_NA(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[209.85.160.181:from]; FREEFALL_USER(0.00)[rlibby]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[multipart/mixed,text/plain,text/x-patch]; DMARC_NA(0.00)[freebsd.org]; NEURAL_SPAM_SHORT(0.07)[0.075]; SPAMHAUS_ZRD(0.00)[209.85.160.181:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[209.85.160.181:from]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[dev-commits-src-all,dev-commits-src-main] 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: Fri, 01 Jan 2021 18:52:36 -0000 --00000000000047bf4105b7db3eab Content-Type: text/plain; charset="UTF-8" On Fri, Jan 1, 2021 at 5:46 AM Michal Meloun wrote: > > > > On 31.12.2020 22:03, Ryan Libby wrote: > > The branch main has been updated by rlibby: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=942951ba46ecd5ebab18de006a24dc52e2d3f745 > > > > commit 942951ba46ecd5ebab18de006a24dc52e2d3f745 > > Author: Ryan Libby > > AuthorDate: 2020-12-31 21:02:45 +0000 > > Commit: Ryan Libby > > CommitDate: 2020-12-31 21:02:45 +0000 > > > > uma dbg: catch more corruption with atomics > > > > Use atomic testandset and testandclear to catch concurrent double free, > > and to reduce the number of atomic operations. > > > > Submitted by: jeff > > Reviewed by: cem, kib, markj (all previous version) > > Sponsored by: Dell EMC Isilon > > Differential Revision: https://reviews.freebsd.org/D22703 > Unfortunately, this broke arm and arm64 kernel with random > 'duplicate alloc'/'duplicate free' panics. > > Michal > Thanks for the report. It's probably going to be several hours before I can dig into this properly. A GENERIC-NODEBUG kernel should avoid the problem. >From a quick scan of source, it looks to me like arm64's atomic_testand{set,clear}_64 are broken because of a wrong mask value under _ATOMIC_TEST_OP_IMPL(64, ...). If you would like to test a patch, you could try the one attached (only compile tested on my end). Ryan > > --- > > sys/vm/uma_core.c | 9 ++++----- > > 1 file changed, 4 insertions(+), 5 deletions(-) > > > > diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c > > index a0192642205d..39c846effac8 100644 > > --- a/sys/vm/uma_core.c > > +++ b/sys/vm/uma_core.c > > @@ -5392,10 +5392,10 @@ uma_dbg_alloc(uma_zone_t zone, uma_slab_t slab, void *item) > > keg = zone->uz_keg; > > freei = slab_item_index(slab, keg, item); > > > > - if (BIT_ISSET(keg->uk_ipers, freei, slab_dbg_bits(slab, keg))) > > + if (BIT_TEST_SET_ATOMIC(keg->uk_ipers, freei, > > + slab_dbg_bits(slab, keg))) > > panic("Duplicate alloc of %p from zone %p(%s) slab %p(%d)", > > item, zone, zone->uz_name, slab, freei); > > - BIT_SET_ATOMIC(keg->uk_ipers, freei, slab_dbg_bits(slab, keg)); > > } > > > > /* > > @@ -5426,11 +5426,10 @@ uma_dbg_free(uma_zone_t zone, uma_slab_t slab, void *item) > > panic("Unaligned free of %p from zone %p(%s) slab %p(%d)", > > item, zone, zone->uz_name, slab, freei); > > > > - if (!BIT_ISSET(keg->uk_ipers, freei, slab_dbg_bits(slab, keg))) > > + if (!BIT_TEST_CLR_ATOMIC(keg->uk_ipers, freei, > > + slab_dbg_bits(slab, keg))) > > panic("Duplicate free of %p from zone %p(%s) slab %p(%d)", > > item, zone, zone->uz_name, slab, freei); > > - > > - BIT_CLR_ATOMIC(keg->uk_ipers, freei, slab_dbg_bits(slab, keg)); > > } > > #endif /* INVARIANTS */ > > > > --00000000000047bf4105b7db3eab Content-Type: text/x-patch; charset="US-ASCII"; name="0001-arm64-fix-mask-in-atomic_test-64-ops.patch" Content-Disposition: attachment; filename="0001-arm64-fix-mask-in-atomic_test-64-ops.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kjemqbwc0 RnJvbSA0ZmIxZDQxMjYzNmJmNmZlNTlkMDQ1N2U3ZGQxN2RhNWU1OWNlNTVmIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBSeWFuIExpYmJ5IDxybGliYnlARnJlZUJTRC5vcmc+CkRhdGU6 IEZyaSwgMSBKYW4gMjAyMSAxMDo0MzowMyAtMDgwMApTdWJqZWN0OiBbUEFUQ0hdIGFybTY0OiBm aXggbWFzayBpbiBhdG9taWNfdGVzdCA2NCBvcHMKClRoZXNlIG1hY3JvcyBnZW5lcmF0ZSBib3Ro IHRoZSAzMiBhbmQgNjQtYml0IG9wcyBidXQgdGhlIG1hc2sgd2FzIGhhcmQKY29kZWQgZm9yIDMy LWJpdCBvcHMuCi0tLQogc3lzL2FybTY0L2luY2x1ZGUvYXRvbWljLmggfCA0ICsrLS0KIDEgZmls ZSBjaGFuZ2VkLCAyIGluc2VydGlvbnMoKyksIDIgZGVsZXRpb25zKC0pCgpkaWZmIC0tZ2l0IGEv c3lzL2FybTY0L2luY2x1ZGUvYXRvbWljLmggYi9zeXMvYXJtNjQvaW5jbHVkZS9hdG9taWMuaApp bmRleCA5OWRkNzN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