Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp645454pxb; Wed, 15 Sep 2021 09:52:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFot5jJBJ3ddKwp1TqxvPIAygWSeMDbHRT7RE+tWkfEwpBBp1zQlBtta53HTxOUvISMfiv X-Received: by 2002:a92:d5d0:: with SMTP id d16mr746830ilq.179.1631724726953; Wed, 15 Sep 2021 09:52:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631724726; cv=none; d=google.com; s=arc-20160816; b=P76grorLgt8w3mfqKfmlhaVqy6XtN/bN8pt9AjgFs85rkEwpFPIRwuQtkI3R0Clomb 1Oh3kYxlOVL/yRWheivIOfnB3mbEVkl827Iui8cR6/gDgvTmIO+oKYzmOQz+zUZzQ+Pb EPa4y6yMBgR65NPnQKi6aL6YkS0EC9dJx2ZxCEGYu2xaYevD2AQpV9Ddfko51WcwLVzA N1OeI7gGVHlQsv4lpSLMaZroogbYC+HWCZpc9rwpBTGygWdRhBMrgmX4eNXG2Lt4HkK2 d9PePUo5t1uoa7gquPZzvm/xXubnAk5jokpLj9CGpttWfX3hiKUnIDy3q6ZGcC8geQXt 0lqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=G8R9q1kj0PPKLWYN6F9DoAWk9sPObbErzmTCZsJLunY=; b=o4YWbA2ewyqv6ATm51Guf+uONZ+bmcIL9x7b7dgkHIxa4N2rq29imngPdXHvPMdBMn nBQKwW5m53Tm0p/zVzrGQE8rV+tqMteuy/mpzNrlDRylb/f/R3N4g3FrTkTW4iNEuLjm RLnnSRH4s85CgiAH3ipPuZn0QFssCZJOHatPfZ3z3f0wks+sydgbrmNzKnECvOuhyJze kPhfvJOV3wlWxEG3ZoWsON4bchvmfaPhcQch52nrLqFmb4PgQK8GaW5WtF9jEQF52RXi WN4be3y6ZyfGZlv+ToiYKogzP2zIoJi+bUQMbLSyzTc6e/m53D6dKz+TDSGARZuYTAba I3wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k+oDjFt5; 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 d3si383848ilu.98.2021.09.15.09.51.54; Wed, 15 Sep 2021 09:52:06 -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=k+oDjFt5; 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 S229690AbhIOQwP (ORCPT + 99 others); Wed, 15 Sep 2021 12:52:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:50120 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229479AbhIOQwO (ORCPT ); Wed, 15 Sep 2021 12:52:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 20A0C61216 for ; Wed, 15 Sep 2021 16:50:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631724655; bh=AiRKHUxW2UC5D7JE+/BfAF9miYwYIckZFB8tXEZpz3w=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=k+oDjFt5gTfWrDzoUS2ed1thbqwwswMTHtIbMBnYsmYlU62X/Ba+wFoMc9CbmtFN5 fSCvl1sd5Bum/A39Q5CUy+vcLFXB9ezlcLxudKXouCxFsIT4YG4wxArub9z90B0fXG CdAqv+byn3s16AMvRbaP1SdRhTIWoaWhgs/I+qdGh7FOVHaVz2ExT6VmHKFZLXfBWi +udS/YTPFUQY1ISwRGp4hnSn2+/hozH/pHKqErbQJMSoXguJzkj6jp27zi01c/vbBf 01wkOHnIWn8gKRXLgEAjUPK/Pjx4bXrq+nKVlS5PdtO9OLuNz4ochBHPFgu6BcIqff /wp8luXtoBShA== Received: by mail-ed1-f46.google.com with SMTP id g8so5976209edt.7 for ; Wed, 15 Sep 2021 09:50:55 -0700 (PDT) X-Gm-Message-State: AOAM531IWQZdipah9MMDi2eP5l9RgrNMeBbr/MEj8H389F2mv+vPafsZ ljnvZAZLbnsdI07wrs14XNYt5h6B6eJgxY3yXtjlpQ== X-Received: by 2002:a17:906:2cd5:: with SMTP id r21mr984813ejr.435.1631724653730; Wed, 15 Sep 2021 09:50:53 -0700 (PDT) MIME-Version: 1.0 References: <20210908184905.163787-1-posk@google.com> <20210908184905.163787-3-posk@google.com> In-Reply-To: From: Andy Lutomirski Date: Wed, 15 Sep 2021 09:50:41 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/4 v0.5] sched/umcg: RFC: add userspace atomic helpers To: Peter Zijlstra Cc: Andy Lutomirski , Jann Horn , Peter Oskolkov , Peter Oskolkov , Ingo Molnar , Thomas Gleixner , Linux Kernel Mailing List , Linux API , Paul Turner , Ben Segall , Andrei Vagin , Thierry Delisle 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 Wed, Sep 15, 2021 at 8:45 AM Peter Zijlstra wrote= : > > On Tue, Sep 14, 2021 at 11:40:01AM -0700, Andy Lutomirski wrote: > > > > > > 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 = the > > > > update. The vm_ops->fault handler can repopulate the page the next > > > > time it=E2=80=99s accessed. > > > > > > 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 an= d > > writable by kernel or completely gone. If its present, the scheduler > > writes it. If it=E2=80=99s gone, the scheduler skips the write and the = next > > fault fills it in. > > That's non-deterministic, and as such not suitable. What's the precise problem? The code would be roughly: if (try_pin_the_page) { write it; unpin; } else { do nothing -- .fault will fill in the correct contents. } The time this takes is nondeterministic, but it's bounded and short. > > > > > 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 ac= tivations=E2=80=9D, > > > > right? Wouldn=E2=80=99t it be more efficient to explicitly wake so= mething > > > > 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 w= ill > > > > also have very poor locality. Or am I missing something? > > > > > > The idea was to link the user structures together in a (single) linke= d > > > 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 stupi= d > > > number of N). > > > > > > Polling should not happen, once we run out of runnable tasks, the ser= ver > > > task gets ran again and it can instantly pick up all the blocked > > > notifications. > > > > > > > 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? > > Same problem, ring-buffer has the case where it's full and events get > dropped, at which point you've completely lost state. If it is at all > possible to recover from that, doing so is non-deterministic. > > I really want this stuff to work for realtime workloads too. A ring buffer would have a bounded size -- one word (of whatever size) per user thread.