From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753240AbcKUJht (ORCPT ); Mon, 21 Nov 2016 04:37:49 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:34641 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751264AbcKUJhr (ORCPT ); Mon, 21 Nov 2016 04:37:47 -0500 Date: Mon, 21 Nov 2016 17:37:53 +0800 From: Boqun Feng To: Peter Zijlstra Cc: "Reshetova, Elena" , "gregkh@linuxfoundation.org" , "keescook@chromium.org" , "will.deacon@arm.com" , "arnd@arndb.de" , "tglx@linutronix.de" , "mingo@kernel.org" , "hpa@zytor.com" , "dave@progbits.org" , "linux-kernel@vger.kernel.org" Subject: Re: [RFC][PATCH 7/7] kref: Implement using refcount_t Message-ID: <20161121093753.GH5227@tardis.cn.ibm.com> References: <20161114173946.501528675@infradead.org> <20161114174446.832175072@infradead.org> <2236FBA76BA1254E88B949DDB74E612B41C148C4@IRSMSX102.ger.corp.intel.com> <20161118113718.GP3117@twins.programming.kicks-ass.net> <20161121084428.GG5227@tardis.cn.ibm.com> <20161121090223.GE3102@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="TA4f0niHM6tHt3xR" Content-Disposition: inline In-Reply-To: <20161121090223.GE3102@twins.programming.kicks-ass.net> User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --TA4f0niHM6tHt3xR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Nov 21, 2016 at 10:02:23AM +0100, Peter Zijlstra wrote: > On Mon, Nov 21, 2016 at 04:44:28PM +0800, Boqun Feng wrote: > > On Fri, Nov 18, 2016 at 12:37:18PM +0100, Peter Zijlstra wrote: > > [snip] > > > + > > > +/* > > > + * Similar to atomic_inc(), will saturate at UINT_MAX and WARN. > > > + * > > > + * Provides no memory ordering, it is assumed the caller already has= a > > > + * reference on the object, will WARN when this is not so. > > > + */ > > > +static inline void refcount_inc(refcount_t *r) > > > +{ > > > + unsigned int old, new, val =3D atomic_read(&r->refs); > > > + > > > + for (;;) { > > > + WARN(!val, "refcount_t: increment on 0; use-after-free.\n"); > > > + > >=20 > > Do we want to put the address of @r into the WARN information? Which > > could help us locate the problematic object quickly. >=20 > I explicitly didn't do that because printing kernel addresses is > generally frowned upon. Also, random heap addresses are just that, > random. In most cases the backtrace is more informative. Fair enough ;-) Regards, Boqun --TA4f0niHM6tHt3xR Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAABCAAGBQJYMsBuAAoJEEl56MO1B/q46dEIAKnNR3Su5bxM6G8jj826KocK O2/2FO1WzNMzEEwctMFrnJc+QbUkYQ6KVfRLPQMmx4SArmbD/wsk6G3Z4dnkbsrs yh8c/8HGBuh5/GTtwcI2kBrrGT6AfATw6tWM1352SAEjpLDHAzrK7vYKLebG370x sBjmq2XBsRLbIJVbEfj+qTKTzDNoWdHkIVEFTTJe+LeIAHtYZIvtvct0KBQmbxUX vZavyl/RsmmcnN7D0yLFL9Gvy+ciF/+4zBOert57nxmsfJqEvqZ7FyraUkmHpSII 4g20aYRs3mbt09n/mPDGBhGQb+4rb17fQ8nb5cG1nd3GIeqDSR3pkFAMnlabQQU= =lR3u -----END PGP SIGNATURE----- --TA4f0niHM6tHt3xR--