Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4669274ybp; Mon, 14 Oct 2019 08:12:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzWE9EbUehlA1SAykyvMlCKCIFmbjnrhvI+axh0zlpMUoQZzeWDtfLZ9MJSE8po25PIkJrt X-Received: by 2002:a50:aca5:: with SMTP id x34mr28594951edc.130.1571065960413; Mon, 14 Oct 2019 08:12:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571065960; cv=none; d=google.com; s=arc-20160816; b=C66uPEBmv0P2HVcmGq4DlEXeP9ZJM+EA7FG2TkvX2na0Tlfi8eE7ShxAJTIqBvzW1c E7s28kwMKH+To2pjEkncEE1T9LIzWcCrCyAyd/p/2DlUYW/W3/wL1EyLQSI40BKFjhAG Z9wQgjvjZF501bqMWy0s5NNQd7lOqLAqxH3aYeam37DW0yH2yLs1ZfEZz8fgRKXXpQT9 pxYROUBFlW4F2ZT046giEbf/CKVBDs3C/TOdf7KMCENwZUFrnwZvtoL93tXh1+GUKzSO QHv97AkBhvP7VUfCeqMMTqaUsc5lQdRfDGg57huxCkNbKRoAGjiIvXpH5r7iyoQTeGxu 6lvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=n8mZzQYgCJoh/U/LtDTWoqHWL38rFTI9nqBb83t1F0I=; b=hTfAESO5tW8p6drApqGHZPpm9rFT2eVvuCFIXzF8UmavuD5LXjpPkUI+dNdQryOJ+Q hbh0wJQydXvcRtfQmY0/s2JzuWuDkJ3aE6NYC+7xA5iPuoVaCxBsGeAwya8/KgBuadIh tetcRNDKfcPyC2rTowYUmgbV7Ol2TkMxw1MCsn18CdpgJvraEhDvzb02hI3x520DJJdA Uu8Fu+D5Pl3+4yIKajDBSiRmK7lnofK6rXQ+75lzGpdUGwgnn8scW6eMEwujxHlkShkl 4NwaIhIMiTFk/FR3Dilu0w9P3fGNoXrkr4o3P4lt+5nmWs6BLKMAEXq8uDLbws1n87Gf OnzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="eL0KkC/q"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y2si11190774eds.98.2019.10.14.08.12.15; Mon, 14 Oct 2019 08:12:40 -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=@google.com header.s=20161025 header.b="eL0KkC/q"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733257AbfJNPKa (ORCPT + 99 others); Mon, 14 Oct 2019 11:10:30 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:45934 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732647AbfJNPKa (ORCPT ); Mon, 14 Oct 2019 11:10:30 -0400 Received: by mail-oi1-f195.google.com with SMTP id o205so14004077oib.12 for ; Mon, 14 Oct 2019 08:10:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=n8mZzQYgCJoh/U/LtDTWoqHWL38rFTI9nqBb83t1F0I=; b=eL0KkC/qG5Sqdy3584kkE+iz33uqISxvsXEGdERUa7Qba35awyW4wPPpCaQDK4Vf1r A3DLF2XrRN3Lwh4n2M6qxwxu2T46oy32FbABZOdyiBDH2LNz67ggJr+I5OhDY4eeapth bIGYmB1CSf53TZI51DGqJab6Wjwy5z7eYIb7P7XsOHgHr1mbV/Jf08+om+Jr88+Wba5R oTzg3htSuDlhpSRZS3B1U76DkyOGgI+M99HxgN9w9xoR6tCXMFWhLG44qctxm9vFjIrm 5i5FtAqJuGamLA8VvOY1RqJRFB8jEkEhrNIziL8n1p3hBxPQloscS8mtFR/Ak1n5qkBB 6+dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=n8mZzQYgCJoh/U/LtDTWoqHWL38rFTI9nqBb83t1F0I=; b=XPsqaJg2EHVz5otrhNea3Eyto55GeZ1rFSnl9AU1h9tZn8DX2lgKlsYYZcgHxd+XXJ J8OPdkVKRgjLyq4Nj0nM2Lu1MB1hDTM51+Tj1wKrfK52P8S6CI2hLqiiAK1PBVyCcdP0 kh0ETHxmXe92YEkJcS8mvnyzI65wdCgD6YyFQE9SMIoZHa7y6xPtl07nj4N37lXF3n10 mPsj22//lrzK9HZxxHFbNfr+qYYxDRryfvXeEu2CvjCFKAAgNf0lonkmzYA+5f9VjzO9 coEDwTHR5yf0u1Wa6RiIGHQF59vJHPrf5EXk1J/cR1qd7EuNsot2dnFwpBj1R4l6t30a 16nQ== X-Gm-Message-State: APjAAAXVBiYMGfBEgjCPBehHdHARn61S2kLzH7AYmrLgIoHVtl3IDHFB 0U2SCO9phgyAg6MAfVxx/kwwiliCz76SzaSjurscfA== X-Received: by 2002:a05:6808:95:: with SMTP id s21mr25075773oic.68.1571065827544; Mon, 14 Oct 2019 08:10:27 -0700 (PDT) MIME-Version: 1.0 References: <20191012101922.24168-1-christian.brauner@ubuntu.com> <20191012102119.qq2adlnxjxrkslca@wittgenstein> <20191014103157.h2wph2ujjidsrhyw@wittgenstein> In-Reply-To: <20191014103157.h2wph2ujjidsrhyw@wittgenstein> From: Jann Horn Date: Mon, 14 Oct 2019 17:10:01 +0200 Message-ID: Subject: Re: [PATCH] pidfd: add NSpid entries to fdinfo To: Christian Brauner Cc: Christian Kellner , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: > > On Sat, 2019-10-12 at 12:21 +0200, Christian Brauner wrote: > > > 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"). Agreed. > 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.