Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934463AbdCVM0d (ORCPT ); Wed, 22 Mar 2017 08:26:33 -0400 Received: from merlin.infradead.org ([205.233.59.134]:46700 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758895AbdCVM02 (ORCPT ); Wed, 22 Mar 2017 08:26:28 -0400 Date: Wed, 22 Mar 2017 13:25:40 +0100 From: Peter Zijlstra To: Eric Dumazet Cc: Kees Cook , Herbert Xu , David Miller , "Reshetova, Elena" , Network Development , bridge@lists.linux-foundation.org, LKML , Alexey Kuznetsov , James Morris , Patrick McHardy , Stephen Hemminger , Hans Liljestrand , David Windsor , Andrew Morton Subject: Re: [PATCH 07/17] net: convert sock.sk_refcnt from atomic_t to refcount_t Message-ID: <20170322122540.odnm4j3r4c4uf7wt@hirez.programming.kicks-ass.net> References: <20170318.182121.439615057765380575.davem@davemloft.net> <20170320103937.lq7nfnutupr3gkn7@hirez.programming.kicks-ass.net> <20170320131629.GA26405@gondor.apana.org.au> <20170320132357.acygo3umw6fiwb4p@hirez.programming.kicks-ass.net> <20170320132713.GA26954@gondor.apana.org.au> <20170320134017.h3c2jrsnd4guuyu7@hirez.programming.kicks-ass.net> <1490131389.16816.123.camel@edumazet-glaptop3.roam.corp.google.com> <1490148199.16816.126.camel@edumazet-glaptop3.roam.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1490148199.16816.126.camel@edumazet-glaptop3.roam.corp.google.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1137 Lines: 29 On Tue, Mar 21, 2017 at 07:03:19PM -0700, Eric Dumazet wrote: > Note that we might define two refcount_inc() : One that does whole > tests, and refcount_inc_relaxed() that might translate to atomic_inc() > on non debug kernels. So you'd want a duplicate interface, such that most code, which doesn't care about refcount performance much, can still have all the tests enabled. But the code that cares about it (and preferably can prove it with numbers) can use the other. I'm also somewhat hesitant to use _relaxed for this distinction, as it has a clear meaning in atomics, maybe _nocheck? Also; what operations do you want _nocheck variants of, only refcount_inc() ? That said; I'm really loath to provide these without actual measurements that prove they make a difference. > Then later, maybe provide a dynamic infrastructure so that we can > dynamically force the full checks even for refcount_inc_relaxed() on say > 1% of the hosts, to get better debug coverage ? Shouldn't be too hard to do in arch specific code using alternative stuff. Generic code could use jump labels I suppose, but that would result in bigger code.