Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp4050756imd; Mon, 29 Oct 2018 17:10:19 -0700 (PDT) X-Google-Smtp-Source: AJdET5d4gMKd6oF/r0ypsQuoGcri51Ld2UUmNGmM/fsRsLr63n+1L7/8VFdZQUIOjdJVydFj1AZg X-Received: by 2002:a62:8915:: with SMTP id v21-v6mr544878pfd.137.1540858219051; Mon, 29 Oct 2018 17:10:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540858219; cv=none; d=google.com; s=arc-20160816; b=pcYhTyeZ3GZb8Aaqh7OpZ5p+09W6OAHe9MFdVUlmK6g9s1HVAlH2APBnpnLdUEqaMG G30yDqdJxl/6PDYRVVSm4511oxwYRbwM93rnVp58g/j7lpeNSjt9xyywyszWHPsfm2Y+ jQQS6zw4dk31yvsMkRJEKIyTtAcCs5qRtc8NEPOJaA59x9umqSVnSdbzhvuyKFJsgGns iZ2U8w85gPfMYSZSQB0CjF1vHxhmRRy5CPD/dGj4Pj3kcoprFSAPxp4ARn3Np8vZ1Vop yu4g9QyhEhd80ASxw+RCxfC+u+6RbxoerYWagLE4piHehr0eKnkFUr52H6TNkM6Y0h3Z fUUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=q0hLaPzmf+ORYNB37gqW9keNyCCW9t+vs6KNdhEmkxc=; b=dgLIMKwmR+UcEwObZ1h494axm0OSZS7pm6/8xRnwhwU5CdgMw4HhbtNTBceSNa26f+ fpbyABPHQcRDCyz5kzZzvohav8BR9enmXLm8crZwjAUy969p7Nujs/D9Rn74AraPtUr5 +cshOF6ZLTipPtjb2YhnU4r7E7xjYKWcX4BxOC+Y3Pm8MNDe7tPP0riybqVqEhOltu/Q xcpC4MrUrPAR2GLw03Dd4evr2Vv8cynC2f8nrhtFZJkDvRUUhFMtaCkMOfPmtkmTC83E 4gb9L7g168KG+z7TLbZPMPcJvyPd+aBZ9rvpXaUAZs+kPJhnMlPy6HUg8+HdgcpKBNbi xGnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bU4rDGlC; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l9-v6si21592208pgj.210.2018.10.29.17.09.42; Mon, 29 Oct 2018 17:10:19 -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=@gmail.com header.s=20161025 header.b=bU4rDGlC; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726135AbeJ3JAN (ORCPT + 99 others); Tue, 30 Oct 2018 05:00:13 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:38698 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725840AbeJ3JAN (ORCPT ); Tue, 30 Oct 2018 05:00:13 -0400 Received: by mail-wm1-f65.google.com with SMTP id l2-v6so4145982wmh.3 for ; Mon, 29 Oct 2018 17:09:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=q0hLaPzmf+ORYNB37gqW9keNyCCW9t+vs6KNdhEmkxc=; b=bU4rDGlCB82LW8cSBjjSrc1a7bficEh97x3GBnXV3eX1csJqmQTYDa0UADPAzo0GiR rpBKu22ldK+swxyJHWhkEiUdg1BJO4PL8GT3D13bFCreEvldiV19bnucQ9P76WavflHP ihHRfb5s+2JCPMDZXlvI5YJySJS5bVXYnpK6BazrAEEEj3eqcgVsPxZbymVjt8P2mj1u 747G4LUJ/ID/SkE82HsBQNvRAQSGPquZMWJVZBMsqXCErjEXUSs+mtXX935ShImxvcGE bn5lv/+P+SBPe9pKlici4gyWaTSRbuq6mwslAPKGKwxI3fwbD5vJGHEl2D638i/EU2Sz +9lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=q0hLaPzmf+ORYNB37gqW9keNyCCW9t+vs6KNdhEmkxc=; b=DuLUElgO06FCvgRe92eLuUgwAGJcNdbDWFEAweN7mLfrcLTB2Tpw3lVP8cZ0fFCtB0 sCjXjUtNM6Plx0soLFYDvW0kV2pujDm7sUF8j45LeEX3MbqCCnBUD8xalIoqK34vQUcN HOvbCEAZoW4oIE3vg8LkQjUZKQjCozulXw1Z8szRNHSYtgPevnTUH24Y8NP4V/zry4sE x502XdpVbeZ+SFY/Ir/PKyAbNKRRu4cwksMqqLEG/+sQDIiJVQ2qTWy1bU/C6Z08CPGC 3N8ODwCxrHJWiFhJp+wwqVnxOo8MGAfup6DyRDA96erVNKdxRJxxihEAwapP+4jC3qRw 6ZoA== X-Gm-Message-State: AGRZ1gJRLTKDWHh7+z/GkawUpVsx9Nu3FloZIRnSTZ86M9PMACOc0l/J p/jVq5/ao+1wEzzzBrpfFuvXVGM= X-Received: by 2002:a1c:9355:: with SMTP id v82-v6mr15193721wmd.128.1540858146828; Mon, 29 Oct 2018 17:09:06 -0700 (PDT) Received: from avx2 (nat5-minsk-pool-46-53-217-92.telecom.by. [46.53.217.92]) by smtp.gmail.com with ESMTPSA id q185-v6sm5708048wmg.45.2018.10.29.17.09.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Oct 2018 17:09:06 -0700 (PDT) Date: Tue, 30 Oct 2018 03:09:03 +0300 From: Alexey Dobriyan To: Daniel Colascione Cc: linux-kernel Subject: Re: Re: [PATCH] fs/proc: introduce /proc/stat2 file Message-ID: <20181030000903.GA30495@avx2> References: <20181029233414.GA29750@avx2> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 29, 2018 at 11:40:47PM +0000, Daniel Colascione wrote: > On Mon, Oct 29, 2018 at 11:34 PM, Alexey Dobriyan wrote: > >> I'd much rather move to a model in which userspace *explicitly* tells > >> the kernel which fields it wants, with the kernel replying with just > >> those particular fields, maybe in their raw binary representations. > >> The ASCII-text bag-of-everything files would remain available for > >> ad-hoc and non-performance critical use, but programs that cared about > >> performance would have an efficient bypass. One concrete approach is > >> to let users open up today's proc files and, instead of read(2)ing a > >> text blob, use an ioctl to retrieve specified and targeted information > >> of the sort that would normally be encoded in the text blob. Because > >> callers would open the same file when using either the text or binary > >> interfaces, little would have to change, and it'd be easy to implement > >> fallbacks when a particular system doesn't support a particular > >> fast-path ioctl. > > > > You've just reinvented systems calls. > > I don't know why you say so. There are important benefits that come > from using an ioctl on a proc file FD instead of a plain system call. > Procfs files have file permissions,auditing, SCM_RIGHTS-ability, PID > race immunity, and other things that you wouldn't get from a plain > "get this information about this PID" system call. This whole thread started because /proc/stat is slow and every number in /proc/stat is system global. If you continue adding stuff to /proc, one day someone will notice that core VFS adds considerable overhead, at this point there is nothing anyone could do. I'd strongly advise to look at what this DB actually needs and deliver just that. Very little of other things apply to /proc/stat: * system call auditing exists, * /proc/stat is world readable and continues to be so, * thus passing descriptor around is pretty useless, * $PID race doesn't apply. Additionally passing descriptors feels like party trick. I suspect that's not how people use statistics in /proc: they run processes and one priviledged enough monitoring daemon collects data, otherwise userspace needs to cooperate with monitoring userspace which of course doesn't happen. PID race is solved by giving out descriptors which pin "struct pid". Which is how the race is solved currently: dentry pins inode, inode pins "struct pid".