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=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no 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 D3218C4320A for ; Mon, 26 Jul 2021 16:47:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B4D4C60EB2 for ; Mon, 26 Jul 2021 16:47:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239864AbhGZQGc (ORCPT ); Mon, 26 Jul 2021 12:06:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240780AbhGZQFA (ORCPT ); Mon, 26 Jul 2021 12:05:00 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55C0EC0617A1 for ; Mon, 26 Jul 2021 09:44:41 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id m13so16566455lfg.13 for ; Mon, 26 Jul 2021 09:44:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DlqUXAYss0z4CwOkVfGtreR6OseE/eXEXPezp0fcD5Q=; b=v/GwQOc/nfVoJOaP+06LI0uq/yjmmZ5T1xMXwDdNwHDrRxLXrNQwJP1e4uwRyy/xrp IOsfYH+cdtu62lwlEx6yb2NTKwdzZFS458KkFOrWnizERkKOK6i0bQGNnwFSRZz/fWGp IUKWriV5wMB6wC/h+yVzUQwFI1DpjFLSud5NrBDizwqsJstnZB+Xp9j+SsylMZ8dAMa0 c5vGk2HKgYounGCCH8vn5pJBitXuNwTgVHaH2TLqdTMi19u/hzVUfmrugGVmb0G267k4 qqIiLUiCwPOwDvDOINBK5Mr9CyRbvnH0wmr+ej6s4ON7UwpM6YzmX8c1kKl6VEmKwpnO IOCg== 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=DlqUXAYss0z4CwOkVfGtreR6OseE/eXEXPezp0fcD5Q=; b=cBDjrzRr6xaDda9CApehZmWc7wV2GTaILNmmlsFc4jKOr+d0ccPvpZv6fiidQbe802 hqowy2iH/K6XItRObVBWXuvR60JvDXo5NAsUoxZJTJahHnV6zPJGnT9ccfewbYLdz/ks T2CZvwdLckFjGClRKOoGA57pwoebSIBpc08I8Pya7K4Cbjcg41AjpzYbE6ffQmL37fhW Zj7LmglzBP7oVQFeM1yQgPSuhIs5uE39wmphf34rWHkJPf076LwtRi3utNhhre2cGllY FffgEm6jQ4gokA4eG/cWl8tzFjb1tbZdQ962M+wKQcOef9H57oRlCV8i2fmlgc99gv+O bRkQ== X-Gm-Message-State: AOAM530ijyTQdgodNt92h6oudZNdcb5aFW7pyx+Jotn1dVc+AQx9B5/P uZULTOYyhr9wOC40e+CQaza/qKwOOu9e2/aPwsQhqQ== X-Google-Smtp-Source: ABdhPJxzBJ3xGLvlzG0KVYzemKw7irNCJbPzXu7HMAIWodwPYqtCqbkZVo0CNJWicFJd4Rc0zQnPhQrIet41JLV3XB0= X-Received: by 2002:a05:6512:3f8:: with SMTP id n24mr6547107lfq.125.1627317879269; Mon, 26 Jul 2021 09:44:39 -0700 (PDT) MIME-Version: 1.0 References: <20210716184719.269033-5-posk@google.com> <2c971806-b8f6-50b9-491f-e1ede4a33579@uwaterloo.ca> <5790661b-869c-68bd-86fa-62f580e84be1@uwaterloo.ca> In-Reply-To: From: Peter Oskolkov Date: Mon, 26 Jul 2021 09:44:27 -0700 Message-ID: Subject: Re: [RFC PATCH 4/4 v0.3] sched/umcg: RFC: implement UMCG syscalls To: Thierry Delisle Cc: Peter Oskolkov , Andrei Vagin , Ben Segall , Jann Horn , Jim Newsome , Joel Fernandes , linux-api@vger.kernel.org, Linux Kernel Mailing List , Ingo Molnar , Peter Zijlstra , Paul Turner , Thomas Gleixner , Peter Buhr Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 23, 2021 at 12:06 PM Thierry Delisle wrote: > > > In my tests reclaimed nodes have their next pointers immediately set > > to point to the list head. If the kernel gets a node with its @next > > pointing to something else, then yes, things break down (the kernel > > kills the process); this has happened occasionally when I had a bug in > > the userspace code. > > I believe that approach is fine for production, but for testing it may > not detect some bugs. For example, it may not detect the race I detail > below. While I think I have the idle servers list working, I now believe that what peterz@ was suggesting is not much slower in the common case (many idle workers; few, if any, idle servers) than having a list of idle servers exposed to the kernel: I think having a single idle server at head, not a list, is enough: when a worker is added to idle workers list, a single idle server at head, if present, can be "popped" and woken; the userspace can maintain the list of idle servers itself; having the kernel wake only one is enough - it will pop all idle workers and decide whether any other servers are needed to process the newly available work. [...] > > Workers are trickier, as they can be woken by signals and then block > > again, but stray signals are so bad here that I'm thinking of actually > > not letting sleeping workers wake on signals. Other than signals > > waking queued/unqueued idle workers, are there any other potential > > races here? > > Timeouts on blocked threads is virtually the same as a signal I think. I > can see that both could lead to attempts at waking workers that are not > blocked. I've got preemption working well enough to warrant a new RFC patchset (also have timeouts done, but these were easy). I'll clean things up, change the idle servers logic to only one idle server exposed to the kernel, not a list, add some additional documentation (state transitions, userspace code snippets, etc.) and will post v0.4 RFC patchset to LKML later this week. [...]