From owner-svn-src-head@freebsd.org Tue Feb 11 00:53:00 2020 Return-Path: Delivered-To: svn-src-head@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 A85722494FE; Tue, 11 Feb 2020 00:53:00 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from cell.glebi.us (glebi.us [162.251.186.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 48Gklc2xZHz4H5L; Tue, 11 Feb 2020 00:53:00 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.15.2/8.15.2) with ESMTPS id 01B0qpt4001575 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 10 Feb 2020 16:52:51 -0800 (PST) (envelope-from glebius@freebsd.org) Received: (from glebius@localhost) by cell.glebi.us (8.15.2/8.15.2/Submit) id 01B0qpiR001574; Mon, 10 Feb 2020 16:52:51 -0800 (PST) (envelope-from glebius@freebsd.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@freebsd.org using -f Date: Mon, 10 Feb 2020 16:52:51 -0800 From: Gleb Smirnoff To: Mateusz Guzik Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r357728 - head/sys/sys Message-ID: <20200211005251.GA1351@FreeBSD.org> References: <202002101352.01ADqQLh039003@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202002101352.01ADqQLh039003@repo.freebsd.org> User-Agent: Mutt/1.12.2 (2019-09-21) X-Rspamd-Queue-Id: 48Gklc2xZHz4H5L X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-6.00 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-0.999,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Feb 2020 00:53:00 -0000 On Mon, Feb 10, 2020 at 01:52:26PM +0000, Mateusz Guzik wrote: M> Author: mjg M> Date: Mon Feb 10 13:52:25 2020 M> New Revision: 357728 M> URL: https://svnweb.freebsd.org/changeset/base/357728 M> M> Log: M> Tidy up zpcpu_replace* M> M> - only compute the target address once M> - remove spurious type casting, zpcpu_get already return the correct type M> M> While here add missing newlines to other routines. M> M> Modified: M> head/sys/sys/pcpu.h M> M> Modified: head/sys/sys/pcpu.h M> ============================================================================== M> --- head/sys/sys/pcpu.h Mon Feb 10 13:24:14 2020 (r357727) M> +++ head/sys/sys/pcpu.h Mon Feb 10 13:52:25 2020 (r357728) M> @@ -245,32 +245,41 @@ extern struct pcpu *cpuid_to_pcpu[]; M> * If you need atomicity use xchg. M> * */ M> #define zpcpu_replace(base, val) ({ \ M> - __typeof(val) _old = *(__typeof(base))zpcpu_get(base); \ M> - *(__typeof(val) *)zpcpu_get(base) = val; \ M> + __typeof(val) *_ptr = zpcpu_get(base); \ M> + __typeof(val) _old; \ M> + \ M> + _old = *_ptr; \ M> + *_ptr = val; \ M> _old; \ M> }) I think this function must have only protected variant that asserts that curthread->td_critnest is on. zpcpu_get() sometimes can be used without critical section, when we are fine with getting a value from a different CPU. However, can't imagine a situation where migrating during a replace operation is acceptable. -- Gleb Smirnoff