From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752891AbcFUSXd (ORCPT ); Tue, 21 Jun 2016 14:23:33 -0400 Received: from mail-yw0-f174.google.com ([209.85.161.174]:34450 "EHLO mail-yw0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752810AbcFUSXb (ORCPT ); Tue, 21 Jun 2016 14:23:31 -0400 Date: Tue, 21 Jun 2016 13:28:32 -0400 From: Tejun Heo To: Kenny Yu Cc: "lizefan@huawei.com" , "hannes@cmpxchg.org" , "cyphar@cyphar.com" , "cgroups@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Kernel Team Subject: Re: [PATCH v3] cgroup: Add pids controller event when fork fails because of pid limit Message-ID: <20160621172832.GM3262@mtj.duckdns.org> References: <20160621163402.GI3262@mtj.duckdns.org> <1466528198-3416939-1-git-send-email-kennyyu@fb.com> <20160621171212.GL3262@mtj.duckdns.org> <9874B6F0-99B8-4739-B099-B7EEE99478F3@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9874B6F0-99B8-4739-B099-B7EEE99478F3@fb.com> User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Tue, Jun 21, 2016 at 05:23:40PM +0000, Kenny Yu wrote: > >It'd be better to use atomic64_inc_and_test() instead. > > > > if (err) { > > if (atomic64_inc_and_test()) { > > pr_xxx...; > > } > > cgroup_file_notify(&pids->events_file); > > } > > > > According to the docs https://www.kernel.org/doc/Documentation/atomic_ops.txt , > it looks like atomic_inc_and_test returns "a boolean indicating whether the resulting > counter value was zero or not", which will only happen when the counter goes from > negative to 0. I'll keep it as atomic_inc_return and get rid of the temp variable. Right you're. Sorry about the confusion. Yeah, that sounds good to me. Thanks! -- tejun