Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1605437pxb; Fri, 10 Sep 2021 09:30:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyOftFcTdw845TqGOB7VjPiZzlWWoDG6lIaJsFpHAHO9V8x53TEt4FCgACfd693Gwz/FaK X-Received: by 2002:a92:1306:: with SMTP id 6mr6764984ilt.183.1631291404185; Fri, 10 Sep 2021 09:30:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631291404; cv=none; d=google.com; s=arc-20160816; b=Er3If89+veqY580HR8xyWb0NoNwutNMHSHd5R3X63vfHPi6mm0e2d40bC/E4v79L6y nHjyG8I691bSPL8WuGcRmdBORkhjpVX/Nph9umW0lWBYuCZmFKhTIXrrsZIAOj/s6nA2 kQkRPaRf6dHRgC3jq6xgkVIH9aqY+ml3ePMxQ0s2a0TRONRDxrIuiQ8LVuV80yR3lZvB bSqnz6UEq8XXGiv/U+6lC3MeRsPxq+xHWtoiTaZMUd8yJvdOHAqVJr1Dy7KK4vu9+h3p wqi+O0TsxqTZKiNTv9WXbjKdOhNtY0U95LBHpJbBdaiJhEU1Qgnum8iy+vqHukM5eSS/ TLBA== 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=Ni2JhLZQgk9Q6G2MUbeVWPBAuWIrAdHFzB95UL3/Sis=; b=RYvsAvAaDDscuvj33mrX07Ue6gOBQQebSoDoKCSF6iW5RNUAYjhBe/O/2srU6+pXKo 4szwG2Eddnf+An9bi6CdB6TJc//Abnd5uEi53dSav8zihKJB52GSRxw/0W8jVZVSGzCt d2y2F/ts+ivAwZuSe7HkKJQSwNq5Pp0B/7BoyCALQfYk1A+ndhdYV3hdizVDpyGjuT7r TurlpXy0lPSr+u0PUBZu/RBsdSb3N5Aue1MB0aXNdt3l5jXbAy7m7EIhQx/7/XNoOUrr f4PKanIcJ0lrWpn61O5wlZmjzuhpMUfI3+12M6kzX2kOcA4bc+ktWs79YFCOe1KDnE4v IkKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=FZrorI4C; 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 d27si5460033jaa.121.2021.09.10.09.29.52; Fri, 10 Sep 2021 09:30:04 -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=FZrorI4C; 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 S229826AbhIJQ30 (ORCPT + 99 others); Fri, 10 Sep 2021 12:29:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229543AbhIJQ3Y (ORCPT ); Fri, 10 Sep 2021 12:29:24 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41500C061757 for ; Fri, 10 Sep 2021 09:28:13 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id i28so4086178ljm.7 for ; Fri, 10 Sep 2021 09:28:13 -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=Ni2JhLZQgk9Q6G2MUbeVWPBAuWIrAdHFzB95UL3/Sis=; b=FZrorI4CFj/1QAA+qnqt0Jg0yZPa9EKmXgA0exenFIey7++LpW0YpJ6Kh1Ivx2Y0Sx gfSJWmMk8X7/4+gITPhZ1eaBubFCD17NGZKsh6jm/hjttEpQTypNZWCuLJsfsmhEORAg B5N5vLra29/4UdTLPH/rZCa9+TS0+W399jX6uH8VwEwtky4tpSxUQOAAHwOxs765IWVN 5RuRkvlkKZlMtSeitRNWPZaLgDSvcsiwiqeypfkwVXwCZ7754AdKLGr0ZD6el3+6bkBE lts09uJPRmZ3/wa6KujBoPA6mhewvVqFIKD85835Fi/m7EtCP66voRar5DXtHCN0ah8P 1PFw== 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=Ni2JhLZQgk9Q6G2MUbeVWPBAuWIrAdHFzB95UL3/Sis=; b=a++o0V5tHf3/PCTcXpji9mJ98R3ghU4Uo/ZKRFoQVVAk9QRGNakUDYj7PgnihO8gTs 9GDmNW6JjoSaXNyf4H586sxvjnUuk2f2ezUoCP9aWYrrxLYyLGEUECq0aeaev/LrotC8 30POtoNj4EWfvC2KTsP8Ry8VjeOYisxnB/t6jTsGYLXSmSl8zZ/+vp158GOIrry0PSxH Nno5rkRlanwF972hrtyTLNV1AX99TSLAAodCY9uLVs62nu+NtuAH35PUu6E8rfmg36Bu /MNXn9EXfZEhC5zTzl9hFXzHDU5q9JaQzwWDNJbjAUzIVTwOwXeGptxKtvOtzlLqZ+HG s6qQ== X-Gm-Message-State: AOAM5305rfV31VASRNrnq/Vsf1wkzoXx7QDw+xRUeRIwBdR0g2sbZZcK EMNeYe+5izLTGjQRxZI0GJ7TOGKtUFtjMAxuTlo+pQ== X-Received: by 2002:a2e:b44f:: with SMTP id o15mr4889575ljm.430.1631291291374; Fri, 10 Sep 2021 09:28:11 -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: <3591AC6D-45D2-476A-80B1-46BFA1742602@oracle.com> From: Peter Oskolkov Date: Fri, 10 Sep 2021 09:28:00 -0700 Message-ID: Subject: Re: [RESEND RFC PATCH 0/3] Provide fast access to thread specific data To: Prakash Sangappa Cc: Linux Kernel Mailing List , linux-api , Ingo Molnar , Paul Turner , Jann Horn , 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 9:13 AM Prakash Sangappa wrote: > > > > > On Sep 10, 2021, at 8:18 AM, Peter Oskolkov wrote: > > > > On Wed, Sep 8, 2021 at 5:16 PM Prakash Sangappa > > wrote: > >> > >> Including liunx-kernel.. > >> > >> Resending RFC. This patchset is not final. I am looking for feedback o= n > >> this proposal to share thread specific data for us in latency sensitiv= e > >> codepath. > > > > Hi Prakash, > > > > > > I'd like to add here that Jann and I have been discussing a similar > > feature for my UMCG patchset: > > > > https://lore.kernel.org/lkml/CAG48ez0mgCXpXnqAUsa0TcFBPjrid-74Gj=3DxG8H= Zqj2n+OPoKw@mail.gmail.com/ > > Hi Peter, > > I will take a look. > > > > > 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. > > Exactly. For this reason wanted kernel to allocate the pinned memory. > Didn=E2=80=99t want to deal with files etc as a large number threads will= be using > the shared structure mechanism. > > > > > 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 t= o > 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... > > I have not looked at your use case. > > > > > On a more general note, we have a kernel extension internally at > > Google, named "kuchannel", that is similar to what you propose here: > > per task/thread shared memory with counters and other stat fields that > > the kernel populates and the userspace reads (and some additional > > functionality that is not too relevant to the discussion). > > We have few other use cases for this we are looking at, which I can > describe later. > > -Prakash > > > > > Thanks, > > Peter > > > > [...] >