From patchwork Thu Jan 3 23:44:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 10747865 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B015717D2 for ; Thu, 3 Jan 2019 23:44:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EF4D25EA6 for ; Thu, 3 Jan 2019 23:44:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9397D2623C; Thu, 3 Jan 2019 23:44:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F8F225EA6 for ; Thu, 3 Jan 2019 23:44:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728973AbfACXod (ORCPT ); Thu, 3 Jan 2019 18:44:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51476 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728956AbfACXoc (ORCPT ); Thu, 3 Jan 2019 18:44:32 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ED730BDF7; Thu, 3 Jan 2019 23:44:31 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-244.rdu2.redhat.com [10.10.120.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8835608DD; Thu, 3 Jan 2019 23:44:30 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 5/5] percpu: Kill off PERCPU_REF_INIT_DEAD and percpu_ref_reinit() From: David Howells To: viro@zeniv.linux.org.uk Cc: avagin@gmail.com, dhowells@redhat.com, linux-fsdevel@vger.kernel.org Date: Thu, 03 Jan 2019 23:44:30 +0000 Message-ID: <154655907017.3032.3397037242037017828.stgit@warthog.procyon.org.uk> In-Reply-To: <154655904205.3032.4248425887082198759.stgit@warthog.procyon.org.uk> References: <154655904205.3032.4248425887082198759.stgit@warthog.procyon.org.uk> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 03 Jan 2019 23:44:32 +0000 (UTC) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Kill off PERCPU_REF_INIT_DEAD and percpu_ref_reinit() for lack of users. They were being used in cgroups, but this was causing problems with the refcounting in the event that kernfs_get_tree() created a superblock and then failed with the refcount not fully initialised. Signed-off-by: David Howells --- include/linux/percpu-refcount.h | 7 ------- lib/percpu-refcount.c | 31 +++---------------------------- 2 files changed, 3 insertions(+), 35 deletions(-) diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h index b297cd1cd4f1..fdd69b99f331 100644 --- a/include/linux/percpu-refcount.h +++ b/include/linux/percpu-refcount.h @@ -77,12 +77,6 @@ enum { * percpu_ref_switch_to_percpu() is invoked on it. */ PERCPU_REF_INIT_ATOMIC = 1 << 0, - - /* - * Start dead w/ ref == 0 in atomic mode. Must be revived with - * percpu_ref_reinit() before used. Implies INIT_ATOMIC. - */ - PERCPU_REF_INIT_DEAD = 1 << 1, }; struct percpu_ref { @@ -109,7 +103,6 @@ void percpu_ref_switch_to_percpu(struct percpu_ref *ref); void percpu_ref_kill_and_confirm(struct percpu_ref *ref, percpu_ref_func_t *confirm_kill); void percpu_ref_resurrect(struct percpu_ref *ref); -void percpu_ref_reinit(struct percpu_ref *ref); /** * percpu_ref_kill - drop the initial ref diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c index de10b8c0bff6..7a56c36aec5d 100644 --- a/lib/percpu-refcount.c +++ b/lib/percpu-refcount.c @@ -70,15 +70,12 @@ int percpu_ref_init(struct percpu_ref *ref, percpu_ref_func_t *release, ref->force_atomic = flags & PERCPU_REF_INIT_ATOMIC; - if (flags & (PERCPU_REF_INIT_ATOMIC | PERCPU_REF_INIT_DEAD)) + if (flags & PERCPU_REF_INIT_ATOMIC) ref->percpu_count_ptr |= __PERCPU_REF_ATOMIC; else start_count += PERCPU_COUNT_BIAS; - if (flags & PERCPU_REF_INIT_DEAD) - ref->percpu_count_ptr |= __PERCPU_REF_DEAD; - else - start_count++; + start_count++; atomic_long_set(&ref->count, start_count); @@ -282,14 +279,11 @@ EXPORT_SYMBOL_GPL(percpu_ref_switch_to_atomic_sync); * @ref: percpu_ref to switch to percpu mode * * There's no reason to use this function for the usual reference counting. - * To re-use an expired ref, use percpu_ref_reinit(). * * Switch @ref to percpu mode. This function may be invoked concurrently * with all the get/put operations and can safely be mixed with kill and * reinit operations. This function reverses the sticky atomic state set - * by PERCPU_REF_INIT_ATOMIC or percpu_ref_switch_to_atomic(). If @ref is - * dying or dead, the actual switching takes place on the following - * percpu_ref_reinit(). + * by PERCPU_REF_INIT_ATOMIC or percpu_ref_switch_to_atomic(). * * This function may block if @ref is in the process of switching to atomic * mode. If the caller ensures that @ref is not in the process of @@ -343,25 +337,6 @@ void percpu_ref_kill_and_confirm(struct percpu_ref *ref, } EXPORT_SYMBOL_GPL(percpu_ref_kill_and_confirm); -/** - * percpu_ref_reinit - re-initialize a percpu refcount - * @ref: perpcu_ref to re-initialize - * - * Re-initialize @ref so that it's in the same state as when it finished - * percpu_ref_init() ignoring %PERCPU_REF_INIT_DEAD. @ref must have been - * initialized successfully and reached 0 but not exited. - * - * Note that percpu_ref_tryget[_live]() are safe to perform on @ref while - * this function is in progress. - */ -void percpu_ref_reinit(struct percpu_ref *ref) -{ - WARN_ON_ONCE(!percpu_ref_is_zero(ref)); - - percpu_ref_resurrect(ref); -} -EXPORT_SYMBOL_GPL(percpu_ref_reinit); - /** * percpu_ref_resurrect - modify a percpu refcount from dead to live * @ref: perpcu_ref to resurrect