Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754573AbcKUPjY (ORCPT ); Mon, 21 Nov 2016 10:39:24 -0500 Received: from mga06.intel.com ([134.134.136.31]:47455 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754143AbcKUPjX (ORCPT ); Mon, 21 Nov 2016 10:39:23 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,675,1473145200"; d="scan'208";a="33143186" From: "Reshetova, Elena" To: David Windsor CC: Alexei Starovoitov , Peter Zijlstra , 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() Thread-Topic: [RFC][PATCH 2/7] kref: Add kref_read() Thread-Index: AQHSQEVANqFGs6lR9EeBqDMncz0eH6Dc36YAgAB8mgCAAaU8QIAEaLeAgAAvbYA= Date: Mon, 21 Nov 2016 15:39:19 +0000 Message-ID: <2236FBA76BA1254E88B949DDB74E612B41C15583@IRSMSX102.ger.corp.intel.com> References: <20161117085342.GB3142@twins.programming.kicks-ass.net> <20161117161937.GA46515@ast-mbp.thefacebook.com> <2236FBA76BA1254E88B949DDB74E612B41C14BB4@IRSMSX102.ger.corp.intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id uALFdSgw006739 Content-Length: 601 Lines: 12 > By the way, there are several sites where the use of > atomic_t/atomic_wrap_t as a counter ventures beyond the standard (inc, > dec, add, sub, read, set) operations we're planning on implementing > for both refcount_t and stats_t. 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. Also, simple atomic_dec() is used pretty much everywhere for counters, which we don’t have a straight match in refcount_t API.