From owner-svn-src-all@freebsd.org Sat Oct 14 00:48:52 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AFB0DE316E2; Sat, 14 Oct 2017 00:48:52 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-qk0-x22e.google.com (mail-qk0-x22e.google.com [IPv6:2607:f8b0:400d:c09::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 711EA7F25A; Sat, 14 Oct 2017 00:48:52 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-qk0-x22e.google.com with SMTP id k123so6993450qke.3; Fri, 13 Oct 2017 17:48:52 -0700 (PDT) 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=JYP+bGdufTSW0oHxoVMiCBMU+GO+sK6BofgAzqc4jHc=; b=Ku/Z0w0XDbD9OxyYY/gXdNzGyRNt3augkmpyx/XSrbp9UtrYZ37y5TBXHrWsnx69uE /sCGi0cepUHKjbgX/eEIA5yRpxbRl2S5uKddkKqb/UpG0QMY2O4HJtEaW/zk9Rx36YyC +3TwDFSw/wlQfuoGp/ZMrnD7bKfay7Q6jhjFv9F7+xgJYSUzOeb3Sh+ov2LjIuqn/RxW D4lD/I+X7VZh7SjgCLOSMNYVCD9CeIWLu9e7UDtzP2J9rrt5GP3wL5wUky2urnAzifwU q0zcPtCSI05zi31jnKH9FjH/7/86t+2+iBwI7qMBYbTMX+qEHjE9VdxuIclyOiLXX8Lq vEsw== 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=JYP+bGdufTSW0oHxoVMiCBMU+GO+sK6BofgAzqc4jHc=; b=fcteHWjjaVgWILqZsguoWBbYOQslA81zZQrwYDq0pIyCksYQhX+XgO/oliHyGhzQRZ kggkCah/fZt9xwnSTr/tPDDljpqUJE+EIQLl6X5liRPuwm0JDdKYcBii7VWyJr9rCFDi 8jH039BqpYc9jvdiuse9ghO4dJ/Eam++g0MoRJ9DupFu8N/IEgTM03u/0zn5fae+4uuA HJrEw7+rxh5dME+8n3HAQuxk72daCARxOo1q4EHsuyCjUsctnSulGgNT3vp44BkMpVr1 fwDFMRfIG/Pz2FuA7GwoXXErqTOY/72hY4I4tEqIm9OCztENpTOk7hYZg2qMy4RFJqJs W1sA== X-Gm-Message-State: AMCzsaX5WtOmZQT4+9E6kyHDaY092Z90TV6K5TLr5SuwiARahAe02W6o vUZyO3NjcSi0sgjYIiIh7WAyDZBawWh8UmI9ecUs9A== X-Google-Smtp-Source: AOwi7QC9OmHJxCrn6dk1TB1TITye4ytY5nMkLgp4jGq+QK8NIAm2Py9ZO7+bh3zaEZSbPWC88umxpahhLd27aZDzn6s= X-Received: by 10.55.215.22 with SMTP id m22mr4671927qki.119.1507942131329; Fri, 13 Oct 2017 17:48:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.46.107 with HTTP; Fri, 13 Oct 2017 17:48:49 -0700 (PDT) In-Reply-To: <1507941050.8386.88.camel@freebsd.org> References: <201710132031.v9DKVueS089009@repo.freebsd.org> <1507941050.8386.88.camel@freebsd.org> From: Mateusz Guzik Date: Sat, 14 Oct 2017 02:48:49 +0200 Message-ID: Subject: Re: svn commit: r324609 - head/sys/sys To: Ian Lepore Cc: Svatopluk Kraus , Mateusz Guzik , "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Oct 2017 00:48:52 -0000 On Sat, Oct 14, 2017 at 2:30 AM, Ian Lepore wrote: > On Fri, 2017-10-13 at 23:38 +0200, Svatopluk Kraus wrote: > > MTX_UNOWNED is a flag. You did not change its value from 4 to 0, you > > removed it actually. I have very bad feeling about it. But maybe, it's > > really possible and in that case, a very good explanation should be > > provided. > > > > Svata > > > > The part that scares me is that DESTROYED may have been defined as > CONTESTED|UNOWNED for subtle and clever reasons lost in the mists of > time. Any of the places that are testing the MTX_CONTESTED bit may > have been relying somehow on the fact that a destroyed mutex has that > bit set. > > Then again, maybe Mateusz has carefully analyzed all this stuff, and we > should just relax. :) > > I highly doubt there was anything clever going on. Rather, someone wanted to somehow denote a destroyed mutex, but did not want to introduce an additional flag - they are not free since the field shares the value with the address of the owner. That is, adding flags requires increasing alignment of struct thread and that adds to memory usage. Thus they combined the flags in a way which can never happen under normal circumstances. mtx_destroy explicitly sets the value to MTX_DESTROYED, so there is no change here. MTX_UNOWNED is *not* used as a flag. If you grep the tree you will see it is only used in direct comparisons. That said, I reviewed all users again and a minor bug was introduced in owner_mtx (only used by dtrace). For some reason it grabs the owner, but the instead of checking if it grabbed anything it checks the flag (fixed in r324613). So that's my bad. Justification for the change was provided in the commit message: it makes .text smaller on amd64 and probably all architectures. -- Mateusz Guzik