Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp638646ybm; Thu, 28 May 2020 11:22:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPILcEPxiUiF2RP2td87nVNyfhbUZOzcAr0BaqCnJoVUzMPIGstFcF/W3jVOkf9gcYdnny X-Received: by 2002:aa7:ca13:: with SMTP id y19mr4436882eds.30.1590690126058; Thu, 28 May 2020 11:22:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590690126; cv=none; d=google.com; s=arc-20160816; b=ja88h6IceyUtGrir0aSvy5E8n0i9bQmeeosMAO9egjOfqaHJCt3fKimkgEXlOPBxK1 +nh+zluoS8nv83lTv2dP1NOTnMaSIkUnCAPpoIu8G7W5fg4y2XVfKxmYlOLMd1lYQN9b q696EOODSCQ7AED0fPygsPonLe7Hq0q8B5xqE8JJO6MFPsPKwjiamL1oCrkRvmjANW73 F1m/UsKnrOCDb3QcDG3GmI2ZwJME8XW8JRo3sApN9vaRk40e9dWJ3zTqS/jKolDlmTzC 6fou0Wjx2CcJHp+Tl7hFniZbDGdwWIpP2ZhHL6jQCpnWGbeB3fXyQJIChL0Ypc7PTGs4 yY/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=0aw5FkIJmuAbWTjzj646tyeDUOeCBjK1uXdDis+EquY=; b=DsyL5hUfxGm2UN6/ixIDjjujGmvJDUur55FPkQ6+tDrpjdwxqhoPzM1VwFwe8c+SCd wOepcUtC3Qpodlfj43DG2gck1pr8fd15bxo1+Oz0efW8Z/SkYXMwqcw8ItUiDEpZ5ejg 27Q3Iq6n4qiOEaynXPqVwaYW7qeDk89TzM/JckrNU2/lPL2DjJ/4IfCUOlr8JPZmo+I3 W/0I3nSn/5BLx5tLEKZrMwqqKpEJv2ud1hKEBsgYv9YDc8zRSJPPURTN522aK4lpy0Fg xnPHngwSSV0DShNgfp0SUhj1Dn31z94d3YDlcbb2qPDWeE9jd62P+qLlT8zho4h+swyf xIEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RHSXi142; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e12si4134376edy.210.2020.05.28.11.21.40; Thu, 28 May 2020 11:22: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=@redhat.com header.s=mimecast20190719 header.b=RHSXi142; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405752AbgE1SRf (ORCPT + 99 others); Thu, 28 May 2020 14:17:35 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:28210 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2405735AbgE1SRd (ORCPT ); Thu, 28 May 2020 14:17:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590689851; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0aw5FkIJmuAbWTjzj646tyeDUOeCBjK1uXdDis+EquY=; b=RHSXi142xhtNJmndKau7docS1X41XZBj35NGHrrw71P/xcic0/7j4ze/YkDAnk/tLdp7NU BwGUAqow4Tfy1dQ6Nxwsr/cbcmDA5gkAt66wMP389C6jdFPrcX0T9cAjNwI3kfyXLnSXP1 DZiEmMtyPCyLUqiMrh3EcK0ExW8Mo5Q= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-185-mo6Rypq4PMqzQZPux6zIAQ-1; Thu, 28 May 2020 14:17:27 -0400 X-MC-Unique: mo6Rypq4PMqzQZPux6zIAQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E7B10107B7CA; Thu, 28 May 2020 18:17:24 +0000 (UTC) Received: from lorien.usersys.redhat.com (ovpn-114-31.phx2.redhat.com [10.3.114.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AE2DE5F7EA; Thu, 28 May 2020 18:17:17 +0000 (UTC) Date: Thu, 28 May 2020 14:17:15 -0400 From: Phil Auld To: Peter Zijlstra Cc: Joel Fernandes , Nishanth Aravamudan , Julien Desfossez , Tim Chen , mingo@kernel.org, tglx@linutronix.de, pjt@google.com, torvalds@linux-foundation.org, vpillai , linux-kernel@vger.kernel.org, fweisbec@gmail.com, keescook@chromium.org, Aaron Lu , Aubrey Li , aubrey.li@linux.intel.com, Valentin Schneider , Mel Gorman , Pawan Gupta , Paolo Bonzini Subject: Re: [PATCH RFC] sched: Add a per-thread core scheduling interface Message-ID: <20200528181715.GC26442@lorien.usersys.redhat.com> References: <20200520222642.70679-1-joel@joelfernandes.org> <20200521085122.GF325280@hirez.programming.kicks-ass.net> <20200521134705.GA140701@google.com> <20200522125905.GM325280@hirez.programming.kicks-ass.net> <20200522213524.GD213825@google.com> <20200524140046.GA5598@lorien.usersys.redhat.com> <20200528170128.GN2483@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200528170128.GN2483@worktop.programming.kicks-ass.net> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 28, 2020 at 07:01:28PM +0200 Peter Zijlstra wrote: > On Sun, May 24, 2020 at 10:00:46AM -0400, Phil Auld wrote: > > On Fri, May 22, 2020 at 05:35:24PM -0400 Joel Fernandes wrote: > > > On Fri, May 22, 2020 at 02:59:05PM +0200, Peter Zijlstra wrote: > > > [..] > > > > > > It doens't allow tasks for form their own groups (by for example setting > > > > > > the key to that of another task). > > > > > > > > > > So for this, I was thinking of making the prctl pass in an integer. And 0 > > > > > would mean untagged. Does that sound good to you? > > > > > > > > A TID, I think. If you pass your own TID, you tag yourself as > > > > not-sharing. If you tag yourself with another tasks's TID, you can do > > > > ptrace tests to see if you're allowed to observe their junk. > > > > > > But that would require a bunch of tasks agreeing on which TID to tag with. > > > For example, if 2 tasks tag with each other's TID, then they would have > > > different tags and not share. > > Well, don't do that then ;-) > That was a poorly worded example :) The point I was trying to make was more that one TID of a group (not cgroup!) of tasks is just an arbitrary value. At a single process (or pair rather) level, sure, you can see it as an identifier of whom you want to share with, but even then you have to tag both processes with this. And it has less meaning when the whom you want to share with is mutltiple tasks. > > > What's wrong with passing in an integer instead? In any case, we would do the > > > CAP_SYS_ADMIN check to limit who can do it. > > So the actual permission model can be different depending on how broken > the hardware is. > > > > Also, one thing CGroup interface allows is an external process to set the > > > cookie, so I am wondering if we should use sched_setattr(2) instead of, or in > > > addition to, the prctl(2). That way, we can drop the CGroup interface > > > completely. How do you feel about that? > > > > > > > I think it should be an arbitrary 64bit value, in both interfaces to avoid > > any potential reuse security issues. > > > > I think the cgroup interface could be extended not to be a boolean but take > > the value. With 0 being untagged as now. > > How do you avoid reuse in such a huge space? That just creates yet > another problem for the kernel to keep track of who is who. > The kernel doesn't care or have to track anything. The admin does. At the kernel level it's just matching cookies. Tasks A,B,C all can share core so you give them each A's TID as a cookie. Task A then exits. Now B and C are using essentially a random value. Task D comes along and want to share with B and C. You have to tag it with A's old TID, which has no meaning at this point. And if A's TID ever gets reused. The new A` gets to share too. At some level aren't those still 32bits? > With random u64 numbers, it even becomes hard to determine if you're > sharing at all or not. > > Now, with the current SMT+MDS trainwreck, any sharing is bad because it > allows leaking kernel privates. But under a less severe thread scenario, > say where only user data would be at risk, the ptrace() tests make > sense, but those become really hard with random u64 numbers too. > > What would the purpose of random u64 values be for cgroups? That only > replicates the problem of determining uniqueness there. Then you can get > two cgroups unintentionally sharing because you got lucky. > Seems that would be more flexible for the admin. What if you had two cgroups you wanted to allow to run together? Or a cgroup and a few processes from a different one (say with different quotas or something). I don't have such use cases so I don't feel that strongly but it seemed more flexible and followed the mechanism-in-kernel/policy-in-userspace dictum rather than basing the functionality on the implementation details. Cheers, Phil > Also, fundamentally, we cannot have more threads than TID space, it's a > natural identifier. > --