Article View: muc.lists.netbsd.source-changes
Article #8Re: CVS commit: src/sys/dev/usb
From: Taylor R Campbell
Date: Fri, 23 Oct 2026 17:33
Date: Fri, 23 Oct 2026 17:33
44 lines
3386 bytes
3386 bytes
> Date: Fri, 23 Oct 2026 09:48:40 -0700
> From: Jason Thorpe <thorpej@me.com>
>
> > On Oct 23, 2026, at 9:37 AM, Taylor R Campbell <riastradh@NetBSD.org> wrote:
> >
> > I think a flag is clearer than a magic ctor/dtor. The point here is
> > to change the behaviour of pool_cache_get (or pool_cache_put), but the
> > ctor/dtor explicitly _do not generally_ run on pool_cache_get/put (a
> > common misunderstanding I have seen, and had myself in the past).
> > Using them for this role seems likely to be even more confusing.
>
> Counter-argument: Use of a ctor guarantees that the object will be
> returned to the caller in the constructed state.
No, it doesn't?
Given
ctor(obj) { obj->foo = 1; }
the following can print either 1 or 2:
obj = pool_cache_get(pc);
obj->foo = 2;
pool_cache_put(pc, obj);
obj = pool_cache_get(pc);
printf("%d\n", obj->foo);
There _may_ be a dtor/ctor cycle between the pool_cache_put and the
pool_cache_get, but there's no _guarantee_ of that.
The only guarantee is that when a _backing page_ is allocated, the
ctor will run before pool_cache_get returns any objects from it, and
after pool_cache_put, the dtor will run before its _backing page_ is
freed.
In contrast, the proposal with PR_ZERO is to guarantee that it prints
0, every time.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID:
<20261023173333.B010F84DCA@mail.netbsd.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mailReferences:
<06836EF3-F904-47ED-9429-84E731D3BF24@me.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!2.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mail From: Taylor R Campbell <riastradh@NetBSD.org> Newsgroups: muc.lists.netbsd.source-changes Subject: Re: CVS commit: src/sys/dev/usb Date: Fri, 23 Oct 2026 17:33:32 +0000 Organization: Newsgate at muc.de e.V. Sender: source-changes-d-owner@NetBSD.org Approved: news-admin@muc.de Distribution: world Message-ID: <20261023173333.B010F84DCA@mail.netbsd.org> References: <06836EF3-F904-47ED-9429-84E731D3BF24@me.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2"; logging-data="16039"; mail-complaints-to="news-admin@muc.de" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netbsd.org; s=20240131; t=1792776816; bh=kghHHrSMCEpBkJ+hB9Li81qC2Y54l4ps/SUcWzy3WnQ=; h=To:CC:In-reply-to:Subject:Date:From:List-Id:List-Unsubscribe; b=svqP9431RZGS6lkEgBsJ14TfJyAK6z+l8um5MDA0kVebzJ6Mcz2VfJJplOLsvdohd fMicmyxqoVLElBnuVs90NTUnV+rVhYmGZ8QljEU9VB/7YlLKX6Oxg3gEGA9zbzgHlq Nl5+gVUw/0g0mN6QIvO4l/IYL4ZlwDvs7qlVE0D8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netbsd.org; s=20240131; t=1792776813; bh=kghHHrSMCEpBkJ+hB9Li81qC2Y54l4ps/SUcWzy3WnQ=; h=To:CC:In-reply-to:Subject:Date:From; b=BbWH1UlC6lpRbJgWNw6UVChVmauODiOVihKYhxuEeFNWI17R0acMJQ7RiLe9F7KFI VnjvZ30loLsdTzGNKdFTEBgxqp0v8uUROtBgXcwXyUY9j/euDleccLmHRep01ovqj2 Z/kJAXXwOy7o2qOIoWJBuCbu9dlEaVzCxNRGgMGg= In-reply-to: <06836EF3-F904-47ED-9429-84E731D3BF24@me.com> (thorpej@me.com) Precedence: bulk X-Newsgate-Id: f02c70b8849f+ X-No-Archive: Yes