Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1736943pxb; Fri, 10 Sep 2021 12:38:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz11/xRKMvW/tQ3WxCh2qwypCtfwF3KJ80PSINvNKHM5BvzSDncF0mmglhsGw536fh8Ku+/ X-Received: by 2002:a05:6638:13cd:: with SMTP id i13mr1354235jaj.128.1631302705177; Fri, 10 Sep 2021 12:38:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631302705; cv=none; d=google.com; s=arc-20160816; b=djLk97WyW4Qygt2LKhQ0Z2jaoiFBW57lDcc6NkpI84iWWKjceelG5y1i1RZV107XPx PmzDg3HXVdbzCw4hUTEnpTMV/pqerU0rbwGMYZqkqbmZI7K/s/jG8lmcgBfgjlanJhQ6 vcoG8juFIPZDwX4u6I0QGZOP0vL9h6K3JQQfXYrIPwkr/CJRC/HwOGUPO/0WhsTTifST bwXA5uio6uyOfizaIDXFNiWypJOZGWDZm7WHBAjOmj1lCN2S0Ak/HP1ClzlvCE7abbiy eRAJfupywEie1o5v9qTmzxhQlQf/x4vbqUGF6REs8lyU1cr8qnLPpv0blbp4a3gOu+uX VPjQ== 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=MxYG3oQ5GLJLXh/udMSbpNxO67lymB3pYR+6ivwJVGg=; b=GKpVtT6TeXt4oA1/LaA7NRcN7c4qHFuT9b9XpUyvSSeaKnzrzRpNO+DqH8jc/VBMTP 8mInQ0VKPUS8C9OejRHDmEhRTR4PnYoU1jaJArH0Xk4mmfQC8uA0xnSygABkWNwCdQd8 5JWAR8jhQCoh5mK0HrWrm8BT8h8dAnAc0t0mXDgNrsdBktOmVAlSkFznSBC0+G2g5R8N FPz+hLdOPquEstSNMelScuWRut0HHsGOrUbkvJPFxrjamnxM2QGncTNvgMBzbTP5vLZm fQrgOpaTs+mJvG3yqmCN/rXHc4XwnIPxiRDv27NlkMCc3Rmjheb8ZYsamX7wgoZNGr9P SKcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=dIPk8+MO; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r19si5797968ilh.119.2021.09.10.12.38.13; Fri, 10 Sep 2021 12:38:25 -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=@google.com header.s=20210112 header.b=dIPk8+MO; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230489AbhIJTh7 (ORCPT + 99 others); Fri, 10 Sep 2021 15:37:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbhIJTh5 (ORCPT ); Fri, 10 Sep 2021 15:37:57 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 690FCC061574 for ; Fri, 10 Sep 2021 12:36:46 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id q21so4931333ljj.6 for ; Fri, 10 Sep 2021 12:36:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=MxYG3oQ5GLJLXh/udMSbpNxO67lymB3pYR+6ivwJVGg=; b=dIPk8+MOkoDL8UzaYpVPnebIT6lPLIhM+Km0cGozYUcAd6riuY8F9aJqNnl6Yi+K3c HsErue62OffPI5GMJJZPwCOFZXc4Y2qKNvOe3wSQj2V10FG1Xwh8Le7NluHOADKniwCY OsBMcnJRzrsqLO4CWZAvNQ68gto8r+vXHA2qWU0sS9dAqb0ca8qdK1VAuZpkBdPryBg/ 31JB9aRX9oQS+KG7+rOBKNP9GFliGzO/ml9W3CjF+JFLP9Ho37ucySjuWtbpFRiQll6O kWD0506kUXdjErMVRqILnaCFrI0CFSoMMp6ivDGKwbiommTvlfP6tmxFu4SJA/OLcmTQ 7lEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=MxYG3oQ5GLJLXh/udMSbpNxO67lymB3pYR+6ivwJVGg=; b=3DDCEjHMMB8USDL1Mkw2rI9B5FukZuLHovLa7D4ZTK+CQjT6V5WTuW81rKhM/vs87K 3Pqdjc9HIjaH3xItakGxAhZ/Q2V5HW5IXYBYcPcBPtbIo2vhcLQYly1kZWdgkVlZxQT5 iSoP8QD8xEsZ4Aixtw4wbDn4QCVAP3bVU2QHIu9xrCm8tqYLFtwSkb32Nv+yDNvwg0ws hnGmQ6TAkXUOJzm3vz5xXDVqBl++GJzNkmTvmXpUOIc3sf/dTWlIzUcSXnuN0KlaE9md akaL1AH1vRJB2F4jG5k/jd2U3yxjzwDeSaliioQ4lJcvjt5Ukh0ktHmCdu3JFw9pqsbX nsWg== X-Gm-Message-State: AOAM533LBpXth6fhTxaX7FrVF8+nGUT+nf1TXxS3TmyWHrBjJXYmcDU5 OsevnE6z071hmtqUGLDYkEdWmWxOSLV55sfWTy9u2A== X-Received: by 2002:a2e:1556:: with SMTP id 22mr5235455ljv.253.1631302604595; Fri, 10 Sep 2021 12:36:44 -0700 (PDT) MIME-Version: 1.0 References: <1631147036-13597-1-git-send-email-prakash.sangappa@oracle.com> <3591AC6D-45D2-476A-80B1-46BFA1742602@oracle.com> In-Reply-To: From: Peter Oskolkov Date: Fri, 10 Sep 2021 12:36:33 -0700 Message-ID: Subject: Re: [RESEND RFC PATCH 0/3] Provide fast access to thread specific data To: Jann Horn Cc: Prakash Sangappa , Linux Kernel Mailing List , linux-api , Ingo Molnar , Paul Turner , Peter Oskolkov , Peter Zijlstra 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 Fri, Sep 10, 2021 at 12:12 PM Jann Horn wrote: > > On Fri, Sep 10, 2021 at 6:28 PM Peter Oskolkov wrote: > > On Fri, Sep 10, 2021 at 9:13 AM Prakash Sangappa > > wrote: > > > > Do you think your sys_task_getshared can be tweaked to return an > > > > arbitrarily-sized block of memory (subject to overall constraints) > > > > rather than a fixed number of "options"? > > > > > > I suppose it could. How big of a size? We don=E2=80=99t want to hold = on to > > > arbitrarily large amount of pinned memory. The preference would > > > be for the kernel to decide what is going to be shared based on > > > what functionality/data sharing is supported. In that sense the size > > > is pre defined not something the userspace/application can ask. > > > > There could be a sysctl or some other mechanism that limits the amount > > of memory pinned per mm (or per task). Having "options" hardcoded for > > such a generally useful feature seems limiting... > > That seems like it'll just create trouble a few years down the line > when the arbitrarily-chosen limit that nobody is monitoring blows up > in someone's production environment. > > If this area is used for specific per-thread items, then the kernel > should be able to enforce that you only allocate as much space as is > needed for all threads of the process (based on the maximum number > that have ever been running in parallel in the process), right? Which > would probably work best if the kernel managed those allocations. This sounds, again, as if the kernel should be aware of the kind of items being allocated; having a more generic mechanism of allocating pinned memory for the userspace to use at its discretion would be more generally useful, I think. But how then the kernel/system should be protected from a buggy or malicious process trying to grab too much? One option would be to have a generic in-kernel mechanism for this, but expose it to the userspace via domain-specific syscalls that do the accounting you hint at. This sounds a bit like an over-engineered solution, though...