Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4681270ybp; Mon, 14 Oct 2019 08:22:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzmjrzr8KT/hgs63O/B4WhGbiLqG5H3OIjKiP+5tmoLcuKLp0ckgxQpdZ53h+H6TYcv1OsR X-Received: by 2002:a17:906:29db:: with SMTP id y27mr29516444eje.185.1571066552477; Mon, 14 Oct 2019 08:22:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571066552; cv=none; d=google.com; s=arc-20160816; b=Mm1ecW07stGh8N+fUoOevFwoQTz7HRcJB458yc4Oy8XaeERl2kdQJ+zx4ImHkC7vML 54Stx/HpTggQkI/tmVbJSG2H99ByMoxUAeYc0u8O47bo9EvwZce46opmEqHIGyiilCty 6cPAfBxjJCVACRjY2Fz7JD9EiMIRzaJ06B3gXZvf0I3sgoggOpPihEX0G9F9AAhOLqXQ /UwyLg9WfH0PcoZBY0mSabMgKBXTri3kd1LJzZSMw6dPE7CvF6hpEi2CkwWYEIvB6TNs 9AWm1fhIFh1BVAe3rp5CXJAhViS9dy4Cqxb9XpksyT6cAQ7RNSGoEvzImrceu5qsVFMF KvvA== 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=Bpli2FWy4jaHCUTgQsgpxLtikyXA6zeohU0YjZLav+0=; b=T4xqqqWwtuSTwkOi0qHrtP00O0ABZYo6BnTmijwVhD8eJavNJ0BZK518HIuzPZAteq J5esxgu9XdUIr5t2MuKDEVp0oZvFmtAJ1BlRSeM6DdS1CCWNh5Ksis4trPNRRMC4lr4P uKrU4F26yz/7721/RDm8QZQKV1rpSaXPdRkjCH/tVEuBKDElTSMxih5cGt5DawlKPkcP fjSMZwQA40sEN6Toj6a+9fZxhWw++MyOM61L4ulKnnDyvi6sPsm4MVHP0VyvuYCfHjnU ik+zPnRot/IYi0QI0XvnpLQTqEwoKHxpnP+SwzTI+I96Vw3f+cZ7AKt3/xi6G2/OzxGM WfSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kellner.me header.s=mesmtp header.b=cnTdk+aP; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=GxnClzyX; 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 g90si13423977edd.329.2019.10.14.08.22.09; Mon, 14 Oct 2019 08:22:32 -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=cnTdk+aP; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=GxnClzyX; 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 S2387439AbfJNPVK (ORCPT + 99 others); Mon, 14 Oct 2019 11:21:10 -0400 Received: from wnew1-smtp.messagingengine.com ([64.147.123.26]:37361 "EHLO wnew1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732422AbfJNPVK (ORCPT ); Mon, 14 Oct 2019 11:21:10 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id 33E4528A; Mon, 14 Oct 2019 11:21:08 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Mon, 14 Oct 2019 11:21:09 -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=Bpli2FWy4jaHCUTgQsgpxLtikyXA6zeohU0YjZLav+0=; b=cnTdk+aPBhLQ RB9mkNzWt1BbAsarP5ESPmvVG5xVA4jJGnH+3xZKOTziUD5IP4+WNda1ygjP8y+O DdlVxYEAPChb50nWfJBwjBUqx7NabNPKRnzo5+4IlDB5vkzloR7lbFtZS6/kC47c TRGRryefE+TAjib5H+Gn5XGS9q/L/Fs= 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=Bpli2FWy4jaHCUTgQsgpxLtikyXA6zeohU0YjZLav +0=; b=GxnClzyXLTyOCtlZSuewxWNVbdkJeCwQPJcxZvb+k2BBdF63NKVYfn1Og +s9hkpmfO6Uo5zibJu3n1PfRcCaLS7X2GjVqclXZge1p3Wq+j+PHBaKfkAj5xonQ vCNbGti9eitwO5re39TcLw9VzZ1mykm6jHrOgsoro+IWx5FXIvr58zzxuNPgpfqm WQMHlR4TDWXd4JYyFCttqeSPLVJRHQqpkUjjewQykI5PJiuutfZ39/IfHmQngcAm GltldxS+qZeginB1cAs7jWf+xw+F/dCqTvchFEEGM30GFxxTMG7pf78tjxszMH2R m2UAiddZcHygd8JMibe7pxzIOOGrw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrjedugdekkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkuffhvfffjghftggfggfgsehtjeertddtreejnecuhfhrohhmpeevhhhrihhs thhirghnucfmvghllhhnvghruceotghhrhhishhtihgrnheskhgvlhhlnhgvrhdrmhgvqe enucfkphepkeelrdduiedrudehfedrudelieenucfrrghrrghmpehmrghilhhfrhhomhep tghhrhhishhtihgrnheskhgvlhhlnhgvrhdrmhgvnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from hanada.ber.coreos.systems (cable-89-16-153-196.cust.telecolumbus.net [89.16.153.196]) by mail.messagingengine.com (Postfix) with ESMTPA id 68FD1D6005D; Mon, 14 Oct 2019 11:21:02 -0400 (EDT) Message-ID: <3159d545105613416961ff50572f6686cdee03ee.camel@kellner.me> Subject: Re: [PATCH] pidfd: add NSpid entries to fdinfo From: Christian Kellner To: Jann Horn , Christian Brauner Cc: Andrea Arcangeli , Andrew Morton , Aleksa Sarai , Elena Reshetova , Roman Gushchin , "Dmitry V. Levin" , Linux API , kernel list , Michal Hocko , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Al Viro Date: Mon, 14 Oct 2019 17:20:57 +0200 In-Reply-To: References: <20191012101922.24168-1-christian.brauner@ubuntu.com> <20191012102119.qq2adlnxjxrkslca@wittgenstein> <20191014103157.h2wph2ujjidsrhyw@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 Mon, 2019-10-14 at 17:10 +0200, Jann Horn wrote: > On Mon, Oct 14, 2019 at 12:32 PM Christian Brauner wrote: > > On Mon, Oct 14, 2019 at 11:43:01AM +0200, Christian Kellner wrote: > > You could probably do: > > > > #ifdef CONFIG_PID_NS > > seq_put_decimal_ull(m, "\nNSpid:\t", nr); > > for (i = ns->level + 1; i <= pid->level && nr; i++) > > seq_put_decimal_ull(m, "\t", pid->numbers[i].nr); > > #endif > > Personally, I dislike hiding the precondition for running the loop in > the loop statement like that. While it makes the code more concise, > it somewhat obfuscates the high-level logic at a first glance. I agree and it has the side-effect of needing another #ifdef at the end of the variable block for "i". I think I will go with: 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 below the already printed level. */ for (i = ns->level + 1; i <= pid->level; i++) seq_put_decimal_ull(m, "\t", pid->numbers[i].nr); } I will re-work the comment block and then send a new version of the patch. Thanks, Christian