Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4722981rwb; Tue, 8 Aug 2023 12:46:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHmZ9459vs9WrmYpWRHY+Ln2ZpYifVukdWp/pjJfRke7OKo3fjVBFU5IWTkCCjIOCIK7MUy X-Received: by 2002:a50:fa90:0:b0:523:1fa2:4f40 with SMTP id w16-20020a50fa90000000b005231fa24f40mr774520edr.19.1691523972427; Tue, 08 Aug 2023 12:46:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691523972; cv=none; d=google.com; s=arc-20160816; b=0/wPEokkbgQKi47cBek4y0reYV9mm81YczRu+U94ISbToh5NEDbFV37fkP6HI1zBYx YGxCR2Jy8w13kVs+P5gW3ViHFraP0NsArNAjKcnAHyf9MnkXEjSWgCww28BZvoDo/XFb n/JGmMWSFoXqfMN7si4P02DDfcdebq7bNcHpb658r1o9CXYt6hfh8CGKPl0njjxcPZXL deB/AlOvjODDsRtRihJtuw+Qmtf9Mg56lQlTOeeS0RtXsxL0nwvx0vmCZmNtE7OJZLi1 hwtxM8NoPjziRMUV5P90wDRY9I/wPE0JhYrPPCi2XCWAPDgG0jRkPQMr8bs26EI26dBG RCLw== 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:references :in-reply-to:mime-version:dkim-signature; bh=ydoHcaR3qJjLpJCuAxkO8+WkH13peeHQF52+Jhcd9Uk=; fh=ev8n9ramXAawqsgqA5u1Xbfq7ktvxkrNMCuDXIZliDE=; b=NunBoSQSQMK/GZrdYwBZLACParfVWq+2tmJuXY/Mjyzcd35/1O49ODDpY9Oc1k2c+N dHyAJA19hN1HlCwIFWmwl+O3C4QIxrCVFCwGk9Bjf5bX/Xc9TUGzMMsLrVnxwJAe67jd alDc5wtQWns1YX5ghSbmPmBDQ8zy4uJz5+Mh0K/PMr1ULfxayzaPqHVzMQFG2bgSQTE0 nvDuxI9lrzWOoWZr0kgPxE7nGrrKCagB/Ho4jeE2E8BB7pGbh5CFzzqAwHSLVXNKKp0c vfrP22ZvN3fZKKQ6vSeGm6gC3KGnXcJ42ik/L7aWlZGBBXRRyhL2gV2N+gLrOHe8EidL iYAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=YfUg7ZQj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w2-20020a50fa82000000b005234011bb47si2437268edr.679.2023.08.08.12.45.48; Tue, 08 Aug 2023 12:46:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=YfUg7ZQj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S235030AbjHHSR2 (ORCPT + 99 others); Tue, 8 Aug 2023 14:17:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234765AbjHHSQx (ORCPT ); Tue, 8 Aug 2023 14:16:53 -0400 Received: from mail-oo1-xc31.google.com (mail-oo1-xc31.google.com [IPv6:2607:f8b0:4864:20::c31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F5631795BA; Tue, 8 Aug 2023 10:24:03 -0700 (PDT) Received: by mail-oo1-xc31.google.com with SMTP id 006d021491bc7-56c8757d45bso3893638eaf.2; Tue, 08 Aug 2023 10:24:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691515442; x=1692120242; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ydoHcaR3qJjLpJCuAxkO8+WkH13peeHQF52+Jhcd9Uk=; b=YfUg7ZQjJ6Yrr5NI1qwvSf+/2KGuJCwneosLI1dKkfmo5X+mo0e3b2klj2v9dEkm+h 9Id72xB06SRDia4snQqWhxgvje7TQ6ANQNRdvVUd4XTQGD45iXMjIbfQ90qEBa0FGZ5V i7zwUauzHYT5+uy9v1/Zm0EVr7Um0CnTU4XsG5goTpvijq4sYM4pF1S/VcZcPOyyDnIp k0XPpnvDJlqOgVkxaTEdYip2EMi4VEzm5F9Im/94hkuzzZphAIQhNpZT+pP229xjx6YZ bLbIzHgh3sTnogp9VNrNif0KcSOxyBlckHTdrw4vwxoJITYUslkUH7P2EHGlHxsD8/S6 fE3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691515442; x=1692120242; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ydoHcaR3qJjLpJCuAxkO8+WkH13peeHQF52+Jhcd9Uk=; b=lVQwEEHQ95WMMxQw20/Ook1LBPVS4DxpulQrhdQrbb4B7JhM8steyXkwM6q1yH0epJ BfwnS4LMyWeBHWAVrBWMWQOcXl8LiVGROK/RM2AY6dSSva+mQQjIttUPLJv0H/FGg+/u A/r6pOG1HfPbEtYP1lvP13qYHw9kgmJgmo9cI7vJIf/5YpGkXQm6fhBkIiA+KickmvCQ c6fhN1TixQgUv3+TWXmLZdmQUwxaQyprVT2DvnGA3z+IXeQpaOoOwWV69bEFserX4Vzr dsItr1f+AP/q81JRpTQdE+JIZWldxOECN1ZLhdSwRwIh/U8wJJJCvzdBmQybcPrznvke Icpw== X-Gm-Message-State: AOJu0YwcMT+DU4cLZrlP6A5qPbd5gfjECERc6mDLpdE/XiokmkeM+3/j Yl45+uNer25gVm6RTed0mEFACDQfp7DO+caoYWc= X-Received: by 2002:a4a:3818:0:b0:56c:e856:8b2c with SMTP id c24-20020a4a3818000000b0056ce8568b2cmr478061ooa.9.1691515442300; Tue, 08 Aug 2023 10:24:02 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a8a:129a:0:b0:4f0:1250:dd51 with HTTP; Tue, 8 Aug 2023 10:24:01 -0700 (PDT) In-Reply-To: References: <20230806230627.1394689-1-mjguzik@gmail.com> <87o7jidqlg.fsf@email.froward.int.ebiederm.org> From: Mateusz Guzik Date: Tue, 8 Aug 2023 19:24:01 +0200 Message-ID: Subject: Re: [PATCH] fs: use __fput_sync in close(2) To: Linus Torvalds Cc: "Eric W. Biederman" , viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, oleg@redhat.com, Matthew Wilcox , Christian Brauner Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/8/23, Linus Torvalds wrote: > On Tue, 8 Aug 2023 at 10:10, Mateusz Guzik wrote: >> >> Few hours ago I sent another version which very closely resembles what >> you did :) >> 2 main differences: >> - i somehow missed close_fd_get_file so I hacked my own based on close_fd >> - you need to whack the kthread assert in __fput_sync > > Good call on teh __fput_sync() test. > > That BUG_ON() made sense ten years ago when this was all re-organized, > not so much now. > Christian proposes a dedicated routine, I have 0 opinion, you guys sort it out ;) >> I'm offended you ask, it's all in my opening e-mail. > > Heh. I wasn't actually cc'd on that, so I'm going by context and then > peeking at web links.. > Here it is again with some typos fixed and slightly reworded, not necessarily with quality of English improved. Feel free to quote in whatever extent in your commit message (including none). [quote] fs: use __fput_sync in close(2) close(2) is a special case which guarantees a shallow kernel stack, making delegation to task_work machinery unnecessary. Said delegation is problematic as it involves atomic ops and interrupt masking trips, none of which are cheap on x86-64. Forcing close(2) to do it looks like an oversight in the original work. Moreover presence of CONFIG_RSEQ adds an additional overhead as fput() -> task_work_add(..., TWA_RESUME) -> set_notify_resume() makes the thread returning to userspace land in resume_user_mode_work(), where rseq_handle_notify_resume takes a SMAP round-trip if rseq is enabled for the thread (and it is by default with contemporary glibc). Sample result when benchmarking open1_processes -t 1 from will-it-scale (that's an open + close loop) + tmpfs on /tmp, running on the Sapphire Rapid CPU (ops/s): stock+RSEQ: 1329857 stock-RSEQ: 1421667 (+7%) patched: 1523521 (+14.5% / +7%) (with / without rseq) Patched result is the same regardless of rseq as the codepath is avoided. [/quote] -- Mateusz Guzik