From owner-freebsd-arch@FreeBSD.ORG Wed Jun 5 00:12:42 2013 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 768E2FD7; Wed, 5 Jun 2013 00:12:42 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail104.syd.optusnet.com.au (mail104.syd.optusnet.com.au [211.29.132.246]) by mx1.freebsd.org (Postfix) with ESMTP id 3E6851844; Wed, 5 Jun 2013 00:12:41 +0000 (UTC) Received: from c122-106-156-23.carlnfd1.nsw.optusnet.com.au (c122-106-156-23.carlnfd1.nsw.optusnet.com.au [122.106.156.23]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id BA577420B54; Wed, 5 Jun 2013 09:52:25 +1000 (EST) Date: Wed, 5 Jun 2013 09:52:24 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Konstantin Belousov Subject: Re: aio_mlock(2) system call In-Reply-To: <20130604191152.GW3047@kib.kiev.ua> Message-ID: <20130605093622.L11224@besplex.bde.org> References: <20130603100618.GH67170@FreeBSD.org> <20130603161255.GM3047@kib.kiev.ua> <20130604113035.GV67170@glebius.int.ru> <20130604191152.GW3047@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.0 cv=e/de0tV/ c=1 sm=1 a=kj9zAlcOel0A:10 a=PO7r1zJSAAAA:8 a=JzwRw_2MAAAA:8 a=sLyT4IyXTxYA:10 a=a3KUWG958rLjXTh994YA:9 a=CjuIK1q_8ugA:10 a=ebeQFi2P/qHVC0Yw9JDJ4g==:117 Cc: arch@freebsd.org, Gleb Smirnoff X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2013 00:12:42 -0000 On Tue, 4 Jun 2013, Konstantin Belousov wrote: > On Tue, Jun 04, 2013 at 03:30:35PM +0400, Gleb Smirnoff wrote: >> Updated patch. >> > I have no further comments. > > You might want to make the switch of double casts to DEVOLATILE() > in the other parts of vfs_aio.c as separate commit. DEVOLATILE() should only be committed to /dev/null. It masks API bugs. An ordinary cast is sufficiently ugly and doesn't break detection of the bugs by -Wcast-qual. If a variable is actually volatile, then casting away its volatile'ness breaks it. The breakage is larger than with casting away const. But I think that with aio, the bug is using the application API in the kernel. The buffer is volatile in userland but isn't really volatile in the kernel (no more than any buffer that may be written to by DMA. Others are mostly not declared volatile). uio has sort of the opposite problem. It is older than const and void, so it cannot use them. More fundamentally, it only has a single i/o pointer so the pointer cannot be const since it is used for input. But when writing, the source buffer may be const or even volatile. Its pointer cannot be assigned to the uio pointer without casting away qualifiers. Bruce