From owner-freebsd-net Fri Jul 12 15:45: 7 2002 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A312A37B49A for ; Fri, 12 Jul 2002 15:44:38 -0700 (PDT) Received: from wall.polstra.com (wall-gw.polstra.com [206.213.73.130]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0981C4492F for ; Fri, 12 Jul 2002 15:31:32 -0700 (PDT) (envelope-from jdp@polstra.com) Received: from vashon.polstra.com (vashon.polstra.com [206.213.73.13]) by wall.polstra.com (8.11.3/8.11.3) with ESMTP id g6CLwZe26390; Fri, 12 Jul 2002 14:58:35 -0700 (PDT) (envelope-from jdp@vashon.polstra.com) Received: (from jdp@localhost) by vashon.polstra.com (8.12.4/8.12.4/Submit) id g6CLwZax009408; Fri, 12 Jul 2002 14:58:35 -0700 (PDT) (envelope-from jdp) Date: Fri, 12 Jul 2002 14:58:35 -0700 (PDT) Message-Id: <200207122158.g6CLwZax009408@vashon.polstra.com> To: net@freebsd.org From: John Polstra Cc: bmilekic@unixdaemons.com Subject: Re: mbuf external buffer reference counters In-Reply-To: <20020712142021.A44645@unixdaemons.com> References: <20020711162026.A18717@unixdaemons.com> <200207121803.g6CI3je9008944@vashon.polstra.com> <20020712142021.A44645@unixdaemons.com> Organization: Polstra & Co., Seattle, WA Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org In article <20020712142021.A44645@unixdaemons.com>, Bosko Milekic wrote: > > I've thought about the cache issue with regards to the ref. counts > before, actually, and initially, I also thought the exact same thing > as you bring up here. However, there are a few things you need to > remember: > > 1) SMP; counters are typically referenced by several different threads > which may be running on different CPUs at any given point in time, and > this means that we'll probably end up having corresponding cache lines > invalidated back and forth anyway; Agreed. The PII and newer CPUs do have some short cuts built in that mitigate this somewhat by doing direct cache-to-cache updates in the SMP case. But quantitatively I don't know how much that helps. > 2) Using more cache lines may not be better overall, we may be doing > write-backs of other data already there; in any case, we would really > have to measure this; The research that led to the slab allocator demonstrated pretty conclusively that, at least in general, it's better to spread out the usage across all cache lines rather than compete for just a few. Measurements trump research, though, as long as the measurements reflect real-world usage patterns. If you decide to pack the refcounts into the clusters themselves, it might be better to put the recount at the front of each cluster, and offset the packet data by 16 bytes to make room for it. That way, the reference count would be in the same cache line as the first part of the packet header -- a cache line which is almost certain to be accessed (though probably not dirtied) anyway. > 3) By far the most important: all modifications to the ref. count are > atomic, bus-locked, ops. I spoke to Peter a little about this and > although I'm not 100% sure, we think that bus-locked > fetch-inc/dec-stores need the bus anyway. If that's the case, > then we really don't care about whether or not they get cached, right? I'm afraid I don't know the answer to that. The majority of systems will be uniprocessor for a good long time, and I would hate to see their performance sacrificed needlessly. John -- John Polstra John D. Polstra & Co., Inc. Seattle, Washington USA "Disappointment is a good sign of basic intelligence." -- Chögyam Trungpa To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message