Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3766360rwl; Mon, 10 Apr 2023 00:12:31 -0700 (PDT) X-Google-Smtp-Source: AKy350YNNzHq7Dsv6R3LrctddkX4mxz3nkf24JhTP7tCtjZQkITer4VNYh1gzA0z7KGKRVE2y5M1 X-Received: by 2002:a17:906:784:b0:91f:b13f:a028 with SMTP id l4-20020a170906078400b0091fb13fa028mr5566404ejc.34.1681110751277; Mon, 10 Apr 2023 00:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681110751; cv=none; d=google.com; s=arc-20160816; b=Uyxgg3Ig+aEM4nK3PIBgg9FVHsV45X5T0he7+6VyTeCUoPGt939v9YZbl4wjk0TBxo aJVYJrp7kppTARE6Q0/ZgL/LtS5RRlcModzvZnwwbL5/RjwdunXfZWKc/5kOsnf69iH2 1QeTo53pk561mHcFWfjte1zDV0i9KzeoT1R93u6RBhMIXzTQ1lbAgV+Cyx+n9yOrc2jt sv7jan6udo3iUIrSbZ5BH20hNBpWD2vK+M4s2wOo6TXWwWq5Y/BQ+ZVmG3LA9FY2wpQo XMy/pKfJD7CE/h8vFl501McmgyanLJcSrm6bnRgsKUawpNWHh6tlFNv9QialSjiIMgFT BoHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=nePYi444oFSBNCNb1sIZeCx0m02UrkHlr/iQVGosHSc=; b=mJdhFCZGRujDjuZch4VkJppjUAoxLgzJ+H3buS0wpSTVWoxET8A1mhVEDMKUBiSHs8 MxQ/XF9iFfweFtWdpwzGM3BcDKN3NfurdobzNhQxSsG1bNOxswRda6f05+o50U8LQs2S A8fCCfbXbYGDAQaAXCJL/TAuFaK4hLJXqj0ST8fA6CxzTqZ5tVPtIEgab+QhNutQTOQZ fLpVk12pRyDaVZBtVkFHqMFSHkQpNBQOiF4FfNiKn1k/qnjtM5ZHOA+5EhalFJ6Pv409 gfsFkrYsLJhAFAkB777QZhSVMIf64ovUcmCe4V7ksr4bPx7p4K26mZScOczhsc7sd8Fj y0fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VX0v1TPr; 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 hs2-20020a1709073e8200b0094a53055e0fsi4491468ejc.67.2023.04.10.00.12.06; Mon, 10 Apr 2023 00:12:31 -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=20210112 header.b=VX0v1TPr; 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 S229558AbjDJG7y (ORCPT + 99 others); Mon, 10 Apr 2023 02:59:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbjDJG7w (ORCPT ); Mon, 10 Apr 2023 02:59:52 -0400 Received: from mail-ua1-x92f.google.com (mail-ua1-x92f.google.com [IPv6:2607:f8b0:4864:20::92f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 344671FD7 for ; Sun, 9 Apr 2023 23:59:48 -0700 (PDT) Received: by mail-ua1-x92f.google.com with SMTP id z23so2807224uav.8 for ; Sun, 09 Apr 2023 23:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1681109987; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=nePYi444oFSBNCNb1sIZeCx0m02UrkHlr/iQVGosHSc=; b=VX0v1TPr9/I0ciSXfLyT0vVm2nE+3H/S8FiRu5eDBB/FckvIiF5WyWr23EmFe2+xoE 7z0szfsccdHXC4RDFgHpRtqfhUSAjeS6Veu6UlFg7aqFXhU08mljKQSN+6u5bdD5Fves FyBZZP++BgFF7kaZxMfABcbEf2nQ24+bBLW6bdEFBR0Fjw2O8JkVBMR5Lp9/ubrqGsnH bmafk+pXt5TiZD39Y/cnDQN/bvZOc/CgLrL4i2zQ6w0Wec2OEUMx0R+XO83MERrpxEG4 I/QcH5IF43GIyZRFMpX9HCeRDycRyVeucDcpWoqo78+UX0Az7TTgvNazhIgaIN/5K1Oc Oibg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681109987; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nePYi444oFSBNCNb1sIZeCx0m02UrkHlr/iQVGosHSc=; b=nQALRnY+X7MmGca2UmvuDnXZ+m/19T3MEzC6jEJSaQuTPm07X7n702sV6+ayhahHBq IgTR3Xu96VVi2iQtSh6NgoDtAhkXYdX+Yx2hurYVR4J/pzTa6phyypheyKp0rrg4Gim7 5DFi8r2CY55wr7hT1+g7/fV7kU4X5L4aI+b6ttscFt3/LwQUzXu/IQk33scWqa/arvRN 3Bbtm7Okf52akRJGMuzEbTP7vQcLJmOf1FFTqU7TZl0CFffiCVgarZCw82PloTT1g+/a pNMpuD5LnWuKnhPf/KitX0x3bx2cWcNypkjVBw46CXFwNObm7RUSyPzRF900nKyaTDEb 5Z0A== X-Gm-Message-State: AAQBX9fJSIRBP+zHf7nPvrm2PjCmWQCRzXfuinbJdKZ5jU57UjfewNZn cOpM0g46gvvtXsZZDse2P8hdn3xpjcAJcX+faec= X-Received: by 2002:a05:6122:a26:b0:43f:c5d4:cddb with SMTP id 38-20020a0561220a2600b0043fc5d4cddbmr1562278vkn.1.1681109987141; Sun, 09 Apr 2023 23:59:47 -0700 (PDT) MIME-Version: 1.0 References: <20230308073201.3102738-1-avagin@google.com> <20230308073201.3102738-5-avagin@google.com> In-Reply-To: From: Andrei Vagin Date: Sun, 9 Apr 2023 23:59:35 -0700 Message-ID: Subject: Re: [PATCH 4/6] seccomp: add the synchronous mode for seccomp_unotify To: Andy Lutomirski Cc: Andrei Vagin , Kees Cook , Peter Zijlstra , linux-kernel@vger.kernel.org, Christian Brauner , Chen Yu , Dietmar Eggemann , Ingo Molnar , Juri Lelli , Peter Oskolkov , Tycho Andersen , Will Drewry , Vincent Guittot Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 Wed, Apr 5, 2023 at 8:42=E2=80=AFPM Andy Lutomirski wr= ote: > > On Tue, Mar 7, 2023 at 11:32=E2=80=AFPM Andrei Vagin = wrote: > > > > seccomp_unotify allows more privileged processes to do actions on behal= f > > of less privileged processes. > > > > In many cases, the workflow is fully synchronous. It means a target > > process triggers a system call and passes controls to a supervisor > > process that handles the system call and returns controls to the target > > process. In this context, "synchronous" means that only one process is > > running and another one is waiting. > > > > There is the WF_CURRENT_CPU flag that is used to advise the scheduler t= o > > move the wakee to the current CPU. For such synchronous workflows, it > > makes context switches a few times faster. > > > > Right now, each interaction takes 12=C2=B5s. With this patch, it takes = about > > 3=C2=B5s. > > This is great, but: > > > > > This change introduce the SECCOMP_USER_NOTIF_FD_SYNC_WAKE_UP flag that > > it used to enable the sync mode. > > Other than being faster, what does this flag actually do in terms of > user-visible semantics? In short, the process handling an event wakes up on the same cpu where the process that triggered the event has been running. Knowing this fact, the u= ser can understand when it is appropriate to use this flag. Let's imagine that we have two processes where one calls syscalls (the target) and another one handles these syscalls (the supervisor). In this ca= se, the user should see that both processes are running on the same cpu. If we have one target process and one supervisor process, they synchronousl= y swap with each other and don't need to run on cpu concurrently. But it becomes more complicated if one supervisor handles a group of target processes. In this case, setting the SECCOMP_USER_NOTIF_FD_SYNC_WAKE_UP flag depends on the frequency of events. If the supervisor often has pending events (doesn't sl= eep between events), it is better to unset the flag or add more supervisor processes. Thanks, Andrei