Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp126319imm; Tue, 10 Jul 2018 22:50:39 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfpLwk6Ns8+Q7zgDegOOmrvvAoeKQknkDlWBCLSx3WNawKrK8a+xHsb0lMB6S5IP+/7cHKX X-Received: by 2002:a62:1c16:: with SMTP id c22-v6mr15179128pfc.148.1531288239892; Tue, 10 Jul 2018 22:50:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531288239; cv=none; d=google.com; s=arc-20160816; b=g3p+Aee0csYgxnYoXb7B33zXXKzsxCNNw6RV7vbwNvj0U0ZV/ckcdwpnsQnhDwRETd D8K53Rz2j3vUyOIJmsNquPSU/YdiRztGzw+1HLO2a29QU7r704VQfMDYaFMSkDPqNI93 3s20W+9kSfojWo0+U+s36W6VzZVB5jdecq4gu1/yc596N9omOSrNOLkQnxtb4Pra9wf9 r4Esa5eewl295RXHW/znT23tAu5r/WlHY4MTfKl2zBY+8ly764xDaOAJTGwO6WGs3cuP Lzw8qHUSD/hIjFwwFXpwQXtqMt7+j0V3qBh++7uxSWL3uzwPAHzbHCVElIlJ3oZHxvJK lMZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:to :from:date:arc-authentication-results; bh=SoCbEh1XbMp2xxQvCS+J1oaSK0MLgVpabPyMD+41jC4=; b=udFhFc5p/KvG8PJrmjScyc3FTdCB/0yqwycC6wWNj1a1M0VEfoNXVvCJjO9QbAwOsI BqrKnWALYa86fDykyQRTb8ooIadLHNEuKx++4tXEVFDlkLSYacn6AUL3pXrIrHThBq35 oPitTVIjAWSmLW2IWWRam+uqUMzl8xas8kFv3GJ73yPDbeDd9Q03cwuPsXBsMDtS9Eir CXMIH4/lIzZ9qKejCaPRFWtnfb/ezXonygSbTg3HwlDZlysfdQv7g/fEbUDt13bRlNUa snlH6zBuU0o0bZAMNUvsX2uhdLaQegQ1fs3Pyffw1DB3f0qIIpnm95Wj2+SDXhFYlxxe tEfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1-v6si18236053pld.218.2018.07.10.22.50.25; Tue, 10 Jul 2018 22:50:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726401AbeGKFwZ (ORCPT + 99 others); Wed, 11 Jul 2018 01:52:25 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:56834 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725818AbeGKFwZ (ORCPT ); Wed, 11 Jul 2018 01:52:25 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EFC7580D; Tue, 10 Jul 2018 22:49:50 -0700 (PDT) Received: from salmiak (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 60AF13F318; Tue, 10 Jul 2018 22:49:49 -0700 (PDT) Date: Wed, 11 Jul 2018 06:49:46 +0100 From: Mark Rutland To: dsterba@suse.cz, linux-kernel@vger.kernel.org, Will Deacon , Kees Cook , Boqun Feng , Peter Zijlstra , Ingo Molnar Subject: Re: [PATCH] refcount: always allow checked forms Message-ID: <20180711054946.wdkfoou6kt2a2vml@salmiak> References: <20180703100102.16615-1-mark.rutland@arm.com> <20180704084641.GL3126@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180704084641.GL3126@suse.cz> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 04, 2018 at 10:46:41AM +0200, David Sterba wrote: > On Tue, Jul 03, 2018 at 11:01:02AM +0100, Mark Rutland wrote: > > In many cases, it would be useful to be able to use the full > > sanity-checked refcount helpers regardless of CONFIG_REFCOUNT_FULL, as > > this would help to avoid duplicate warnings where callers try to > > sanity-check refcount manipulation. > > > > This patch refactors things such that the full refcount helpers were > > always built, as refcount_${op}_checked(), such that they can be used > > regardless of CONFIG_REFCOUNT_FULL. This will allow code which *always* > > wants a checked refcount to opt-in, avoiding the need to duplicate the > > logic for warnings. > > > > There should be no functional change as a result of this patch. > > > > Signed-off-by: Mark Rutland > > Cc: Boqun Feng > > Cc: David Sterba > > Cc: Ingo Molnar > > Cc: Kees Cook > > Cc: Peter Zijlstra > > Cc: Peter Zijlstra > > Cc: Will Deacon > > I dare to give it my > > Reviewed-by: David Sterba Cheers! > as my POC implementations were crap and Mark's version is much better. Please don't think that your implementations were bad; I just already had an idea as to what this could look like. > > --- > > include/linux/refcount.h | 27 +++++++++++++++++------- > > lib/refcount.c | 53 +++++++++++++++++++++++------------------------- > > 2 files changed, 45 insertions(+), 35 deletions(-) > > > > Dave pointed out that it would be useful to be able to opt-in to full checks > > regardless of CONFIG_REFCOUNT_FULL, so that we can simplify callsites where we > > always want checks. I've spotted a few of these in code which is still awaiting > > conversion. > > The motivation was code like > > WARN_ON(refcount_read(&ref)); > if (refcount_dec_and_test(&ref)) { ... } > > so the warning is redundant for REFCOUNT_FULL, but I'm going to use the > _checked versions everywhere the performance of refcounts is not > critical. If you will have conversion patches, do you want to pick this up as the start of a series? Thanks, Mark.