From owner-svn-src-all@freebsd.org Tue Aug 4 18:11:06 2020 Return-Path: Delivered-To: svn-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 2DBDA37B754; Tue, 4 Aug 2020 18:11:06 +0000 (UTC) (envelope-from alc@rice.edu) Received: from mx0b-0010f301.pphosted.com (mx0b-0010f301.pphosted.com [148.163.153.244]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.pphosted.com", Issuer "Thawte RSA CA 2018" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BLjVd1QtNz4fkD; Tue, 4 Aug 2020 18:11:04 +0000 (UTC) (envelope-from alc@rice.edu) Received: from pps.filterd (m0102858.ppops.net [127.0.0.1]) by mx0b-0010f301.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 074HnfEN020473; Tue, 4 Aug 2020 13:11:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rice.edu; h=subject : to : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=ricemail; bh=r96/fbvc7txA5O/RlVDmOUs2K8dguw/4wF4NJKm3594=; b=KIXcxu3K1gA7HtimYvix2weDYMFqzdPrua+APywB7nqXlDq8i93e9LkmZbsREdIVAb7W d44MMJ5ElFcve9UO7oZ9jbaYmYFLi/Fvj1ZcHnnUhATWm9f5pVBV7M2q/oYlyh858mXl bauNRqjik6ZHZDtJKSQqccCey30CtNjCw2C9nzQEf04H/+QuasKa17lAvPrsFc9dyHcj UAJ6uTY+nZyEZ5EVpv8RaOo7DFun/uhns3mbfXWC270ESDJrWmJFFE5sgi7PUSaTqgWh +NWa5DBJry2hU/U7m3uH7u2u4L/cJE+WAn+iyVlyC2Euzh/9d3iXR+os/Dp3Y0KdiCad iA== Received: from mh1.mail.rice.edu (mh1.mail.rice.edu [128.42.201.20]) by mx0b-0010f301.pphosted.com with ESMTP id 32n60ckh3f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Aug 2020 13:11:03 -0500 Received-X: from mh1.mail.rice.edu (localhost.localdomain [127.0.0.1]) by mh1.mail.rice.edu (Postfix) with ESMTP id 1C1EE460B9F; Tue, 4 Aug 2020 13:11:03 -0500 (CDT) Received-X: from mh1.mail.rice.edu (localhost.localdomain [127.0.0.1]) by mh1.mail.rice.edu (Postfix) with ESMTP id 1AA5346099D; Tue, 4 Aug 2020 13:11:03 -0500 (CDT) X-Virus-Scanned: by amavis-2.7.0 at mh1.mail.rice.edu, auth channel Received-X: from mh1.mail.rice.edu ([127.0.0.1]) by mh1.mail.rice.edu (mh1.mail.rice.edu [127.0.0.1]) (amavis, port 10026) with ESMTP id WbdwhqVRf7zr; Tue, 4 Aug 2020 13:11:03 -0500 (CDT) Received: from 108-254-203-201.lightspeed.hstntx.sbcglobal.net (108-254-203-201.lightspeed.hstntx.sbcglobal.net [108.254.203.201]) (using TLSv1.2 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: alc) by mh1.mail.rice.edu (Postfix) with ESMTPSA id C189D46067B; Tue, 4 Aug 2020 13:11:02 -0500 (CDT) Subject: Re: svn commit: r363842 - head/sys/compat/linuxkpi/common/include/linux To: Emmanuel Vadot , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <202008041525.074FPNLh043749@repo.freebsd.org> From: Alan Cox Message-ID: <1c90911b-d5f6-f8b1-8f4d-97a88fa028bd@rice.edu> Date: Tue, 4 Aug 2020 13:11:02 -0500 User-Agent: Mozilla/5.0 (X11; FreeBSD i386; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <202008041525.074FPNLh043749@repo.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-08-04_04:2020-08-03, 2020-08-04 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1011 mlxscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=684 impostorscore=0 adultscore=0 malwarescore=0 bulkscore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008040131 X-Rspamd-Queue-Id: 4BLjVd1QtNz4fkD X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=rice.edu header.s=ricemail header.b=KIXcxu3K; dmarc=pass (policy=none) header.from=rice.edu; spf=pass (mx1.freebsd.org: domain of alc@rice.edu designates 148.163.153.244 as permitted sender) smtp.mailfrom=alc@rice.edu X-Spamd-Result: default: False [-5.22 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[rice.edu:s=ricemail]; NEURAL_HAM_MEDIUM(-1.00)[-1.005]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; R_SPF_ALLOW(-0.20)[+a:a32.spf.rice.edu]; NEURAL_HAM_LONG(-0.98)[-0.983]; DWL_DNSWL_LOW(-1.00)[rice.edu:dkim]; RCVD_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[rice.edu:+]; DMARC_POLICY_ALLOW(-0.50)[rice.edu,none]; NEURAL_HAM_SHORT(-1.14)[-1.135]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:22843, ipnet:148.163.152.0/22, country:US]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_IN_DNSWL_LOW(-0.10)[148.163.153.244:from] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 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: Tue, 04 Aug 2020 18:11:06 -0000 On 8/4/20 10:25 AM, Emmanuel Vadot wrote: > Author: manu > Date: Tue Aug 4 15:25:22 2020 > New Revision: 363842 > URL: https://svnweb.freebsd.org/changeset/base/363842 > > Log: > linuxkpi: Add clear_bit_unlock > > This calls clear_bit and adds a memory barrier. > > Sponsored by: The FreeBSD Foundation > > Reviewed by: hselasky > MFC after: 1 week > Differential Revision: https://reviews.freebsd.org/D25943 > > Modified: > head/sys/compat/linuxkpi/common/include/linux/bitops.h > > Modified: head/sys/compat/linuxkpi/common/include/linux/bitops.h > ============================================================================== > --- head/sys/compat/linuxkpi/common/include/linux/bitops.h Tue Aug 4 15:00:02 2020 (r363841) > +++ head/sys/compat/linuxkpi/common/include/linux/bitops.h Tue Aug 4 15:25:22 2020 (r363842) > @@ -275,6 +275,13 @@ find_next_zero_bit(const unsigned long *addr, unsigned > #define test_bit(i, a) \ > !!(READ_ONCE(((volatile const unsigned long *)(a))[BIT_WORD(i)]) & BIT_MASK(i)) > > +static inline void > +clear_bit_unlock(long bit, volatile unsigned long *var) > +{ > + clear_bit(bit, var); > + wmb(); For an unlock operation, the memory barrier should come before the clear_bit() call, not after.  See, for example, the alpha implementation in Linux.  Also, the correct "spelling" for this memory barrier in FreeBSD would be atomic_thread_fence_rel(). See, for example, the comment at the top of sys/amd64/include/atomic.h. > +} > + > static inline int > test_and_clear_bit(long bit, volatile unsigned long *var) > {