Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp256587ybr; Fri, 22 May 2020 06:02:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmI/8cbES/3b2t6qROPFdXh1TVIRn5wqfJSAFzNTRjac5atFuErf9I4SZL0P5I6+Jz+hxj X-Received: by 2002:a17:906:a18a:: with SMTP id s10mr7864080ejy.484.1590152545121; Fri, 22 May 2020 06:02:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590152545; cv=none; d=google.com; s=arc-20160816; b=UB+JGqwDSD0CJe67v2FBePXynEazZq2kxhRLysVb5rTmgfxg7DXIJKQY2jjwsEAQ4T pC0Tl0dH6cPx+QWnohqaJcmyiBZG10e+dXR76rc6vvDnl7BPP9c52uMrgZFagUehZQj/ 7bDVy94FwB3atrO1FjiHeBDHBBSvZQ7LpSvWMwgWrCpXDkOyPDSJ/b4hZVZij5El08fJ o8P/GQketbSr8p0Lk5A7qFwA+l6QNXS28l6xep1vCHWIBuRBuf6PhWMCTSczvAwPZ3bX xNDTuzEaNpIpYwoucRd7xVhmZdxhzFoD+P7KeY2Tt7+C1S80qZRtKz8dMAXh6o0d1NoX OOsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=YVfc7SiyzoogxVJFfdDGGh7+zHJ0Lb5CyJPw53pfYto=; b=j5oTIbf2IZ1UYZvVut8x39VHNfdfniUO+tZgBq7ygxOsnItiFb1rwxdUBl8xZ1plh/ 4qdHgAKDIzjNaD7Llky6pdJ+dvRAvCLGSeIEk/xJeLt9qOuIYmwB9PuB+eTyE2LfErs6 G5b8ZQ00TtAaaHmSz7hVgOn6DStWnDKhd4ySSFhsPUBu+ExE1hALepLIzy3q3u+UaQXq sr50iCmLyrZzhDuRDeflvzi6MUoSCHEaM9vGIJ2h9q6vQxxxPsKfnYb79efWYveW6/Yr YecBOq8EuTGyvwjGtShpzQO930RVsmIcFPGKwbDC2tUSC63981BdFMRMp99Eed1gBNgz terQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=rTJKxZcx; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sa3si4936548ejb.733.2020.05.22.06.01.56; Fri, 22 May 2020 06:02: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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=rTJKxZcx; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729822AbgEVM7Y (ORCPT + 99 others); Fri, 22 May 2020 08:59:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729789AbgEVM7X (ORCPT ); Fri, 22 May 2020 08:59:23 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90F26C05BD43 for ; Fri, 22 May 2020 05:59:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=YVfc7SiyzoogxVJFfdDGGh7+zHJ0Lb5CyJPw53pfYto=; b=rTJKxZcx7v5At6aOBDYNjsSJva QDUp0T0VXVpoH4LAUsfb7lgZ5lqA3/K3vs5D1J3+eMwidJQ6qxAVStbmHIAWkXrra6IedH+DUaGYF CjGqIppjkp4YRa5kZXtBkrwtXV84SxGbGtdsaIY1MP3spQ5IJ54ZEDLhXUMSdZbC030E7v4r9A7Jg AlyBZUxi75yt6xsBOOwcGxzsnikPsiRtL1h+5tjlrCf9sHQxTdpYWfiftciM9FN4qQiKwo3TTfiVv 5N3oC6PmG2rZqHiEq191i0pvnVbqaWX9UZ7v4jqfvp2RvdidJewDjU9ntsLMR1mrgGay51UmjWvfW 6FjWV9Cw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jc7GW-0001V8-Er; Fri, 22 May 2020 12:59:08 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 6BD203062C2; Fri, 22 May 2020 14:59:05 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 5A160201479BB; Fri, 22 May 2020 14:59:05 +0200 (CEST) Date: Fri, 22 May 2020 14:59:05 +0200 From: Peter Zijlstra To: Joel Fernandes Cc: 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, kerrnel@google.com, Phil Auld , 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: <20200522125905.GM325280@hirez.programming.kicks-ass.net> References: <20200520222642.70679-1-joel@joelfernandes.org> <20200521085122.GF325280@hirez.programming.kicks-ass.net> <20200521134705.GA140701@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200521134705.GA140701@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 21, 2020 at 09:47:05AM -0400, Joel Fernandes wrote: > Hi Peter, > Thanks for the comments. > > On Thu, May 21, 2020 at 10:51:22AM +0200, Peter Zijlstra wrote: > > On Wed, May 20, 2020 at 06:26:42PM -0400, Joel Fernandes (Google) wrote: > > > Add a per-thread core scheduling interface which allows a thread to tag > > > itself and enable core scheduling. Based on discussion at OSPM with > > > maintainers, we propose a prctl(2) interface accepting values of 0 or 1. > > > 1 - enable core scheduling for the task. > > > 0 - disable core scheduling for the task. > > > > Yeah, so this is a terrible interface :-) > > I tried to keep it simple. You are right, lets make it better. > > > 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. > > It is also horribly ill defined what it means to 'enable', with whoem > > is it allows to share a core. > > I couldn't parse this. Do you mean "enabling coresched does not make sense if > we don't specify whom to share the core with?" As a corrolary yes. I mostly meant that a blanket 'enable' doesn't specify a 'who' you're sharing your bits with. > > OK, so cgroup always wins; is why is that a good thing? > > I was just trying to respect the functionality of the CGroup patch in the > coresched series, after all a gentleman named Peter Zijlstra wrote that > patch ;-) ;-). Yeah, but I think that same guy said that that was a shit interface and only hacked up because it was easy :-) > More seriously, the reason I did it this way is the prctl-tagging is a bit > incompatible with CGroup tagging: > > 1. What happens if 2 tasks are in a tagged CGroup and one of them changes > their cookie through prctl? Do they still remain in the tagged CGroup but are > now going to not trust each other? Do they get removed from the CGroup? This > is why I made the prctl fail with -EBUSY in such cases. > > 2. What happens if 2 tagged tasks with different cookies are added to a > tagged CGroup? Do we fail the addition of the tasks to the group, or do we > override their cookie (like I'm doing)? For #2 I think I prefer failure. But having the rationale spelled out in documentation (man-pages for example) is important. > > > ChromeOS will use core-scheduling to securely enable hyperthreading. > > > This cuts down the keypress latency in Google docs from 150ms to 50ms > > > while improving the camera streaming frame rate by ~3%. > > > > It doesn't consider permissions. > > > > Basically, with the way you guys use it, it should be a CAP_SYS_ADMIN > > only to enable core-sched. > > True, we were relying on the seccomp sandboxing in ChromeOS to protect the > prctl but you're right and I fixed it for next revision. With the TID idea above you get the ptrace tests.