From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Reding Subject: Re: [PATCH 0/6] drm: Introduce consistent reference counting APIs Date: Thu, 9 Feb 2017 21:39:51 +0100 Message-ID: <20170209203948.GA26089@mithrandir.ba.sec> References: <20170208182408.5442-1-thierry.reding@gmail.com> <87r337sbej.fsf@intel.com> <20170209170950.ejlvri3ie22aahqx@phenom.ffwll.local> <87y3xfclgq.fsf@intel.com> <20170209190741.46f72vgra7xwiiwz@phenom.ffwll.local> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0045240918==" Return-path: Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 62F3C6EBA8 for ; Thu, 9 Feb 2017 20:39:56 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id r18so4614763wmd.3 for ; Thu, 09 Feb 2017 12:39:56 -0800 (PST) In-Reply-To: <20170209190741.46f72vgra7xwiiwz@phenom.ffwll.local> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Daniel Vetter Cc: Daniel Vetter , dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============0045240918== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="VS++wcV0S1rZb1Fb" Content-Disposition: inline --VS++wcV0S1rZb1Fb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Feb 09, 2017 at 08:07:41PM +0100, Daniel Vetter wrote: > On Thu, Feb 09, 2017 at 07:39:33PM +0200, Jani Nikula wrote: > > On Thu, 09 Feb 2017, Daniel Vetter wrote: > > > On Thu, Feb 09, 2017 at 04:10:12PM +0200, Jani Nikula wrote: > > >> On Wed, 08 Feb 2017, Thierry Reding wrote: > > >> > This series introduces DRM reference counting APIs that are consis= tent > > >> > with other reference counting APIs in the kernel. They are also mu= ch > > >> > shorter. Compatibility aliases are added to keep existing code wor= king > > >> > and will stay in place until all users of the old APIs are gone. > > >>=20 > > >> I like it. > > >>=20 > > >> But it makes drm_connector_list_iter_{get,put} stick out like a sore > > >> thumb. Something for the TODO list I guess. > > > > > > Hm, why is that one the sore thumb now? Just because it's really long= ? It > > > does acquire/drop references behind the scenes, that's why I went wit= h the > > > _get/put postfixes ... > >=20 > > I think the assumption is that get/put work on an object, and you can > > get/put as many times as you like, as long as you keep them at > > balance. AFAICT this doesn't hold for iter. >=20 > Hm right. What else should we use instead? start/stop are confusing in the > context of list walking, create/destroy maybe? I rather like the _begin()/_end() suffix that I think iterators have in the C++ STL. Well, I guess it's really .end() and .begin() methods in C++. But the following reads rather nicely: drm_connector_list_iter_begin(dev, &iter); drm_for_each_connector_iter(connector, &iter) ... drm_connector_list_iter_end(&iter); Alternatively some other iterators simply use an _init() suffix to initialize the iterator. The kernel has a few of these, such as the of_phandle_iterator (see include/linux/of.h) or of_pci_range_parser (see include include/linux/of_address.h). EFI code uses _begin()/_end() in include/linux/efi.h, cgroups seems to have _start()/_end() in include/linux/cgroup.h. include/linux/klist.h uses klist_iter_init()/klist_iter_exit(). include/linux/rhashtable.h has rhashtable_walk_start()/rhashtable_walk_stop(). A quick grep also shows other variants, one of them being _first(), but those don't have an explicit end function. So there's quite a few options to choose from, but I guess that doesn't make it any easier. If this was a poll, my vote would go to _begin()/_end(). Thierry --VS++wcV0S1rZb1Fb Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAlic048ACgkQ3SOs138+ s6H07g//R0//R5llDAzB+puQAhSdNHgRll0OdCgOWBN6KFFFQfcJ++PAWlJmQfZR SeYC/lASuIcL2asnuBnbntxnB44VXBqakwyzt8/5nLxda54ldeBq/LIH0BOhyzYQ mK2tPt37QMW3X9HuSP7Z4isvYLPXiMtIfPy/e95QNpwULFti2x/Y86W2OaBkDtHz NURGRtuuocXtGc4KKWgEingMe2a1XqhxW7zvU12E3+mZMMxOxFMp6h3OK9k3niHh K8obyO95My4nl4xOuEUJ5WjPGUhQayWlZZb1HekILY+4Cx+xJtSpQ0VYNe1xukG3 /+RVP9f+bkWBOG1SkaMz7nHYhs9QxxKOa7DY2vpjSmxyDaaWaG6D0brV+DAsgm2U YuyFr1LZbpQtu31KRGHVgdNWNAg1Mh2olgaGGC4Tt67g2HdsS4PiQXTZymHYaHVB JntGmBYo2V1rpaUHdzZIoB8jiVGdS3yFDBZ8IkK/Q/ezkjB8mBbZr6U8MyFgXKiJ RHekspLW1w1gpV+wRLXFzLZ2hkGvTz4bxLlfCyWkISeq/pIPDQr5f/O94tHypZtd OhSGVIH0VMs8bur5v/6jt6UYtk7fINAZkK/tX9/jERqprHqUDZdr0jnoQFm9cUy1 qFhyIF/MVkP12DVhYItajIv3KJiSf2O6T+iCKkUz1IgfOm+qxqA= =ugAz -----END PGP SIGNATURE----- --VS++wcV0S1rZb1Fb-- --===============0045240918== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============0045240918==--