From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw0-f193.google.com ([209.85.161.193]:35806 "EHLO mail-yw0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751527AbdCFTym (ORCPT ); Mon, 6 Mar 2017 14:54:42 -0500 Date: Mon, 6 Mar 2017 14:54:39 -0500 From: Tejun Heo To: Elena Reshetova Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-audit@redhat.com, linux-fsdevel@vger.kernel.org, peterz@infradead.org, gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk, mingo@redhat.com, hannes@cmpxchg.org, lizefan@huawei.com, acme@kernel.org, alexander.shishkin@linux.intel.com, paul@paul-moore.com, eparis@redhat.com, akpm@linux-foundation.org, arnd@arndb.de, luto@kernel.org, Hans Liljestrand , Kees Cook , David Windsor Subject: Re: [PATCH 12/19] kernel: convert css_set.refcount from atomic_t to refcount_t Message-ID: <20170306195439.GD19696@htj.duckdns.org> References: <1487585948-6401-1-git-send-email-elena.reshetova@intel.com> <1487585948-6401-13-git-send-email-elena.reshetova@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1487585948-6401-13-git-send-email-elena.reshetova@intel.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Hello, On Mon, Feb 20, 2017 at 12:19:01PM +0200, Elena Reshetova wrote: > @@ -134,10 +135,13 @@ static inline void put_css_set(struct css_set *cset) > * can see it. Similar to atomic_dec_and_lock(), but for an > * rwlock > */ > - if (atomic_add_unless(&cset->refcount, -1, 1)) > + spin_lock_irqsave(&css_set_lock, flags); > + if (refcount_read(&cset->refcount) != 1) { > + WARN_ON(refcount_dec_and_test(&cset->refcount)); > + spin_unlock_irqrestore(&css_set_lock, flags); > return; > + } This isn't an equivalent conversion and should have been mentioned in the patch description. Hmm... and I'm not sure this is a good idea. Can't we add the matching operation on refcount_t rather than adding extra locking like this? Thanks. -- tejun