Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp238471ybj; Fri, 8 May 2020 10:35:12 -0700 (PDT) X-Google-Smtp-Source: APiQypJhW8FspVMR128k2ujR8bW9lcZL5nNZY7lU7rmmcO2rthVS/ha/ejF3Xo/I2Kam+GY1kRfh X-Received: by 2002:a17:906:2ad4:: with SMTP id m20mr2945833eje.324.1588959312797; Fri, 08 May 2020 10:35:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588959312; cv=none; d=google.com; s=arc-20160816; b=KfSms9WKAhA/g7xrg7Cz+EMSMzfLoMU0BEqjJSoja3O7eiHp7jC8Q7Qw/kxnMORA3Z 65+XW4iArXQRgp6G6Ltq1TUI1L9VK+TPJDs2ZKiV26Sc21hUVIyKBL3Kvz6lFhGN70JK +ss4BTfbX4CfGcF0z/r8wzCmOhoJsdqL82+BRlQnWFlMdllzzFsfWYR18wandmFjSJLr iR4Rom81m4QJlpZW3j9O3me7YhR9hFgKjpNWmz0oQAer0HQo74OIpneNZXGgxhspWcdT Qjn9Mmj9nwbtIZM+uRx5iUFx2DUUnzq73L/Km/Qu1JK8+8qh8vjmYbzq3LC0S2psoEIH 3sHg== 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=8u1vbu5bJ69YihL8GWipXODDQVOvMStlxTqzIrRkPUQ=; b=so8AJL0kE1LGFwiy8OnykN87lDmhix3UY1HIFMM9p7/vYQNEpeplOYOyyWbUSVag7o vBCQ2Kqzz2M6xhulNRlAtknSEnLJ9ryZhpIgsw4raRtudkWDP6q14ZqTNXy60ArQLeFs RilFygTY0W4YEWnb40rK7pJEcuywKxy/bn1QunebXRxbt0wnxKam0NLwP9QwPn77WGse EU0SDd8SRe4TJswTzC3J9H4P4JLeo9dAA/YIBlL+cmzDK0NNJDjtNojN+28lxlzqo2Sj iPa9uXcaX1PCdEm4JxB2FMOKUktiM1mAnFbbkqd5YnDQImD8+1U58GIGrL3Umzhzn/S+ Uuzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CevGhA3d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id u1si1350682ejt.47.2020.05.08.10.34.49; Fri, 08 May 2020 10:35:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CevGhA3d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1727910AbgEHRcy (ORCPT + 99 others); Fri, 8 May 2020 13:32:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726746AbgEHRcx (ORCPT ); Fri, 8 May 2020 13:32:53 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62700C061A0C; Fri, 8 May 2020 10:32:53 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id h26so1926535qtu.8; Fri, 08 May 2020 10:32:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8u1vbu5bJ69YihL8GWipXODDQVOvMStlxTqzIrRkPUQ=; b=CevGhA3drB9rx9GAhf7Jd40EnNtr3XglCd18jTPTpJsgn56s0Q9ZugmY0aQqMnSGTH 7aagHQfF3X78TVXApqMaxjd66mhtOXvmL/4HYUWJW/adXA8e8n5GfPBPmQNAL19OfDE5 LKmSVl8km7PxkynymVQEPV4lk577a7G6pryLd8OTLGPtsbCEaAV29/jnVDoGOchK+oXF ADZkHhl+hkYYLZCeFVTd3IXBBgi7Vcs9qr0dwPmfQ9/ULwOPvDSa/PgxDmkfuyvSzJ6H sC+yukRWl+pPdTIl3k+mflFAJ1SndgezVfhRdzQGFW2qCsOZjs94dn27Zb6+yY1dofoM xFPQ== 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=8u1vbu5bJ69YihL8GWipXODDQVOvMStlxTqzIrRkPUQ=; b=RN422PLdjE8go6AuR72FJuTgiBzmtnpYBWzaGZYP3BNaZGF4ofuRufgeE4QXVRyFXS wT6Uqp4sZb8OzRfgzSlVEHpCPSzJHK4+SX0n2pLrZTG7qjNKk0W3Rvri0CJYSilJXc/H 4kL8nlGnSVgj6O0wEhLFBWL3sMvvQtsNBfHfbyLPqFUpfCXSsojm9Bi/u2vKBWbxJyUZ 5Rbzwv+mK39nx495fsByG58gzAwTOXGSK9UwSEBZJuJ1VYo5iWkDVYK3k/kBBMfEoXM6 eR17In0P35gkRK9xxc8aYddKHScusjFhJYNdGmUDIIBnISNwRrS1TqFdXqG+HzTdAwDP E0kA== X-Gm-Message-State: AGi0PuZ/W84N46cblyjD6WQwXcQ/wTq7XnqgYu3XaKJNd1Qcr0JiEJ15 xLZnwcQyn9sZVQX4X0JqcqDx0CoSRnww8Z3Mk1kJPgN0 X-Received: by 2002:ac8:51d3:: with SMTP id d19mr4033765qtn.141.1588959172426; Fri, 08 May 2020 10:32:52 -0700 (PDT) MIME-Version: 1.0 References: <20200508153634.249933-1-hch@lst.de> <20200508153634.249933-5-hch@lst.de> In-Reply-To: <20200508153634.249933-5-hch@lst.de> From: Andrii Nakryiko Date: Fri, 8 May 2020 10:32:41 -0700 Message-ID: Subject: Re: [PATCH 04/12] bpf: use __anon_inode_getfd To: Christoph Hellwig Cc: Alexander Viro , linux-integrity@vger.kernel.org, open list , linux-gpio@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, kvm@vger.kernel.org, linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, Networking , bpf 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 Fri, May 8, 2020 at 8:39 AM Christoph Hellwig wrote: > > Use __anon_inode_getfd instead of opencoding the logic using > get_unused_fd_flags + anon_inode_getfile. Also switch the > bpf_link_new_file calling conventions to match __anon_inode_getfd. > > Signed-off-by: Christoph Hellwig > --- > include/linux/bpf.h | 2 +- > kernel/bpf/cgroup.c | 6 +++--- > kernel/bpf/syscall.c | 31 +++++++++---------------------- > 3 files changed, 13 insertions(+), 26 deletions(-) > [...] > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c > index 64783da342020..cb2364e17423c 100644 > --- a/kernel/bpf/syscall.c > +++ b/kernel/bpf/syscall.c > @@ -2307,23 +2307,10 @@ int bpf_link_new_fd(struct bpf_link *link) > * complicated and expensive operations and should be delayed until all the fd > * reservation and anon_inode creation succeeds. > */ The comment above explains the reason why we do want to split getting fd, getting file, and installing fd later. I'd like to keep it this way. Also, this code was refactored in bpf-next by [0] (it still uses get_unused_fd_flag + anon_inode_getfile + fd_install, by design). [0] https://patchwork.ozlabs.org/project/netdev/patch/20200429001614.1544-3-andriin@fb.com/ > -struct file *bpf_link_new_file(struct bpf_link *link, int *reserved_fd) > +int bpf_link_new_file(struct bpf_link *link, struct file **file) > { > - struct file *file; > - int fd; > - > - fd = get_unused_fd_flags(O_CLOEXEC); > - if (fd < 0) > - return ERR_PTR(fd); > - > - file = anon_inode_getfile("bpf_link", &bpf_link_fops, link, O_CLOEXEC); > - if (IS_ERR(file)) { > - put_unused_fd(fd); > - return file; > - } > - > - *reserved_fd = fd; > - return file; > + return __anon_inode_getfd("bpf_link", &bpf_link_fops, link, O_CLOEXEC, > + file); > } > [...]