From owner-cvs-src Mon Mar 10 10:31: 3 2003 Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6734037B404; Mon, 10 Mar 2003 10:31:01 -0800 (PST) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4415543FBD; Mon, 10 Mar 2003 10:31:00 -0800 (PST) (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.8/8.12.8) with ESMTP id h2AIUxuP003040; Mon, 10 Mar 2003 19:30:59 +0100 (CET) (envelope-from phk@phk.freebsd.dk) To: John Baldwin Cc: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, Nate Lawson Subject: Re: cvs commit: src/sys/sys devicestat.h From: "Poul-Henning Kamp" In-Reply-To: Your message of "Mon, 10 Mar 2003 13:26:17 EST." Date: Mon, 10 Mar 2003 19:30:59 +0100 Message-ID: <3039.1047321059@critter.freebsd.dk> Sender: owner-cvs-src@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In message , John Baldwin writes: > >On 10-Mar-2003 Poul-Henning Kamp wrote: >> In message , Nate Lawson wri >> tes: >> >> Doesn't work: >> >> CPU0 (kernel) CPU1 (userland) >> >> increment seq >> start copy >> fiddle data >> end copy >> (copy is inconsistent) >> >> You need two sequence fields: >> >> CPU0 (kernel) CPU1 (userland) >> >> increment seq0 >> start copy >> fiddle data >> end copy >> increment seq1 >> (seq0 != seq1 indicates inconcistent data) >> >> Notice that to make it absolutely water-tight, the seq fields must >> be updated with appropriate write barriers and the order of the >> fields must be the opposite as the direction the copy is performed in. > >Correct. If you use: > > atomic_add_acq_int(&seq0, 1); > ... all the updates ... > atomic_add_rel_int(&seq1, 1); > >then you should have sufficient membars. Right, but even with that, I still need to make sure that the userland copy starts out by copying seq1 and finishes by copying seq0, and since that may depend on the mood of the compiler and the phase of the moon. This is disk statistics, it's not really worth that effort. The data in the structure will not get corrupted, bue one of our readings may. So what... -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-src" in the body of the message