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 X-Spam-Level: X-Spam-Status: No, score=-21.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A629C43460 for ; Thu, 20 May 2021 18:36:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 02D0D610CC for ; Thu, 20 May 2021 18:36:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235506AbhETShn (ORCPT ); Thu, 20 May 2021 14:37:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233857AbhETShm (ORCPT ); Thu, 20 May 2021 14:37:42 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AA55C061574 for ; Thu, 20 May 2021 11:36:20 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id n129-20020a2527870000b02904ed02e1aab5so23661476ybn.21 for ; Thu, 20 May 2021 11:36:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=Y3E/s//jSqmr2fRbZ7hJsOKlIWD8vy2UGKXjvIPsYz0=; b=dvvcwuOwQ1etb2yg4Mmpz4XeM/8+ySJaOHOr1gM86Qo9W/48I9TARULwV/lVCORjxJ +oMnk/TaZMBlzBbfEsM8yI7MqNkr5B6NA73E09y7D+uB9m+oqTK7kC7U+50GtlCUmYMV YG5q/aY6/mcVrqYK1PuqCd2cteWBnYCdksEBGcoHvrVyI/iYnrFpMBhOBh5tW88osCvH gZVvfZTgRmx2Mm3N7om497biSj7/aEZw+HSgm7356PfeciivgzWoKilYtt2rSPuOsr0a Vf8vV0feJsl+/90eu9QabJNMIccWlx2B/CzPqQSzBeQeij2K7zHttz/UApik/Z51pp9l JmWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=Y3E/s//jSqmr2fRbZ7hJsOKlIWD8vy2UGKXjvIPsYz0=; b=RlvfY5BCdIdgNZgrsHSUVYMNcgZZFLVktaTNRtuM/gi8GfEaAe2i+U/aqUK9jLksDo I6NMKmUZHzyRjuaCjShd3nugn5fPtosQQVelOXtC3F/yZqzXm/CjFWlEFPZ1LneA/sYZ FS2Cbf11ecDepSJzFWn6By+ie15YMZPLl41ToJ/ZlJqFMRPSiSoEOSYn2utdz75MZIE5 uJAHs9HGA0m2Ig0nCqOjsrPT/XXycgSGYpGltd39WCFqalMuIi+OzIY6wR0pyGwlNot7 +yFrROr2zoFvgwfwRfG/JwgV7luwjvozfKv7T2Vt+lqP3Lqnz8rWXCeOKb9axmQu1C1P qKIw== X-Gm-Message-State: AOAM532wkK5wLuyY6lv8lHpcTPHguxPJXferd8AnoccVYItS/JMB2CVl ppY4YzM7Tb0TB9XK7PalW9Hpy161 X-Google-Smtp-Source: ABdhPJzZCcXASkNwHd8nRTCHe6xe24/QF3Drz0lv3ukNETTNPqiXSf3LW5YEfINbHHHOHps6bSrNU8Fr X-Received: from posk.svl.corp.google.com ([2620:15c:2cd:202:f13e:18cf:76e6:2dc4]) (user=posk job=sendgmr) by 2002:a25:6c07:: with SMTP id h7mr9338929ybc.317.1621535779774; Thu, 20 May 2021 11:36:19 -0700 (PDT) Date: Thu, 20 May 2021 11:36:05 -0700 Message-Id: <20210520183614.1227046-1-posk@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.1.818.g46aad6cb9e-goog Subject: [RFC PATCH v0.1 0/9] UMCG early preview/RFC patchset From: Peter Oskolkov To: Peter Zijlstra , Ingo Molnar , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org Cc: Paul Turner , Ben Segall , Peter Oskolkov , Peter Oskolkov , Joel Fernandes , Andrew Morton , Andrei Vagin , Jim Newsome Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As indicated earlier in the FUTEX_SWAP patchset: https://lore.kernel.org/lkml/20200722234538.166697-1-posk@posk.io/ "Google Fibers" is a userspace scheduling framework used widely and successfully at Google to improve in-process workload isolation and response latencies. We are working on open-sourcing this framework, and UMCG (User-Managed Concurrency Groups) kernel patches are intended as the foundation of this. This patchset is "early preview/RFC" - an earlier version of the "core UMCG API" was discussed offlist, and I was asked to post "what I have" to LKML before I consider the work ready for a full review. Notes: - the first six patches cover "core UMCG API" and are more "ready" than the last three, in the sense that I expect to see few, if any, material changes to them, unless the whole approach is NACKed; - the last three patches cover "server/worker UMCG API" and need more work and testing: - while I'm not aware of any specific issues with them, I have not implemented and/or tested, yet, many important use cases, such as: - tracing - signals/interrupts - explicit preemption of workers other than cooperative wait/swap - comments/documentation is missing in many important places, or maybe even wrong/outdated. As such, please pay more attention to the high-level intended behavior and design than to things like patch organization, contents of commit messages, comments or indentation, especially in the last three patches. Unless the feedback here points to a different approach, my next step is to add timeout handling to sys_umcg_wait/sys_umcg_swap, as this will open up a lot of Google-internal tests that cover most of use/corner cases other than explicit preemption of workers (Google Fibers use cooperative scheduling features only). Then I'll work on issues uncovered by those tests. Then I'll address preemption and tracing. This work is loosely based on Google-internal SwitchTo and SwitchTo Groups kernel patches developed by Paul Turner and Ben Segall. Peter Oskolkov (9): sched/umcg: add UMCG syscall stubs and CONFIG_UMCG sched/umcg: add uapi/linux/umcg.h and sched/umcg.c sched: add WF_CURRENT_CPU and externise ttwu sched/umcg: implement core UMCG API lib/umcg: implement UMCG core API for userspace selftests/umcg: add UMCG core API selftest sched/umcg: add UMCG server/worker API (early RFC) lib/umcg: add UMCG server/worker API (early RFC) selftests/umcg: add UMCG server/worker API selftest arch/x86/entry/syscalls/syscall_64.tbl | 11 + include/linux/mm_types.h | 5 + include/linux/sched.h | 7 +- include/linux/syscalls.h | 14 + include/uapi/asm-generic/unistd.h | 25 +- include/uapi/linux/umcg.h | 70 ++ init/Kconfig | 10 + kernel/fork.c | 11 + kernel/sched/Makefile | 1 + kernel/sched/core.c | 17 +- kernel/sched/fair.c | 4 + kernel/sched/sched.h | 15 +- kernel/sched/umcg.c | 1114 +++++++++++++++++ kernel/sched/umcg.h | 96 ++ kernel/sys_ni.c | 13 + mm/init-mm.c | 4 + tools/lib/umcg/.gitignore | 4 + tools/lib/umcg/Makefile | 11 + tools/lib/umcg/libumcg.c | 572 +++++++++ tools/lib/umcg/libumcg.h | 262 ++++ tools/testing/selftests/umcg/.gitignore | 3 + tools/testing/selftests/umcg/Makefile | 15 + tools/testing/selftests/umcg/umcg_core_test.c | 347 +++++ tools/testing/selftests/umcg/umcg_test.c | 475 +++++++ 24 files changed, 3096 insertions(+), 10 deletions(-) create mode 100644 include/uapi/linux/umcg.h create mode 100644 kernel/sched/umcg.c create mode 100644 kernel/sched/umcg.h create mode 100644 tools/lib/umcg/.gitignore create mode 100644 tools/lib/umcg/Makefile create mode 100644 tools/lib/umcg/libumcg.c create mode 100644 tools/lib/umcg/libumcg.h create mode 100644 tools/testing/selftests/umcg/.gitignore create mode 100644 tools/testing/selftests/umcg/Makefile create mode 100644 tools/testing/selftests/umcg/umcg_core_test.c create mode 100644 tools/testing/selftests/umcg/umcg_test.c -- 2.31.1.818.g46aad6cb9e-goog