Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp926158pxb; Tue, 14 Sep 2021 11:42:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIYVBtSzreTzVHNL+DxsGNyp3K5qhH4B6MZUAwnwg7HrupJygHIl2H4ei5J037FnpffhSq X-Received: by 2002:a05:6e02:2199:: with SMTP id j25mr14125891ila.97.1631644970100; Tue, 14 Sep 2021 11:42:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631644970; cv=none; d=google.com; s=arc-20160816; b=wilzcOMWVFnkE/ZzwZFsTYKyTpdLE+lcpAcR0KyP6NuTrboKIWVNfBR1LVqjy7A245 Qod8SsjQy7XljAuusVA+5v+YqQNkY9LuogXFqGJgYJb+UbNm3ONzKPVRcinroKeGikzR dAbvPoL4GDp15tqGkkADXJw5I8+1gXcuj95KpKvSb7jgFTNf0sgoO1/hqCdCwxULZRuG BmoockKxH6xWX3k7N9hKcihF/BBmYJzf67IdKPKTSw+57OeEXFyCd6vzDYjDyhDJjuAZ sHYQ4dJUEEeOhSQxWXU3vyUDeMk21SlUGBS1kIAUhHVe8kJNF3eaVeRyndXGZOVGGCFE biNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:subject:cc:to:from :date:references:in-reply-to:message-id:mime-version:user-agent :dkim-signature; bh=Jak5cfdBJcbmGsJj6hcyV6ux3FCp/RrSXsH9y9WVvrY=; b=0hNzy5LANv4bTYahrg2iMmBjIY6OxzFU6ONlaRceAMYxNg0L7pTPkWZr304TBOI3E6 5OZ6epEZgmVQpWPJIm87B3A6KFgcoSCSm7X4Xvfv/ub5a+04dQ3kWlRKW3xlLXy9XZAC mFlKg4ymDD4Xddiqi2vBrLSWopqQ2X1o0A2LxTV/YDdrf/qYC1NHIEpHcZ9p5vEHAm6B qOBtV+oblMsP3cC4KFoSy4CPZDGgbJEdhTsZzMRbJnlcDsLzZZxzJM2wUdFiMEiCFkVH o5HTIyhS8g7UzTFqu8eZxz4wcijXN8H0DVs8wWOC+2hLg2ziDnzi+pfZgLxkr8RS/6l6 wOFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eLekWCKF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c7si10671367ilu.60.2021.09.14.11.42.37; Tue, 14 Sep 2021 11:42:50 -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=pass header.i=@kernel.org header.s=k20201202 header.b=eLekWCKF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230012AbhINSlq (ORCPT + 99 others); Tue, 14 Sep 2021 14:41:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:54868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229906AbhINSlo (ORCPT ); Tue, 14 Sep 2021 14:41:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B0654610E6; Tue, 14 Sep 2021 18:40:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631644826; bh=l7C56GEOC+aCw6hs43x4MKGepxIPQ/bOtEDY/hCzwNQ=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=eLekWCKFBxK4cA+J4J+PVXVWpATAWAY8FORxhwkJ193WGqfguIhEIf5BR0syRlowU l/WCM/7O2A6rjqREoXDqhQrEcq+t6DrjwoIE9ffSc0ovJ5sCFJB347WfXp21JOuPmN b4hDChbeD+fQyuL4lqZr6QWpyR1FsOBNc8NFOun1m4vhRFfDnp2mVgcJLVmHOOars+ QMeyzo5eJsWQu0TNkk4gYNoO/6yty/k9x9szkhdlwTOiitTRahdLWYxQevO2QYATdz YhVB6wkOblGy5q5soUjtDUnW4H2XBlRpv5UeTE3Ls3wRBF48Ijo8txx/7sw+hVgqIl 49TOqkwUb1wAw== Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id CE00B27C0054; Tue, 14 Sep 2021 14:40:24 -0400 (EDT) Received: from imap2 ([10.202.2.52]) by compute6.internal (MEProxy); Tue, 14 Sep 2021 14:40:24 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudegledguddvhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtgfesthhqredtreerjeenucfhrhhomhepfdet nhguhicunfhuthhomhhirhhskhhifdcuoehluhhtoheskhgvrhhnvghlrdhorhhgqeenuc ggtffrrghtthgvrhhnpedvleehjeejvefhuddtgeegffdtjedtffegveethedvgfejieev ieeufeevuedvteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpegrnhguhidomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqudduiedu keehieefvddqvdeifeduieeitdekqdhluhhtoheppehkvghrnhgvlhdrohhrgheslhhinh hugidrlhhuthhordhush X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 7823AA002E4; Tue, 14 Sep 2021 14:40:23 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-1291-gc66fc0a3a2-fm-20210913.001-gc66fc0a3 Mime-Version: 1.0 Message-Id: In-Reply-To: References: <20210908184905.163787-1-posk@google.com> <20210908184905.163787-3-posk@google.com> Date: Tue, 14 Sep 2021 11:40:01 -0700 From: "Andy Lutomirski" To: "Peter Zijlstra (Intel)" Cc: "Jann Horn" , "Peter Oskolkov" , "Peter Oskolkov" , "Ingo Molnar" , "Thomas Gleixner" , "Linux Kernel Mailing List" , "Linux API" , "Paul Turner" , "Ben Segall" , "Andrei Vagin" , "Thierry Delisle" Subject: Re: [PATCH 2/4 v0.5] sched/umcg: RFC: add userspace atomic helpers Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 14, 2021, at 11:11 AM, Peter Zijlstra wrote: > On Tue, Sep 14, 2021 at 09:52:08AM -0700, Andy Lutomirski wrote: > > With a custom mapping, you don=E2=80=99t need to pin pages at all, I= think. > > As long as you can reconstruct the contents of the shared page and > > you=E2=80=99re willing to do some slightly careful synchronization, = you can > > detect that the page is missing when you try to update it and skip t= he > > update. The vm_ops->fault handler can repopulate the page the next > > time it=E2=80=99s accessed. >=20 > The point is that the moment we know we need to do this user-poke, is > schedule(), which could be called while holding mmap_sem (it being a > preemptable lock). Which means we cannot go and do faults. That=E2=80=99s fine. The page would be in one or two states: present and= writable by kernel or completely gone. If its present, the scheduler wr= ites it. If it=E2=80=99s gone, the scheduler skips the write and the nex= t fault fills it in. >=20 > > All that being said, I feel like I=E2=80=99m missing something. The = point of > > this is to send what the old M:N folks called =E2=80=9Cscheduler act= ivations=E2=80=9D, > > right? Wouldn=E2=80=99t it be more efficient to explicitly wake som= ething > > blockable/pollable and write the message into a more efficient data > > structure? Polling one page per task from userspace seems like it > > will have inherently high latency due to the polling interval and wi= ll > > also have very poor locality. Or am I missing something? >=20 > The idea was to link the user structures together in a (single) linked > list. The server structure gets a list of all the blocked tasks. This > avoids having to a full N iteration (like Java, they're talking stupid > number of N). >=20 > Polling should not happen, once we run out of runnable tasks, the serv= er > task gets ran again and it can instantly pick up all the blocked > notifications. >=20 How does the server task know when to read the linked list? And what=E2= =80=99s wrong with a ring buffer or a syscall?