Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp743643pxb; Wed, 22 Sep 2021 11:48:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKC0N+E9n0VC+2WbFABaFwzN3BZHCP2i3oRWjB/ZGLfcojW5ee9Vk/MEeyCSF7QQ/6qjXL X-Received: by 2002:a50:bf46:: with SMTP id g6mr962677edk.182.1632336529845; Wed, 22 Sep 2021 11:48:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632336529; cv=none; d=google.com; s=arc-20160816; b=gmn/DkDCP3QFd1aahAqtCmGWfCuCf1yR8xFYZw5FCJMZIf75TDyEp9QTA76DJLcu91 A9GRuo9mvw6t03Ai4/goJWOOJVKT6AdtYxBNw2uoBEXq6vxVwgJy7Bg/SjsbBbFjK+dh JkkSbtIBZqf8TmAnPY27xm870FUKykrntKFnThVQOOflhvc8OAOo7UsgztS7DqaOWl/w 1C3/0wg+dIO2nBxARoaR6RsocKrWvaBdSKhvf3SLp1UQ2Za4i0QkPcd+rOx51h4EoSFO qquP0e663j2kK1H0xSyFp8uQ3Y3hEJPj66eNbkMP0Za2KaVz/oaP/boAmIpnMwXaAWiG zJ/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :mime-version:user-agent:date:message-id:from:in-reply-to:references :cc:to:subject:ironport-data:dkim-signature; bh=QHb3slInR4Mx8S+2roscozMHnDP21o7IPmoP79Znlt4=; b=huScPOCaZQwsT2sM4HUuxusN92TeTrSf8GjF0eaZLNo7aXYfvLB+FS2HpYN1ZORUyd kbu8lYRwtwghhu0ZbtXuLhr9vtO47OKpu4sQclvTvzk6dLKxpE+kr05es3smkZhi+vHj r4IOk1xeaXfbdrQhhQFq7ZfIVf5REX12cm679Zmx1H1tCBzxmyr7SYZBXExs0cPihHGr ouXPCTKVPOAfzdvpJ5kUNynXmd2dLPDIJsHR8aFkJ2aNvaFKNWn3qYOp7iSheFf+kT1o tE5WQ2mWhaPcwAGFqsKFUWWWdOFY0gAlE6o7FlsGOu0vSNb+yWL3IhPOUOjjhCBZQKf8 EoYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@uwaterloo.ca header.s=default header.b=FKSEgWvE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=uwaterloo.ca Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z3si3719350edm.39.2021.09.22.11.48.20; Wed, 22 Sep 2021 11:48:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@uwaterloo.ca header.s=default header.b=FKSEgWvE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=uwaterloo.ca Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237116AbhIVSr6 (ORCPT + 99 others); Wed, 22 Sep 2021 14:47:58 -0400 Received: from esa.hc503-62.ca.iphmx.com ([216.71.135.51]:37169 "EHLO esa.hc503-62.ca.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbhIVSr6 (ORCPT ); Wed, 22 Sep 2021 14:47:58 -0400 X-Greylist: delayed 430 seconds by postgrey-1.27 at vger.kernel.org; Wed, 22 Sep 2021 14:47:57 EDT DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=uwaterloo.ca; i=@uwaterloo.ca; q=dns/txt; s=default; t=1632336388; x=1663872388; h=subject:to:cc:references:in-reply-to:from:message-id: date:mime-version:content-transfer-encoding; bh=v5kFGHXxXJ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aI+6xVl6av 1AcnNOdquEJZaxhjwSGR+MLEbq1oeuaOSHRm1poGN8q/lxB5kKeQGyZ2xkmTG8BDyrOUWa5C KMPkWu9PKNuAUY= Received: from connect.uwaterloo.ca (HELO connhm04.connect.uwaterloo.ca) ([129.97.208.43]) by ob1.hc503-62.ca.iphmx.com with ESMTP/TLS/AES256-GCM-SHA384; 22 Sep 2021 14:39:05 -0400 Received: from [10.42.0.123] (10.32.225.138) by connhm04.connect.uwaterloo.ca (172.16.137.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Wed, 22 Sep 2021 14:39:04 -0400 Subject: Re: [PATCH 5/5 v0.6] sched/umcg: add Documentation/userspace-api/umcg.txt To: Peter Oskolkov , Peter Zijlstra , Ingo Molnar , Thomas Gleixner , , CC: Paul Turner , Ben Segall , Peter Oskolkov , Andrei Vagin , Jann Horn References: <20210917180323.278250-1-posk@google.com> <20210917180323.278250-6-posk@google.com> In-Reply-To: <20210917180323.278250-6-posk@google.com> From: Thierry Delisle Message-ID: <12eb2300-4a78-9e93-30a3-8e2ddba4693f@uwaterloo.ca> Date: Wed, 22 Sep 2021 14:39:04 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [10.32.225.138] X-ClientProxiedBy: connhm03.connect.uwaterloo.ca (172.16.137.67) To connhm04.connect.uwaterloo.ca (172.16.137.68) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-09-17 2:03 p.m., Peter Oskolkov wrote: > [...] > +SYS_UMCG_WAIT() > + > +int sys_umcg_wait(uint32_t flags, uint64_t abs_timeout) operates on > +registered UMCG servers and workers: struct umcg_task *self provided to > +sys_umcg_ctl() when registering the current task is consulted in addition > +to flags and abs_timeout parameters. > + > +The function can be used to perform one of the three operations: > + > +* wait: if self->next_tid is zero, sys_umcg_wait() puts the current > +  server or worker to sleep; I believe this description is misleading but I might be wrong. From the example     * worker to server context switch (worker "yields"):       S:IDLE+W:RUNNING => +S:RUNNING+W:IDLE It seems to me that when a worker goes from running to idle, it should *not* set the next_tid to 0, it should preserve the next_tid as-is, which is expected to point to its current server. This is consistent with my understanding of the umcg_wait implementation. This operation is effectively a direct context-switch to the server. With that said, I'm a little confused by the usage of "yields" in that example. I would expect workers yielding to behave like kernel threads calling sched_yield(), i.e., context switch to the server but also be immediately added to the idle_workers_ptr. From my understanding of the umcg_wait call, "worker to server context switch" does not have analogous behaviour to sched_yield. Am I correct? If so, I suggest using "park" instead of "yield" in the description of that example. I believe the naming of wait/wake as park/unpark is consistent with Java[1] and Rust[2], but I don't know if that naming is used in contexts closer to the linux kernel. [1] https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/LockSupport.html [2] https://doc.rust-lang.org/std/thread/fn.park.html