From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9423C4CECE for ; Mon, 14 Oct 2019 15:21:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BF3EA20854 for ; Mon, 14 Oct 2019 15:21:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kellner.me header.i=@kellner.me header.b="cnTdk+aP"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="GxnClzyX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387472AbfJNPVK (ORCPT ); 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