From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758016Ab3ENPcv (ORCPT ); Tue, 14 May 2013 11:32:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4017 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752627Ab3ENPcu (ORCPT ); Tue, 14 May 2013 11:32:50 -0400 Date: Tue, 14 May 2013 17:28:36 +0200 From: Oleg Nesterov To: Tejun Heo Cc: Kent Overstreet , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, akpm@linux-foundation.org, Zach Brown , Felipe Balbi , Greg Kroah-Hartman , Mark Fasheh , Joel Becker , Rusty Russell , Jens Axboe , Asai Thambi S P , Selvan Mani , Sam Bradshaw , Jeff Moyer , Al Viro , Benjamin LaHaise , Christoph Lameter , Ingo Molnar Subject: Re: [PATCH 04/21] Generic percpu refcounting Message-ID: <20130514152836.GA21972@redhat.com> References: <1368494338-7069-1-git-send-email-koverstreet@google.com> <1368494338-7069-5-git-send-email-koverstreet@google.com> <20130514145932.GA6607@mtj.dyndns.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130514145932.GA6607@mtj.dyndns.org> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/14, Tejun Heo wrote: > > > +int percpu_ref_tryget(struct percpu_ref *ref) > > +{ > > + int ret = 1; > > + > > + preempt_disable(); > > + > > + if (!percpu_ref_dead(ref)) > > + percpu_ref_get(ref); > > + else > > + ret = 0; > > + > > + preempt_enable(); > > + > > + return ret; > > +} ... > BTW, why is this > function necessary? What's the use case? Yes, I was wondering too. And please note that this code _looks_ wrong, percpu_ref_get() still can increment ref->count. Hmm. Just noticed this comment above percpu_ref_kill() * The caller must issue a synchronize_rcu()/call_rcu() before calling * percpu_ref_put() to drop the initial ref. Really? Oleg. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Oleg Nesterov Subject: Re: [PATCH 04/21] Generic percpu refcounting Date: Tue, 14 May 2013 17:28:36 +0200 Message-ID: <20130514152836.GA21972@redhat.com> References: <1368494338-7069-1-git-send-email-koverstreet@google.com> <1368494338-7069-5-git-send-email-koverstreet@google.com> <20130514145932.GA6607@mtj.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Kent Overstreet , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, akpm@linux-foundation.org, Zach Brown , Felipe Balbi , Greg Kroah-Hartman , Mark Fasheh , Joel Becker , Rusty Russell , Jens Axboe , Asai Thambi S P , Selvan Mani , Sam Bradshaw , Jeff Moyer , Al Viro , Benjamin LaHaise , Christoph Lameter , Ingo Molnar To: Tejun Heo Return-path: Content-Disposition: inline In-Reply-To: <20130514145932.GA6607@mtj.dyndns.org> Sender: owner-linux-aio@kvack.org List-Id: linux-fsdevel.vger.kernel.org On 05/14, Tejun Heo wrote: > > > +int percpu_ref_tryget(struct percpu_ref *ref) > > +{ > > + int ret = 1; > > + > > + preempt_disable(); > > + > > + if (!percpu_ref_dead(ref)) > > + percpu_ref_get(ref); > > + else > > + ret = 0; > > + > > + preempt_enable(); > > + > > + return ret; > > +} ... > BTW, why is this > function necessary? What's the use case? Yes, I was wondering too. And please note that this code _looks_ wrong, percpu_ref_get() still can increment ref->count. Hmm. Just noticed this comment above percpu_ref_kill() * The caller must issue a synchronize_rcu()/call_rcu() before calling * percpu_ref_put() to drop the initial ref. Really? Oleg. -- To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to majordomo@kvack.org. For more info on Linux AIO, see: http://www.kvack.org/aio/ Don't email: aart@kvack.org