Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4324149ybp; Mon, 14 Oct 2019 02:51:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqw6Lq4iSwLXMMRcbpPfrNuUa3yi6hPK4R5i55/wMTQXwxki+Z8WKFu+6hDvBoV6dIbmkan2 X-Received: by 2002:a17:906:fcd4:: with SMTP id qx20mr28069463ejb.257.1571046691569; Mon, 14 Oct 2019 02:51:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571046691; cv=none; d=google.com; s=arc-20160816; b=IUxjjvo7eH0nPb2e2wYRRDnBpyuY0995QVnpB9Kh22KapC6pBXJ6efP1q50N7zx9tb hsFyHCGWbEMMn2RJfDqlvRprl7R7NVPT9+e8yVqCOFPjEz7SDJiRUS5PxOVsJMIdS1Yz 3B7571OVcv0iu9k0wEFTI47QhLHTEsX7huQgoo46tmgmNphwHfqVvSkwJKYYZcezz0sg +R3QYIUZAlxUC20facqWbANxU8G554lWWWNX0ZO4ECEYyO5BmdeBLD96hEM9822/03v6 YXx+2H4enKm2IwgxVNkX/9PjlewvG5Z7gdDM4achFOuNOXTvZ+KPgWxxEVF/wW2oSTTW VOdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature:dkim-signature; bh=g0eFRemBLYbt3Vj8rAn5r0iCJcP4iC+nMgPsp2aeyxQ=; b=g0rQMJUuy4kd8do0T/SA1oAqGVAdexVPMs1KBEAGnbhSD1DN46qNGuIHIL2E4hmUjY J5685KBJ5uvEqnPqnnPGYtsmvWstgZuoWZiAOHKmZm4ar76ZJy1YkGpgOhuBvcRF6fSW 80GACdetWBdxR5O73A+exvTOClfB95XAlF1sutyJYizx3E+FgVjDTtHT03MEqf7lp2fO YiXVKuDWjJRUxvGEGt02vmhec1phaA2IUweWYqoYLhHWh1RYTU0g1fpPH5FIIngbHJPk rY/OMi1pgGhM5r3tLxDickQS9tAJmzQgzejQ33WxDZRR+yYmiPBBMi+0GUY4wN5K449e k0BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kellner.me header.s=mesmtp header.b=m3pH2RmG; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=fBdXfPY7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g29si12031394edb.13.2019.10.14.02.51.08; Mon, 14 Oct 2019 02:51:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kellner.me header.s=mesmtp header.b=m3pH2RmG; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=fBdXfPY7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731044AbfJNJvA (ORCPT + 99 others); Mon, 14 Oct 2019 05:51:00 -0400 Received: from wnew4-smtp.messagingengine.com ([64.147.123.18]:40583 "EHLO wnew4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730872AbfJNJvA (ORCPT ); Mon, 14 Oct 2019 05:51:00 -0400 X-Greylist: delayed 467 seconds by postgrey-1.27 at vger.kernel.org; Mon, 14 Oct 2019 05:50:59 EDT Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id 5D19F735; Mon, 14 Oct 2019 05:43:10 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 14 Oct 2019 05:43:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kellner.me; h= message-id:subject:from:to:cc:date:in-reply-to:references :content-type:mime-version:content-transfer-encoding; s=mesmtp; bh=g0eFRemBLYbt3Vj8rAn5r0iCJcP4iC+nMgPsp2aeyxQ=; b=m3pH2RmGh+mj wgvkt8KKNTsOw/RCIpYWpPBZ9rvYpsYphyRZ4YEAuhQHTYFsGa6SR22GK7aHS3BF kjKgFdK5SZpgFRxOdNyN36n/3I9JmIokiTyUqahDnD9DvVaMbeeE52QEnVRWV/Wq AFO9J3gtmaeGLYBMtulGsshEe90KKCQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=g0eFRemBLYbt3Vj8rAn5r0iCJcP4iC+nMgPsp2aey xQ=; b=fBdXfPY7DPkJHy3ntlbPfzGqGoe/3gzTG01r694FV4htyZypSAuCJ6qwJ uCzw1sWz+HpgCIo7uQLa9TB6z4TXqHxKiXGS9E/6Caywos3hNxCC/gjKHr7X99q+ p2r7uKqq+IaKPAOjQwm87WGHMXpRRnTg136+xzlaAbHQXjgh2I0EoBRqbVG05WeD l9iJBDmAa8smMKTFfoLdPRJw0fTr5pXkdGw3v4Do7s/3op1bk67Jbbh9kS0NE6TT MjoqyEOUPckhDxg9gVMTcSXiCCaLajbpkvNzp9BgXIuPtZ2IW4FVsS1Ds8oPKxCd 9PhMDv7Nqz/SYtcO0hBPflt5oIyVg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrjedugddvtdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkuffhvfffjghftggfggfgsehtjeertddtreejnecuhfhrohhmpeevhhhrihhs thhirghnucfmvghllhhnvghruceotghhrhhishhtihgrnheskhgvlhhlnhgvrhdrmhgvqe enucfkphepkeelrdduiedrudehfedrudelieenucfrrghrrghmpehmrghilhhfrhhomhep tghhrhhishhtihgrnheskhgvlhhlnhgvrhdrmhgvnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from hanada.local (cable-89-16-153-196.cust.telecolumbus.net [89.16.153.196]) by mail.messagingengine.com (Postfix) with ESMTPA id AB6348005B; Mon, 14 Oct 2019 05:43:05 -0400 (EDT) Message-ID: Subject: Re: [PATCH] pidfd: add NSpid entries to fdinfo From: Christian Kellner To: Christian Brauner , jannh@google.com Cc: aarcange@redhat.com, akpm@linux-foundation.org, cyphar@cyphar.com, elena.reshetova@intel.com, guro@fb.com, ldv@altlinux.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, mhocko@suse.com, mingo@kernel.org, peterz@infradead.org, tglx@linutronix.de, viro@zeniv.linux.org.uk Date: Mon, 14 Oct 2019 11:43:01 +0200 In-Reply-To: <20191012102119.qq2adlnxjxrkslca@wittgenstein> References: <20191012101922.24168-1-christian.brauner@ubuntu.com> <20191012102119.qq2adlnxjxrkslca@wittgenstein> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.4 (3.32.4-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2019-10-12 at 12:21 +0200, Christian Brauner wrote: > I think this might be more what we want. Yep, indeed. > I tried to think of cases where the first entry of Pid is not > identical > to the first entry of NSpid but I came up with none. Maybe you do, > Jann? Yeah, I don't think that can be the case. By looking at the source of 'pid_nr_ns(pid, ns)' a non-zero return means that a) 'pid' valid, ie. non-null and b) 'ns' is in the pid namespace hierarchy of 'pid' (at pid->level, i.e. "pid->numbers[ns->level].ns == ns"). > Christian, this is just a quick stab I took. Feel free to pick this > up as a template. Thanks! I slightly re-worked it, with the reasoning above in mind, to get rid of one of the branches: +#ifdef CONFIG_PID_NS + seq_put_decimal_ull(m, "\nNSpid:\t", nr); + if (nr) { + int i; + + /* If nr is non-zero it means that 'pid' is valid and that + * ns, i.e. the pid namespace associated with the procfs + * instance, is in the pid namespace hierarchy of pid. + * Start at one level below and print all descending pids. + */ + for (i = ns->level + 1; i <= pid->level; i++) { + ns = pid->numbers[i].ns; + seq_put_decimal_ull(m, "\t", pid_nr_ns(pid, ns)); + } + } +#endif But I now just realized that with the very same reasoning, if nr is non-zero, we don't need to redo all the checks and can just do: for (i = ns->level + 1; i <= pid->level; i++) seq_put_decimal_ull(m, "\t", pid->numbers[i].nr); If this sounds good to you I resend the patches with the change above. Thanks, Christian