Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2898734pxj; Mon, 17 May 2021 12:30:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjtNYFD4RvRPWSxderuUIWUX1zU4wzJb+LmPIgU0lBrV7jUAqBb498t0xsOqgA01LQg+Qf X-Received: by 2002:a17:906:26d3:: with SMTP id u19mr1602514ejc.128.1621279852824; Mon, 17 May 2021 12:30:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621279852; cv=none; d=google.com; s=arc-20160816; b=gzvS54v90kEHEuIV0DeYgSKAOWO68KIWjcf/MurKjtN3mXkFEabibVqOkVCwwCtS2F C4+j9oK64Ibq45BkiZvRve1gsQuEC0LcnVn9EkZRUiCJEI/ARRnni/2pp8rsGmFUwXJk rEMpgcRb3HkOXOxDbuwihMX9Bh3m1yQBKMIB1XXU7cpfT2GatHZ002SuIMFNl9yYuJgI DP6uKTtAQGpaLe1pUUUAiEw+0Arq8CjyLHlxq6tcL1r5Mr2tpLNimXCZpFqKcQtUNr9u VFKW9NPALSU/ghcpuCGvlWpZdte0JzsbugFy69GsZeca0sDzN7C+9mbC0o1qBtaMOVM/ raQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=MQyS3XJe4AKUr1SWVpgv2bs2/GuaT0/cfk3NUPLHQ08=; b=lgBGCppUOLebybsrNpooV02OIVIaoOPt26SkAsselLj8yGGLwL19eWnh5QJW1WxkjW RRJTuaFRCWl/WhxlXhioursW65pr6kQNi3ZFokL+Gl2VFsftH+nhuUIsKGx2B02o9Zup btD8pAdc++Mw1DEIQu9wTRpnKEHMIclFKTqCEnIjQgWQZcLhyFQCk04yg4bnJxoDgvP2 Bmpfu6jbk4UBLc33VbqJf/K7qZFOQDPmqNU3AAyorwCUdFTBj9BC6zgeBhiHbhvcAalO f3GVEGD6s+8ujM5/h7Ca5PrJlqJ/IQaps1W3xhBw7cxIGgvtq97eMEv3OBzkQbU0HbOP SJ8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dGZa+sD+; 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 j7si18002356ejm.492.2021.05.17.12.30.24; Mon, 17 May 2021 12:30:52 -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=dGZa+sD+; 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 S237219AbhEQNW5 (ORCPT + 99 others); Mon, 17 May 2021 09:22:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234106AbhEQNW5 (ORCPT ); Mon, 17 May 2021 09:22:57 -0400 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C9F2C061573; Mon, 17 May 2021 06:21:40 -0700 (PDT) Received: by mail-il1-x134.google.com with SMTP id c16so6084384ilo.1; Mon, 17 May 2021 06:21:40 -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=MQyS3XJe4AKUr1SWVpgv2bs2/GuaT0/cfk3NUPLHQ08=; b=dGZa+sD+S3wBlqHS13HTMc3qEXBZLPBYHl6BzQZzo9YDo6xgCbxZyRBv5dPWN+Aj9L 5m+gBW3elWiEH7YYw1YDfUkyxWfDPPqQxiRJnWie+1BAuI1K3qhY/OU/OybuLQZ9AzOs Qi3ZJhM78kbmVyR4L2tHQbyGIJUatgoOlyntKgySbRe3pzGu14J5lHdEwgpUM2v6/Arr 3kmGliEVdHpb3sAahauZ8+h5/NtAfir4P/d+gCKT40KgKS/F/UScpMo8v+UTqDep7Fgk 0D8hQ64XCZn+yrNKgGyeHA0kCSyXgB798DA42Fbg6wRF4mYNdg67YqYBMM/a7gXm1axW 26FQ== 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=MQyS3XJe4AKUr1SWVpgv2bs2/GuaT0/cfk3NUPLHQ08=; b=ilP/gMZ7ezYjnyFZKAkBbsOKVqAQ13gSrgrznCozOS/+14594nWQYF3IOXpu4FNz4F qxdplFxGmsx4j+x1MUeEURBRrZb+1plASByeGIbUxoG/pZ0/BGhC9yphnWVwJa+H5PCE 56WyfB3XQPFzmKa1LIcJNDK0e6eoZ9W/73ghl288oMBRFevTu22WUSkfbjCt6ePyPvlK hgRfIBdnODHOT2JC+/BocY+jsLdSnzT63KGNtm2F82XeaebJuhzm73h6Tom1CpxqKjzu jYJo7uGs/1lN9hFhhV6bVZeb1FYRCF/6lp86kVViRb/ZhxhMC9DRobA7CS+lpLjNAoOr ymlg== X-Gm-Message-State: AOAM5313RchiT8AK9e1NtE9nVVRE8N8JvLwlkXoGQgrZOI6ddny20QIi 4DZe+a36V54Y1qSVRI2bjpZO8tHYClFQNP8hjVC5290V3bo= X-Received: by 2002:a92:cc43:: with SMTP id t3mr4301180ilq.250.1621257699449; Mon, 17 May 2021 06:21:39 -0700 (PDT) MIME-Version: 1.0 References: <20210125153057.3623715-1-balsini@android.com> <20210125153057.3623715-5-balsini@android.com> In-Reply-To: From: Amir Goldstein Date: Mon, 17 May 2021 16:21:28 +0300 Message-ID: Subject: Re: [PATCH RESEND V12 4/8] fuse: Passthrough initialization and release To: Alessio Balsini Cc: Miklos Szeredi , Akilesh Kailash , Antonio SJ Musumeci , David Anderson , Giuseppe Scrivano , Jann Horn , Jens Axboe , Martijn Coenen , Palmer Dabbelt , Paul Lawrence , Peng Tao , Stefano Duo , Zimuzo Ezeozue , wuyan , fuse-devel , kernel-team , linux-fsdevel , linux-kernel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > I have an ugly patch which uses IDR as Miklos asked, but unfortunately > I'm facing some performance issues due to the locking mechanisms to keep > guarantee the RCU consistency. I can post the new patch set as an RFC > soon for the community to take a look. > At a glance what happens is: > - the IDR, one for each fuse_conn, contains pointers to "struct > fuse_passthrough" containing: > - fuse_file *: which is using passthrough, > - file *: native file system file target, > - cred of the FUSE server, > - ioctl(PASSTHROUGH_OPEN): updates IDR, requires spinlock: > - kmalloc(fuse_passthrough), update file and cred, > - ID = idr_alloc(), > - return ID, > - fuse_open reply from FUSE server with passthrough ID: updates IDR, > requires spinlock: > - pt = idr_find(ID), > - update fuse_file with the current fuse_file, > - update fuse_file->passthrough_id = ID, > - idr_replace(), > - read/write/mmap: lock-free IDR read: > - idr_find(fuse_file::passthrough_id), > - forward request to lower file system as for the current FUSE > passthrough patches. > - ioctl(PASSTHROUGH_CLOSE): updates IDR, requires spinlock: > - idr_remove(); > - call_rcu(): tell possible open fuse_file user that the ID is no more > valid and kfree() the allocated struct; > - close(fuse_file): updates IDR, requires spinlock: > - ID = fuse_file::passthrough_id > - idr_find(ID), > - fuse_passthrough::fuse_file = NULL, > - idr_replace(). > > This would be fine if passthrough is activated for a few, big files, > where the passthrough overhead is dominated by the direct access > benefits, but if passthrough is enabled for many small files which just > do one or two read/writes (as what I did for my benchmark of total build > time for the kernel, where I was passing-through every opened file), the > overhead becomes a real issue. > > If you have any thoughts on how to make this simpler, I'm absolutely > open to fix this. > This IDR namespace usually serves a single process. Right? It sounds a bit more like a file table, more specifically, like io_file_table. I may be way off, but this sounds a bit like IORING_REGISTER_FILES. Is there anything that can be learned from this UAPI? Maybe even reuse of some of the io_uring file register code? Thanks, Amir.