Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp958458ybi; Fri, 24 May 2019 14:29:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaH1OW9xcrpf/PKqfin9Edchej+4Sx2/4K5GKMEdKdy+Dma2lkBiXgD0s5CqvphcivxSqJ X-Received: by 2002:a17:902:bd95:: with SMTP id q21mr72459045pls.159.1558733350280; Fri, 24 May 2019 14:29:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558733350; cv=none; d=google.com; s=arc-20160816; b=WC9tOhtRJPoS8tCrFZlgMcAi90X3DNlqaWS5F0MOvs4vpg1o0JfXMMkUA/5I/iQxQV oSjhOgAAMfnUJARfv8Rs8jXyvirsdbA+AVd+gi3wRSPnH0CQ1d01xdndxvoZThzMR9vg TLzxif/KKo0MHaWOJM/SR+TUZ9N4eCDHcWegXQlZi5tnN4oSQtr6KUSyyfpqFI6QWPQI 88tT15UyPuzFW6GqU6KZWRpJ1MgDB1sG+v+9ogEOeUwIjS0kFCGpyPbWVz9q9AKSnT7o qdqN+tU9yv6n7NHx3S5qW7ynnA7ZOkxAy3dlP6r84ovSa/xrFRKs9hI1Etu5XFVuE6Gk vJOQ== 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=y9ux/6s5mqKpo3SGmaASVq5a3/znJngTKz9dxsY6Ors=; b=AuAyb57w/6La2oaY1UqmXiJWpUm+GpnH9WMsZZMPR2w3f1FhFFbQOZI+V01XC2RMO+ 2/1p1CdsW4w/5pMGyDcgV1q9KS15HD+86eMURaoemaqki9DCDjpv1EJiuKgTndcZbOMw 6BXoheSW9uwklvHWcD308adwFo6Rb/O1jKpFLLreM8ee/6RrKjiBRn1nx6c3S8+jE2nN TcL7mqxY5OLtNA1E3HYYPSQ1/HHBla9Hz5Bpup5I9mIl+N2hM6wPWb2dVHVj8zpjH05y 5xCfY8hEjO1iGQMdXxnRtmFfSmNDHVkUSdFNf1/w+XaHh+jGn9WZCvzd4wm8zoeolo3a 0zDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=omEJrnMw; 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 d21si6071223pgl.591.2019.05.24.14.28.54; Fri, 24 May 2019 14:29:10 -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=omEJrnMw; 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 S2404271AbfEXV1q (ORCPT + 99 others); Fri, 24 May 2019 17:27:46 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:53174 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404163AbfEXV1p (ORCPT ); Fri, 24 May 2019 17:27:45 -0400 Received: by mail-wm1-f66.google.com with SMTP id y3so10709951wmm.2; Fri, 24 May 2019 14:27:44 -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=y9ux/6s5mqKpo3SGmaASVq5a3/znJngTKz9dxsY6Ors=; b=omEJrnMwXjBomP4BtaaCk/eahP4koX6r9N/1FRZFbAIeIEejhvE2xj11PA1ZGUmirI P1LAT+/s4Rfq71eZQ/EX0iXP+V8Hfrs6mDbooVcuextI7ReAKBae9Lyw6fmipHr3iZ8F Yn+jYqg8fnQuHMF/YhMnjgUZShVc/DqDuWGyAUcK0XNIzO/aSTv4Pc+QlK2PDBllUX1+ Sk1tbDsdU87eYGD6n6E9jIQJdoR8X3BZsx1owMCdIv5cj8CCZbMEJoL47ABToHMmYDV9 W6fLBNA/j+oOorGBbQtIBrMiI+yCs90gT/VlKkPj+2gz0PuF/aQf/R7AGGTM4eEJGEFQ 8Y3Q== 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=y9ux/6s5mqKpo3SGmaASVq5a3/znJngTKz9dxsY6Ors=; b=ib+5oKIPNfbxUApWGsnXQo+LuFf9JgQlv+E6JLlvFdPHD3nvtUoAofiuKZl+P77inY heCdJALOK/kWv7IqxPgKGTDtZKAaxyoL9gZ5hxO7o1t+kTiozLUR32a2RtUnZMgwzHt1 pPM1iCZXhYiXgh5FXXSlJPsk6mXTiOEJxzTcp2lqrPuCh0MRPK7erMMXric/JTL39GRK BpMsvs7bBsI3ey6LlMusR0Upf0zWswLLoSn2/J6ZfJRPnDSX5DdFcskQpDOmcovrTNkV mUrnFscTtMa5phl3RkrQGAm/hcmfqhrUbh0WZZUSNSbb+wpcPp71oEq2f6xdKIYM0ACU 9snw== X-Gm-Message-State: APjAAAX7fckNvEw3TzLwIb5eQ1OOKYmUHjKlIPLTdWdJAZPoRYaSPCRr +i4M1xmPRGAi94kQmP4UNq5PEzs= X-Received: by 2002:a05:600c:2289:: with SMTP id 9mr18657802wmf.106.1558733263578; Fri, 24 May 2019 14:27:43 -0700 (PDT) Received: from avx2 ([46.53.253.112]) by smtp.gmail.com with ESMTPSA id b2sm3371534wrt.20.2019.05.24.14.27.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 May 2019 14:27:42 -0700 (PDT) Date: Sat, 25 May 2019 00:27:40 +0300 From: Alexey Dobriyan To: Linus Torvalds Cc: Christian Brauner , Linux List Kernel Mailing , linux-fsdevel Subject: Re: [PATCH v2 0/2] close_range() Message-ID: <20190524212740.GA7165@avx2> References: <20190523182152.GA6875@avx2> <20190524183903.GB2658@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 Fri, May 24, 2019 at 11:55:44AM -0700, Linus Torvalds wrote: > On Fri, May 24, 2019 at 11:39 AM Alexey Dobriyan wrote: > > > > > Would there ever be any other reason to traverse unknown open files > > > than to close them? > > > > This is what lsof(1) does: > > I repeat: Would there ever be any other reason to traverse unknown > open files than to close them? > > lsof is not AT ALL a relevant argument. > > lsof fundamentally wants /proc, because lsof looks at *other* > processes. That has absolutely zero to do with fdmap. lsof does *not* > want fdmap at all. It wants "list other processes files". Which is > very much what /proc is all about. > > So your argument that "fdmap is more generic" is bogus. > > fdmap is entirely pointless unless you can show a real and relevant > (to performance) use of it. > > When you would *possibly* have a "let me get a list of all the file > descriptors I have open, because I didn't track them myself" > situation? That makes no sense. Particularly from a performance > standpoint. > > In contrast, "close_range()" makes sense as an operation. What about orthogonality of interfaces? fdmap() bulk_close() Now fdmap() can be reused for lsof/criu and it is only 2 system calls for close-everything usecase which is OK because readdir is 4(!) minimum: open getdents getdents() = 0 close Writing all of this I understood how fdmap can be made more faster which neither getdents() nor even read() have the luxury of: it can return a flag if more data is available so that application would do next fdmap() only if truly necessary. > I can > explain exactly when it would be used, and I can easily see a > situation where "I've opened a ton of files, now I want to release > them" is a valid model of operation. And it's a valid optimization to > do a bulk operation like that. > > IOW, close_range() makes sense as an operation even if you could just > say "ok, I know exactly what files I have open". But it also makes > sense as an operation for the case of "I don't even care what files I > have open, I just want to close them". > > In contrast, the "I have opened a ton of files, and I don't even know > what the hell I did, so can you list them for me" makes no sense. > > Because outside of "close them", there's no bulk operation that makes > sense on random file handles that you don't know what they are. Unless > you iterate over them and do the stat thing or whatever to figure it > out - which is lsof, but as mentioned, it's about *other* peoples > files. What you're doing is making exactly one usecase take exactly one system call and leaving everything else deal with /proc. Stracing lsof shows very clearly how stupid and how wasteful it is. Especially now that we're post-meltdown era caring about system call costs (yeah suure). I'm suggesting make close-universe usecase take only 2 system calls. which is still better than anything /proc can offer.