Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966100AbbDXPhD (ORCPT ); Fri, 24 Apr 2015 11:37:03 -0400 Received: from mail-qc0-f173.google.com ([209.85.216.173]:33868 "EHLO mail-qc0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755198AbbDXPhA (ORCPT ); Fri, 24 Apr 2015 11:37:00 -0400 Date: Fri, 24 Apr 2015 11:36:57 -0400 From: Tejun Heo To: Aleksa Sarai Cc: lizefan@huawei.com, mingo@redhat.com, peterz@infradead.org, richard@nod.at, =?iso-8859-1?Q?Fr=E9d=E9ric?= Weisbecker , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Subject: Re: [PATCH v10 4/4] cgroups: implement the PIDs subsystem Message-ID: <20150424153657.GC24029@htj.duckdns.org> References: <1429446154-10660-1-git-send-email-cyphar@cyphar.com> <1429446154-10660-5-git-send-email-cyphar@cyphar.com> <20150422162954.GF10738@htj.duckdns.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1967 Lines: 50 Hello, On Thu, Apr 23, 2015 at 10:43:12AM +1000, Aleksa Sarai wrote: > > Why is this safe? What guarantees that css's ref isn't already zero > > at this point? > > Because it's already been exposed by pids_fork, so the current css_set But what prevents against the task being migrated to a different cgroup? > (which contains the current css)'s ref has been bumped. There isn't a > guarantee that there is a ref to css, but there is a guarantee the > css_set it is in has a ref. The problem with using tryget is that we > can't fail here. The guarantee you have there is the css_set wouldn't go away until rcu lock is dropped and you can deref csses from it. The way it's currently implemented, you're guaranteed to have references to the csses but that's sort of implementation detail. It can be implemented in different ways. A task, as long as it's alive, is guaranteed to have a css associated with it all the time. What the tryget protects is races against the task being migrated to a different cgroup, so retrying until success is guaranteed to finish in a short amount of time. > >> + /* We use INT_MAX as the maximum value of pid_t. */ > >> + if (limit < 0 || limit > INT_MAX) > > > > This is kinda weird if we're using PIDS_MAX for max as it may end up > > showing "max" after some larger number is written to the file. > > The reason for this is because I believe you said "PIDS_MAX isn't > meant to be exposed to userspace" (one of the previous patchsets used > PIDS_MAX as the maximum valid value). Yeah, but wouldn't it be weird to allow the userland to input PIDS_MAX (whatever value that may be) and reads back max? It can be whatever maximum input value + 1, no? Thanks. -- tejun -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/