From owner-freebsd-smp Fri Dec 15 9:47:20 2000 From owner-freebsd-smp@FreeBSD.ORG Fri Dec 15 09:47:18 2000 Return-Path: Delivered-To: freebsd-smp@freebsd.org Received: from berserker.bsdi.com (berserker.twistedbit.com [199.79.183.1]) by hub.freebsd.org (Postfix) with ESMTP id 1F40B37B400 for ; Fri, 15 Dec 2000 09:47:17 -0800 (PST) Received: from berserker.bsdi.com (cp@localhost.bsdi.com [127.0.0.1]) by berserker.bsdi.com (8.11.1/8.9.3) with ESMTP id eBFHlAF67343; Fri, 15 Dec 2000 10:47:10 -0700 (MST) (envelope-from cp@berserker.bsdi.com) Message-Id: <200012151747.eBFHlAF67343@berserker.bsdi.com> To: Julian Elischer Cc: smp@FreeBSD.ORG Subject: Re: atomic increment? In-reply-to: Your message of "Fri, 15 Dec 2000 08:26:24 PST." <3A3A4630.1905D5D@elischer.org> From: Chuck Paterson Date: Fri, 15 Dec 2000 10:47:10 -0700 Sender: cp@berserker.bsdi.com Sender: owner-freebsd-smp@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org } }> }> Please remember that atomic ops are really expensive, at }> least as expensive as acquiring a mutex. } }That depends on what you wnat to do with them! }If I wnat nothing but to write a 1 to a location, and know at teh same }time whether the previous contents was a 1 or a 0 then most machines }allow that to be done pretty cheaply (2 memory cycles - overlap) }A full blown mutex is at least that.. (at a minimum). } 2 locked memory cycles which are a huge number of ordinary instructions. A full blown mutex enter is the same price. }I DO NOT want to have people complaining that netgraph is too slow }because I have to to 600,000 mtx_enters 600,000 mtx_exit's }every second. And on top of that if there is a colision, I have to }queue the packet on a queue that is guarded in some way, so it's probably closer }to }800,000 per second. (don;t mention Gb ethernet) I fully agree. I just don't want people thinking that using atomic operations is a fix for this type of problem. You can't use mutices for each one, and you can't use atomic operations either. Chuck To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message