From owner-dev-commits-src-all@freebsd.org Fri Jan 1 13:46: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 DC2314C8B9D; Fri, 1 Jan 2021 13:46:14 +0000 (UTC) (envelope-from meloun.michal@gmail.com) Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) (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 4D6mWp3bQPz4qPL; Fri, 1 Jan 2021 13:46:14 +0000 (UTC) (envelope-from meloun.michal@gmail.com) Received: by mail-wm1-x32c.google.com with SMTP id a6so9023630wmc.2; Fri, 01 Jan 2021 05:46:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:reply-to:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=BVmFxyrP+HfEjrKL1qWOGKB7m4Cjzc0oCKK21Pq9RnE=; b=MCLNwK/Yv6rRgtpmzJ87UQViuiXrGZZcXyth1Czm4QKDIvq2Tck5C2B3atGKaY9ljw Die2VfNQu8ceEHM61nEXSefdTzDN6oztNZuvEi15WJ89VeJ11nR7ohsbBEEX557eNt9T 9i0L1vGHauFlfQUtAAwxOmGzvYZgVlslreklfsS65czgirhOl7IeOLDbPiimsbWZ1jm3 pgwh/LT+YhaFVmhFI+QkwehTYnDUZK5hKB2MoO4/jPgX85lRKqFjYh1l83zaL45CoNlU 6zhD3xzAozpNP3PKvPOipPahevqZxBAQciJ2kqqCoDgSx4YkpO4Oz869cN7uCVu4wriF GV2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:reply-to:subject:to:references:from :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=BVmFxyrP+HfEjrKL1qWOGKB7m4Cjzc0oCKK21Pq9RnE=; b=odbyNQjMH908+eoEyRc0nstXVQQO+EPgHjqpTUuMc+4NJMxt4DkcYVcchqA7n/EltF zaMumhLcYSq7EetLjQXe5ktIvgUtllGhVUkWEJKCk7d9QMD/ScO2loNmspuSnlRwaKRu wRzJJNJsYqBF9xHyZRKxoVI1I9FV8VxFv8qvwRoHmHkgMP46KpKjXGe8jFp6Sytadqw9 6AbIXtvQ4btAdj9Hes7vcCaYoHsaNXav1ksVact0MiuD9NFBeu2DZ2U0YG0ZMk4Qq8Iw FQHZKWzVKSmVkMGhdE5Jp6Jsa1ylWBfMB4UrEaXTeoFXeqs3j6XKhOr9mBPkpZk6RzXx HEqg== X-Gm-Message-State: AOAM531iDt0YgRvydsu1TgL+AxC53qYu+VSaAPJaBXeI8Y73ZEK3mNJ7 5Ux64pNn0SpOY+vUD9PA4xs9PDi4WdaCzg== X-Google-Smtp-Source: ABdhPJz7J2C/EyVMVz+MG1PVmVyuHpqAGSN7Aj8j7Q82NhMQgoLRMRbQWwCLon9tOLzaNeMxcWfiiQ== X-Received: by 2002:a1c:a583:: with SMTP id o125mr15629058wme.91.1609508772043; Fri, 01 Jan 2021 05:46:12 -0800 (PST) Received: from [88.208.79.100] (halouny.humusoft.cz. [88.208.79.100]) by smtp.gmail.com with ESMTPSA id k6sm17935217wmf.25.2021.01.01.05.46.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 Jan 2021 05:46:11 -0800 (PST) Sender: Michal Meloun Reply-To: meloun.michal@gmail.com Subject: Re: git: 942951ba46ec - main - uma dbg: catch more corruption with atomics To: Ryan Libby , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202012312103.0BVL3dGu073808@gitrepo.freebsd.org> From: Michal Meloun Message-ID: Date: Fri, 1 Jan 2021 14:46:13 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <202012312103.0BVL3dGu073808@gitrepo.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4D6mWp3bQPz4qPL X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; TAGGED_FROM(0.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: Fri, 01 Jan 2021 13:46:14 -0000 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 > --- > 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 */ > >