Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754326AbcKUQBQ (ORCPT ); Mon, 21 Nov 2016 11:01:16 -0500 Received: from merlin.infradead.org ([205.233.59.134]:52290 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753636AbcKUQBP (ORCPT ); Mon, 21 Nov 2016 11:01:15 -0500 Date: Mon, 21 Nov 2016 17:00:59 +0100 From: Peter Zijlstra To: "Reshetova, Elena" Cc: David Windsor , Alexei Starovoitov , Kees Cook , Greg KH , Will Deacon , Arnd Bergmann , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , LKML , Daniel Borkmann Subject: Re: [RFC][PATCH 2/7] kref: Add kref_read() Message-ID: <20161121160059.GB3174@twins.programming.kicks-ass.net> References: <20161117085342.GB3142@twins.programming.kicks-ass.net> <20161117161937.GA46515@ast-mbp.thefacebook.com> <2236FBA76BA1254E88B949DDB74E612B41C14BB4@IRSMSX102.ger.corp.intel.com> <2236FBA76BA1254E88B949DDB74E612B41C15583@IRSMSX102.ger.corp.intel.com> <20161121154915.GB3124@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161121154915.GB3124@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 510 Lines: 12 On Mon, Nov 21, 2016 at 04:49:15PM +0100, Peter Zijlstra wrote: > > Speaking of non-fitting patterns. This one is quite common in > > networking code for refcounters: > > > > if (atomic_cmpxchg(&cur->refcnt, 1, 0) == 1) {} This is from > > net/netfilter/nfnetlink_acct.c, but there are similar ones in other > > places. > > Cute, but weird it doesn't actually decrement if not 1. Hurgh.. creative refcounting that. The question is how much of that do we want to support? It really must not decrement there.