Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1671284pxb; Fri, 10 Sep 2021 10:58:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYimAZlX8TBN9Cdxx27mVvGscx9jY92kOrur5u6r7hSROdsCcHk55XkTTOZCIpPBJ5oHcK X-Received: by 2002:a6b:296:: with SMTP id 144mr8000590ioc.114.1631296692507; Fri, 10 Sep 2021 10:58:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631296692; cv=none; d=google.com; s=arc-20160816; b=Uz5wKLvB/bBS5XjlLVbJBiwOXJPBY29xdCzNAa293pWhq5Wyz96bk7aWr2ouhvOAKY I1L3QbiA1WBwnVDbQzUQ5XIrXAaBoM2pmxSZYxdOhb3ikWi60zUECzyb7Tda7K4im2jn wrR7XfNH2Usn6TfQObtOE3rU+rSEnCCyS71R00dqI94878Ad8GWZ0z72qiI4AslpJadw Tqbb30sfh775VOxGv9c5P+mpRZMdVnBDX/mxCanbXnEqYm/k5sBdeoarGTUOgrfo/C47 D7PFo1uFrBz4uTPIATXV89YKLDPCKWZrIL9M2G9ZskI2E7ulLJV4+iSrJf2SAheE42yB D+sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter; bh=5+hAG8XNzsa04MG+fqOR9+Yfgc7sEdxUWr0qmmVfCfY=; b=PB0NJGwdH/bC93JXp40oJ6OSAmg0p477WdUejK2pfcL+sgrWEF7Nilp0HO8n/327ok 0zyee/anzYcmv9V6RCkJE6I9PfKcOGn1JFUAf/v6+O8bZBdlMflug1+ruGJ0PACNku12 dt0Qcz0Zlomve5SXMjA4fHZ+M8uInXIk/jz9gxw1zt3gQXIDc6srCwzccrUqM2cBxiNu 2vNSWadgLH8Z0LVGzBDh8vHckkJ3iOhccgJQB9e1Ec9RFngHUvmDd+bp+lCpi7VhrdSN fhs6Srk8t3mfhcwH/YTPpZfreL9c9UHRcEKrMUQyTOZLCc2ktp5eaD4kETSfQQ7LHnFi fxyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b="D2Y/BDbC"; 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=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f22si1468119jam.69.2021.09.10.10.58.01; Fri, 10 Sep 2021 10:58:12 -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=@efficios.com header.s=default header.b="D2Y/BDbC"; 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=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232008AbhIJR5I (ORCPT + 99 others); Fri, 10 Sep 2021 13:57:08 -0400 Received: from mail.efficios.com ([167.114.26.124]:37242 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229476AbhIJR5I (ORCPT ); Fri, 10 Sep 2021 13:57:08 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 8276B380BB7; Fri, 10 Sep 2021 13:55:56 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id IuMMT8J-4IRd; Fri, 10 Sep 2021 13:55:56 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 02421380BB6; Fri, 10 Sep 2021 13:55:56 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 02421380BB6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1631296556; bh=5+hAG8XNzsa04MG+fqOR9+Yfgc7sEdxUWr0qmmVfCfY=; h=Date:From:To:Message-ID:MIME-Version; b=D2Y/BDbCbe3M+6qV+k1Ku+t9zQP6MKY9svVkACnUBAxoa6TPj3ucPG6abAXe+G3HL tZz0TPPyvqbl9zwjLKyElCw+aNQKcUFampR72oaEiGDyrhXE/QaieXV6W1gKYo1n9s f285Abk/Q74G/4sRi96Yy46x7bEPUhguUfyMGy5EiAcMXcleRRPntVs7ozASxZMQ2i zQqziskxboGMELSktXPskxE5geC8+oXc3ijBU7bpVZdgNgqHyGpDVwaYhrk7UY5SNN hl/JI44yuWz1aT4lAIw6fiO+EwxsIqJQk6ZMq55qw3n7UVBAoNyplrq5tCJcCAKMpW 7A11IyMoYIojA== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id FVcMjE_yDwv4; Fri, 10 Sep 2021 13:55:55 -0400 (EDT) Received: from mail03.efficios.com (mail03.efficios.com [167.114.26.124]) by mail.efficios.com (Postfix) with ESMTP id E492C380BB5; Fri, 10 Sep 2021 13:55:55 -0400 (EDT) Date: Fri, 10 Sep 2021 13:55:55 -0400 (EDT) From: Mathieu Desnoyers To: Peter Oskolkov Cc: Florian Weimer , Prakash Sangappa , linux-kernel , linux-api , Ingo Molnar , Paul Turner , Jann Horn , Peter Oskolkov , Vincenzo Frascino , Peter Zijlstra Message-ID: <872090791.15342.1631296555821.JavaMail.zimbra@efficios.com> In-Reply-To: References: <1631147036-13597-1-git-send-email-prakash.sangappa@oracle.com> <8735qcgzdu.fsf@oldenburg.str.redhat.com> <1297400717.15316.1631295199656.JavaMail.zimbra@efficios.com> Subject: Re: [RESEND RFC PATCH 0/3] Provide fast access to thread specific data MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.26.124] X-Mailer: Zimbra 8.8.15_GA_4125 (ZimbraWebClient - FF91 (Linux)/8.8.15_GA_4059) Thread-Topic: Provide fast access to thread specific data Thread-Index: cCPc3M0lsPgAFLR7AFntnYw+6ICTsA== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Sep 10, 2021, at 1:48 PM, Peter Oskolkov posk@google.com wrote: > On Fri, Sep 10, 2021 at 10:33 AM Mathieu Desnoyers > wrote: >> >> ----- On Sep 10, 2021, at 12:37 PM, Florian Weimer fweimer@redhat.com wrote: >> >> > * Peter Oskolkov: >> > >> >> In short, due to the need to read/write to the userspace from >> >> non-sleepable contexts in the kernel it seems that we need to have some >> >> form of per task/thread kernel/userspace shared memory that is pinned, >> >> similar to what your sys_task_getshared does. >> > >> > In glibc, we'd also like to have this for PID and TID. Eventually, >> > rt_sigprocmask without kernel roundtrip in most cases would be very nice >> > as well. For performance and simplicity in userspace, it would be best >> > if the memory region could be at the same offset from the TCB for all >> > threads. >> > >> > For KTLS, the idea was that the auxiliary vector would contain size and >> > alignment of the KTLS. Userspace would reserve that memory, register it >> > with the kernel like rseq (or the robust list pointers), and pass its >> > address to the vDSO functions that need them. The last part ensures >> > that the vDSO functions do not need non-global data to determine the >> > offset from the TCB. Registration is still needed for the caches. >> > >> > I think previous discussions (in the KTLS and rseq context) did not have >> > the pinning constraint. >> >> If this data is per-thread, and read from user-space, why is it relevant >> to update this data from non-sleepable kernel context rather than update it as >> needed on return-to-userspace ? When returning to userspace, sleeping due to a >> page fault is entirely acceptable. This is what we currently do for rseq. >> >> In short, the data could be accessible from the task struct. Flags in the >> task struct can let return-to-userspace know that it has outdated ktls >> data. So before returning to userspace, the kernel can copy the relevant data >> from the task struct to the shared memory area, without requiring any pinning. >> >> What am I missing ? > > I can't speak about other use cases, but in the context of userspace > scheduling, the information that a task has blocked in the kernel and > is going to be removed from its runqueue cannot wait to be delivered > to the userspace until the task wakes up, as the userspace scheduler > needs to know of the even when it happened so that it can schedule > another task in place of the blocked one. See the discussion here: > > https://lore.kernel.org/lkml/CAG48ez0mgCXpXnqAUsa0TcFBPjrid-74Gj=xG8HZqj2n+OPoKw@mail.gmail.com/ OK, just to confirm my understanding, so the use-case here is per-thread state which can be read by other threads (in this case the userspace scheduler) ? Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com