From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932438AbdKFOrg (ORCPT ); Mon, 6 Nov 2017 09:47:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58096 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753113AbdKFOrf (ORCPT ); Mon, 6 Nov 2017 09:47:35 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CBC25B5CF Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=oleg@redhat.com Date: Mon, 6 Nov 2017 15:47:33 +0100 From: Oleg Nesterov To: Andrei Vagin Cc: Andrew Morton , linux-kernel@vger.kernel.org, Gargi Sharma Subject: Re: [PATCH] pid: restore the old behaviour of the ns_last_pid sysctl Message-ID: <20171106144733.GA19282@redhat.com> References: <20171103203133.19007-1-avagin@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171103203133.19007-1-avagin@openvz.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 06 Nov 2017 14:47:34 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/03, Andrei Vagin wrote: > > @@ -297,8 +298,18 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write, > * it should synchronize its usage with external means. > */ > > - tmp.data = &pid_ns->idr.idr_next; > - return proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); > + next = idr_get_cursor(&pid_ns->idr) - 1; > + > + tmp.data = &next; > + ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos); > + if (ret < 0) > + return ret; > + > + if (!write) > + return 0; > + > + idr_set_cursor(&pid_ns->idr, next + 1); > + return 0; Ah yes, we should also take "write" into account, I forgot it is readable. Can't resist, to me err = proc_dointvec_minmax(...); if (!err && write) idr_set_cursor(...); return err; looks a bit more readable, but this is matter of taste of course. Acked-by: Oleg Nesterov