From owner-svn-src-head@freebsd.org Sat Mar 3 12:09:31 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EDB1FF362A6; Sat, 3 Mar 2018 12:09:30 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail108.syd.optusnet.com.au (mail108.syd.optusnet.com.au [211.29.132.59]) by mx1.freebsd.org (Postfix) with ESMTP id 3D7437E1E9; Sat, 3 Mar 2018 12:09:29 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail108.syd.optusnet.com.au (Postfix) with ESMTPS id ABA8F1A47D4; Sat, 3 Mar 2018 23:09:21 +1100 (AEDT) Date: Sat, 3 Mar 2018 23:09:20 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Konstantin Belousov cc: Pedro Giffuni , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r330285 - head/sys/sys In-Reply-To: <20180303102106.GG3194@kib.kiev.ua> Message-ID: <20180303224422.U3460@besplex.bde.org> References: <201803021647.w22Gl2t7092316@repo.freebsd.org> <20180302181934.GF3194@kib.kiev.ua> <20180303130511.N1283@besplex.bde.org> <20180303102106.GG3194@kib.kiev.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=FNpr/6gs c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=kj9zAlcOel0A:10 a=8ggJXkvBAAAA:8 a=pKfNTG1ak-NQXwge5X8A:9 a=CjuIK1q_8ugA:10 a=GHEzSmbhvkB-cyu2CITy:22 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 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: Sat, 03 Mar 2018 12:09:31 -0000 On Sat, 3 Mar 2018, Konstantin Belousov wrote: > On Sat, Mar 03, 2018 at 01:47:41PM +1100, Bruce Evans wrote: >> On Fri, 2 Mar 2018, Konstantin Belousov wrote: >> >>> On Fri, Mar 02, 2018 at 12:43:34PM -0500, Pedro Giffuni wrote: >>>> ... >>>> I think use of _Nonnull attributes in the threading functions may also >>>> be a waste (I introduced them mostly to be compatible with Android). >>>> FWIW, Dragonfly sprinkled some restrict there recently: >>>> >>>> http://gitweb.dragonflybsd.org/dragonfly.git/commit/d33005aaee6af52c80428b59b52aee522c002492 >>>> >>>> Just in case someone is considering more cleanups. >>> >>> This is not a cleanup for me, but a needed change. Right now x86 >>> copyouts are implemented in asm, so whatever damage is done to the >>> prototypes, only effect is at the caller side. In my work, i386 copyouts >>> are done in C, so it starts matter. >> >> That seems slow, especially for small sizes as are common for syscall args >> (in 1 of my versions, copyin() of args is optimized to fuword() in a loop, >> and fuword() is optimized to not use pcb_onfault, so it is not much more >> than 1 memory access. However, in your i386 version this optimization >> would be negative since the slow part is switching the map, so fuword() >> should never be used to access multiple words). > Yes. I already explained it in private, the current choice for i386 is > either to be neglected very fast, or to get this change to still be a > Tier 1 32 bit platform. The change is to make 4/4g split for UVA/KVA. > In particular, the change ensures that it is possible to self-host i386 > for forthcoming years, which is not practical for armv7 now and would be > less so with clang grow. I use i386 since it is 10-20% faster than amd64 for my applications, and don't like changes that fix this by slowing down the fast case. My applications don't include clang. >> ... >>> Also I looked at the dragonfly commit because I become curious what do you >>> mean by threading functions. The first example was >>> int pthread_attr_getguardsize(const pthread_attr_t * __restrict, >>> - size_t *); >>> + size_t * __restrict); >>> POSIX agrees with the dragonfly change, but I do not understand it. >>> Aliasing rules already disallow the first and second arguments to point >>> to the same memory, because they have different types. >> >> (1) thread_attr_t is opaque, so the types might be the same. >> (2) pthread_attr_t might be a pointer to a struct/union containing a size_t. >> (3) perhaps other reasons. I'm not sure how 'restrict interacts with global >> variables or even it it prevents the interaction in (2). A previous >> discussion showed that const doesn't make types different enough to >> prevent aliasing. Similarly for volatile. >> >> Similarly for other pointers to {opaque, struct/union, or even integer} types. >> size_t can't be aliased to int, but it can be aliased to any unsigned type >> in C and to any unsigned type not smaller than uint16_t in POSIX (POSIX >> but not C requires u_char == uint8_t, so size_t can't be u_char in POSIX >> but it can be u_char in C). > > I can only summarize it as 'there is no use to have restrict on the > pthread_attr_getguardsize() arguments'. No, the summary is 'POSIX is correct to declare almost all arg pointers as restrict, since it is not useful for new APIs to allow aliases, and restrict must be used so that implementations can take advantage of this if they want'. Bruce