Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3457476ybf; Tue, 3 Mar 2020 06:24:49 -0800 (PST) X-Google-Smtp-Source: ADFU+vtKR6nEPCorfu8KOA2eTIjuUERBYUOPvE4qjc1k87frDYg96Yl3yEVZhIfrKcDJ/W68tkMl X-Received: by 2002:aca:d954:: with SMTP id q81mr2624004oig.157.1583245488994; Tue, 03 Mar 2020 06:24:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583245488; cv=none; d=google.com; s=arc-20160816; b=LXrh6ykCMb1XeHhT7JCjMIhBW8/fyP/JPQ+jL6j4+sF8RAQRHHXv2SF2Qt/o/KUf5C NDI9kcWYUFOwSLfv3C7alPUTFggMcB1aLdwn9S4aLZ4vox0s1zFmcNA+2bafHImSHxik ERlRjG8aKT01Rn+szfuqTR7Rh6/qzPa0H4Ab41Swp01AVIpqmi7ZlDOWpt+0chv2f2pE URgkCtlBSST3+k4s6Uu34o/C+ZDhQTL4ISRhmZM4sgDIHUQRl4VhXoNKv3zyE8JKWmb8 PgW+tHU2dYmVG4yLcUVYJriSMrOAFcNF1DMLz+Nb1UA7HNuOoZK+2iLfdr7/92LbIJAQ Lm7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=xxeMn5Rpd6+F0wQq8OLSLHw0W2ZzrVpUhs/g69Uoscg=; b=uuNiVWS5AIwFOaqcsZyEiVphw0n05OpzaDILOJ0I9Or24z/z5kmlXoE7eTJ71kjmOd c9CNWu/vT5GbrAMc1vuOLI6Oh82M3WZ5zpv+rbmfv2jEOQgFbmc+U+kueqVEPiMoRDEQ MVZTEUPVhaRI2DNlkt382xZ/xgNIqpAszyPcuT1R3hBfPBot1YW7kVZa2UXT3BkXuIHu NtO3WeLyqjcnoqsKiSaFuxj9qoamikXf+ssfjaEtCSV98dlgj1jRXA7mLaFG+Nuardfk 4r6USPFfbWai+2dJqh0gQCBwhhn4i7H7y4FIqmIwhhbxCJRY579ytT9GKMRfPQ3aFSlp Fw4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B60XaKRw; 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 d2si8084170oth.267.2020.03.03.06.24.36; Tue, 03 Mar 2020 06:24:48 -0800 (PST) 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=@kernel.org header.s=default header.b=B60XaKRw; 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 S1729393AbgCCOYL (ORCPT + 99 others); Tue, 3 Mar 2020 09:24:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:55098 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729318AbgCCOYL (ORCPT ); Tue, 3 Mar 2020 09:24:11 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6561E2083E; Tue, 3 Mar 2020 14:24:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583245450; bh=zQeebs9ROb6X8Gktb/55GVuE90KUd03mb0RQ2gOkonw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=B60XaKRw5kiBK054K7U+jib+5PdXf4lEksUwQNb1NWVmzdDWO4HSiDI/7vOQHjTiH a34CbmdY5vEOXrwr9EU5jANndisTaI+/IRthU5qTEvvz/OiRkyDIWzIkukPygjq7le wLSu3A281fmBNSlgWph1n9CReeXg6U+J8c36Tv9o= Date: Tue, 3 Mar 2020 15:24:07 +0100 From: Greg Kroah-Hartman To: Jann Horn Cc: Miklos Szeredi , Karel Zak , David Howells , Ian Kent , Christian Brauner , James Bottomley , Steven Whitehouse , Miklos Szeredi , viro , Christian Brauner , "Darrick J. Wong" , Linux API , linux-fsdevel , lkml , Jens Axboe Subject: Re: [PATCH 00/17] VFS: Filesystem information and notifications [ver #17] Message-ID: <20200303142407.GA47158@kroah.com> References: <1509948.1583226773@warthog.procyon.org.uk> <20200303113814.rsqhljkch6tgorpu@ws.net.home> <20200303130347.GA2302029@kroah.com> <20200303131434.GA2373427@kroah.com> <20200303134316.GA2509660@kroah.com> <20200303141030.GA2811@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 03, 2020 at 03:13:26PM +0100, Jann Horn wrote: > On Tue, Mar 3, 2020 at 3:10 PM Greg Kroah-Hartman > wrote: > > > > On Tue, Mar 03, 2020 at 02:43:16PM +0100, Greg Kroah-Hartman wrote: > > > On Tue, Mar 03, 2020 at 02:34:42PM +0100, Miklos Szeredi wrote: > > > > On Tue, Mar 3, 2020 at 2:14 PM Greg Kroah-Hartman > > > > wrote: > > > > > > > > > > Unlimited beers for a 21-line kernel patch? Sign me up! > > > > > > > > > > > > Totally untested, barely compiled patch below. > > > > > > > > > > Ok, that didn't even build, let me try this for real now... > > > > > > > > Some comments on the interface: > > > > > > Ok, hey, let's do this proper :) > > > > Alright, how about this patch. > > > > Actually tested with some simple sysfs files. > > > > If people don't strongly object, I'll add "real" tests to it, hook it up > > to all arches, write a manpage, and all the fun fluff a new syscall > > deserves and submit it "for real". > > Just FYI, io_uring is moving towards the same kind of thing... IIRC > you can already use it to batch a bunch of open() calls, then batch a > bunch of read() calls on all the new fds and close them at the same > time. And I think they're planning to add support for doing > open()+read()+close() all in one go, too, except that it's a bit > complicated because passing forward the file descriptor in a generic > way is a bit complicated. It is complicated, I wouldn't recommend using io_ring for reading a bunch of procfs or sysfs files, that feels like a ton of overkill with too much setup/teardown to make it worth while. But maybe not, will have to watch and see how it goes. > > It feels like I'm doing something wrong in that the actuall syscall > > logic is just so small. Maybe I'll benchmark this thing to see if it > > makes any real difference... > > > > thanks, > > > > greg k-h > > > > From: Greg Kroah-Hartman > > Subject: [PATCH] readfile: implement readfile syscall > > > > It's a tiny syscall, meant to allow a user to do a single "open this > > file, read into this buffer, and close the file" all in a single shot. > > > > Should be good for reading "tiny" files like sysfs, procfs, and other > > "small" files. > > > > There is no restarting the syscall, am trying to keep it simple. At > > least for now. > > > > Signed-off-by: Greg Kroah-Hartman > [...] > > +SYSCALL_DEFINE5(readfile, int, dfd, const char __user *, filename, > > + char __user *, buffer, size_t, bufsize, int, flags) > > +{ > > + int retval; > > + int fd; > > + > > + /* Mask off all O_ flags as we only want to read from the file */ > > + flags &= ~(VALID_OPEN_FLAGS); > > + flags |= O_RDONLY | O_LARGEFILE; > > + > > + fd = do_sys_open(dfd, filename, flags, 0000); > > + if (fd <= 0) > > + return fd; > > + > > + retval = ksys_read(fd, buffer, bufsize); > > + > > + __close_fd(current->files, fd); > > + > > + return retval; > > +} > > If you're gonna do something like that, wouldn't you want to also > elide the use of the file descriptor table completely? do_sys_open() > will have to do atomic operations in the fd table and stuff, which is > probably moderately bad in terms of cacheline bouncing if this is used > in a multithreaded context; and as a side effect, the fd would be > inherited by anyone who calls fork() concurrently. You'll probably > want to use APIs like do_filp_open() and filp_close(), or something > like that, instead. Ah, nice, that does make more sense. I'll play around with that, and benchmarking this thing later tonight. Have to go get some stable kernels out first... thanks for the quick review, much appreciated. greg k-h