From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D330C54EBC for ; Tue, 10 Jan 2023 21:31:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232392AbjAJVbU (ORCPT ); Tue, 10 Jan 2023 16:31:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234562AbjAJVaS (ORCPT ); Tue, 10 Jan 2023 16:30:18 -0500 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0D9063395 for ; Tue, 10 Jan 2023 13:30:17 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id n1-20020a170902e54100b00192cc6850ffso9176876plf.18 for ; Tue, 10 Jan 2023 13:30:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:from:to:cc:subject:date:message-id:reply-to; bh=kR7E5lKTXGCIxIfu8WA7EkUmjLuM6fKOUzhK6YsIuhE=; b=U0vOf0BGKvhCP7pKH7UBvRVAOBoVvHGWrq1IH/IgkCmbZCucOkfHG2cgyi3w0M3S31 d1hVJ9WAUpxce+9HpybH0qgBtL++HpMxBdhAkx70EfjwJ31A0uAjm42l9I6aIZFSve8w wtf47yDgbxGwXSmASNCJMqBJD0ZYeGmOxJ2fWsGo9dmoWDrcuCTq6eScCuSpW2g+MFCU LdrIFKuy8SMyInFJnUsFugLrtIVUEsUod/UAmhro/LP2EIndNOiZAXoKcRgOQFG+qdRp XCe6kSj6FmCFHLZvIa6GsiM+O+LCQMMXix2uNmxZ9/6UAN5/KySv66cBv+Q1VuKo60Jv 0lRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=kR7E5lKTXGCIxIfu8WA7EkUmjLuM6fKOUzhK6YsIuhE=; b=k2eD68FdRi4YLsRMSFMiBj9Szmd4N6XfoqEMGjmAiSn6i5YRKo8VpERS9jl0NGcRuq mPJ7htSEzcBcoxi5/ffeVt7InD6kVMgxiAruRDC1IimPK/iCYbaumNXvKByW6hKwpiBV ZB5O8g6Crhpkk6ke+f3FJlVba11l7Mo++OVH4dzhaeg/Ko6kvPyEjVH6b+BWlnfRj9pO 0hVjGDEEaLEdd+xkUapbwx9V7nVndQKosTWmL1GJLgGwgcuV2nRvBt5c2Da75Sd8QGkD mHtrVGGZlpZhc8JmLqjpcAgeXeyV8IFg3CEF840TvAWMraJ5DePIoq1M8hOC+usCOgij N1dg== X-Gm-Message-State: AFqh2kpiFwrmmxSGfPlgIMtc9rN+jysS/MCaNKotuyd2sXR3+RHlKS9G E4x1Bc9BlAZK6r/g92dgzqWBmUinxu0= X-Google-Smtp-Source: AMrXdXsfrknjaRrq4LcfwjupZceQ0hZxQx6onuFm29uy247QqRuRQoGk9l9LaV9iNcdgL35Ar4M3W8fy7lo= X-Received: from avagin.kir.corp.google.com ([2620:0:1008:11:6203:13b5:2d85:b75c]) (user=avagin job=sendgmr) by 2002:a17:902:b613:b0:193:37c2:89d1 with SMTP id b19-20020a170902b61300b0019337c289d1mr627749pls.80.1673386217384; Tue, 10 Jan 2023 13:30:17 -0800 (PST) Date: Tue, 10 Jan 2023 13:30:05 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20230110213010.2683185-1-avagin@google.com> Subject: [PATCH 0/5 v3 RESEND] seccomp: add the synchronous mode for seccomp_unotify From: Andrei Vagin To: Peter Zijlstra , Ingo Molnar , Vincent Guittot , Dietmar Eggemann Cc: linux-kernel@vger.kernel.org, Kees Cook , Christian Brauner , Andrei Vagin , Andy Lutomirski , Juri Lelli , Peter Oskolkov , Tycho Andersen , Will Drewry Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrei Vagin seccomp_unotify allows more privileged processes do actions on behalf 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 back to the target process. In this context, "synchronous" means that only one process is running and another one is waiting. The new WF_CURRENT_CPU flag advises the scheduler to 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 abou= t 3=C2=B5s. v2: clean up the first patch and add the test. v3: update commit messages and a few fixes suggested by Kees Cook. Kees is ready to take this patch set, but wants to get Acks from the sched folks. Cc: Andy Lutomirski Cc: Christian Brauner Cc: Dietmar Eggemann Cc: Kees Cook Cc: Ingo Molnar Cc: Juri Lelli Cc: Peter Oskolkov Cc: Peter Zijlstra Cc: Tycho Andersen Cc: Will Drewry Cc: Vincent Guittot Andrei Vagin (4): seccomp: don't use semaphore and wait_queue together sched: add a few helpers to wake up tasks on the current cpu seccomp: add the synchronous mode for seccomp_unotify selftest/seccomp: add a new test for the sync mode of seccomp_user_notify Peter Oskolkov (1): sched: add WF_CURRENT_CPU and externise ttwu include/linux/completion.h | 1 + include/linux/swait.h | 1 + include/linux/wait.h | 3 + include/uapi/linux/seccomp.h | 4 + kernel/sched/completion.c | 12 +++ kernel/sched/core.c | 5 +- kernel/sched/fair.c | 4 + kernel/sched/sched.h | 13 +-- kernel/sched/swait.c | 11 +++ kernel/sched/wait.c | 5 ++ kernel/seccomp.c | 72 +++++++++++++-- tools/testing/selftests/seccomp/seccomp_bpf.c | 88 +++++++++++++++++++ 12 files changed, 204 insertions(+), 15 deletions(-) --=20 2.37.2