From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755979AbdCGTSb convert rfc822-to-8bit (ORCPT ); Tue, 7 Mar 2017 14:18:31 -0500 Received: from mga07.intel.com ([134.134.136.100]:29976 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754911AbdCGTQs (ORCPT ); Tue, 7 Mar 2017 14:16:48 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,258,1486454400"; d="scan'208";a="65199958" From: "Reshetova, Elena" To: Tejun Heo 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 Thread-Topic: [PATCH 12/19] kernel: convert css_set.refcount from atomic_t to refcount_t Thread-Index: AQHSi2OpdIcWWK/Rlkeek6fnkZ+AXaGIUDKAgAGCYRA= Date: Tue, 7 Mar 2017 19:12:51 +0000 Message-ID: <2236FBA76BA1254E88B949DDB74E612B41C55AD8@IRSMSX102.ger.corp.intel.com> References: <1487585948-6401-1-git-send-email-elena.reshetova@intel.com> <1487585948-6401-13-git-send-email-elena.reshetova@intel.com> <20170306195439.GD19696@htj.duckdns.org> In-Reply-To: <20170306195439.GD19696@htj.duckdns.org> 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="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 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? Oh, actually this is fault on our side: initially we didn't have a refcount_dec_not_one() interface and we had to be creative in converting cases like this, but now the interface is present, but we actually forgot to convert this particular case. So, the above change should be: - if (atomic_add_unless(&cset->refcount, -1, 1)) + if (refcount_dec_not_one(&cset->refcount)) Do you want me to resend or could you modify the patch while applying? Best Regards, Elena. > > Thanks. > > -- > tejun