Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1432795ybk; Thu, 21 May 2020 06:50:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNCEgKsxRvTbSJgj9PDf5bBGRX9xQMUKA1M9XrWOmX24ICJ4XJqcDNN7C5FQhd0F4L3jqD X-Received: by 2002:a17:906:d98:: with SMTP id m24mr3437307eji.553.1590069010358; Thu, 21 May 2020 06:50:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590069010; cv=none; d=google.com; s=arc-20160816; b=gT7K23i1NxDHoNLj+oxpLqJad1RRp6S7Bso0u8sGCQzM5islk0dioJCgSINaYm+/tZ hjGlG89YacUihgKvWYMH/DwZH5uT9NUCLpoZdHV22ppFqHr63w/xzG7mNHInvW3EFmJh DsJ+eLYmZ2mqD6nFz1IdU13ai0kUj7LX2Z54ROyg0AlzZBxj/H8bfm7XNLEg+ulhgmjU 6ZWQutwpWLqd9htykdP6ywiIz++KRAx9ka/6h65MxPE1beg17p9WUqHVWCKtD8USS213 StAogKj66Bttd2eW7zV2dTffF6Turk9Gv/HuLgPBdtKeHxVXCl8wdsN4UccPsn26OISO 4GYw== 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=44FYlkUrt8i90UVdJutZuc7RtdPIilkJHRfkNsLzvz8=; b=fp7Ft9ozaaMIerQKc52SD/CSI4TC6SizCWBplSN20HYRMFHUaQ4paQLwwJ8Pv8Q/Jd eHMSNxVvLKv+QlDXlh6Ero/X9EPw2W8J7ZkIWll4LV07fRFx6nRwW8C8IdKKcyOvcOT0 WlfIjK/rFfUWTXSdv496pHN64fuOAAWqq/FrLdWoZLdaEGhGpxAMR0lwag141096KH5D PBWn5k2NfCm+lOfXxlzjl/DZyh3lohVXtdqCnE1nZ4G5XQEBdarQ3GL+0BwzGrxp1cd9 qwndZ2iaeRZ0aq4rdgj2pIpz6hCQ0fjCdReRN1/a4rL+KJ+QNVZhHMbN+mxoyZdsh9Pf ie2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=P+T2oevs; 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 b25si3039396edt.290.2020.05.21.06.49.45; Thu, 21 May 2020 06:50:10 -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=@joelfernandes.org header.s=google header.b=P+T2oevs; 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 S1729626AbgEUNrK (ORCPT + 99 others); Thu, 21 May 2020 09:47:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729431AbgEUNrI (ORCPT ); Thu, 21 May 2020 09:47:08 -0400 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F87FC061A0E for ; Thu, 21 May 2020 06:47:08 -0700 (PDT) Received: by mail-qt1-x844.google.com with SMTP id z18so5503819qto.2 for ; Thu, 21 May 2020 06:47:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=44FYlkUrt8i90UVdJutZuc7RtdPIilkJHRfkNsLzvz8=; b=P+T2oevsrMwt9Bij/ihxWdOK8KwWgzy8u/kkA0uyB1t4fxz8j7sEd+WZmQ3/qGW3vN 4ijlnbA8I678sfzZbNUQsycLFzDdAmEkXA1kpZdK1DWvladeb6rGOd31JzlAPiEcwlL7 IpdP4mo0Lsoyu3jqWkn6qhcQKg6ltm6tTjIb8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=44FYlkUrt8i90UVdJutZuc7RtdPIilkJHRfkNsLzvz8=; b=lfxhUAxLeem6+qEay8Qc+StFmh3HIkQDo1BMZ7UONSixLPgaJcvUdNUETGaZOBd5C4 Yqy+cm70RKc8pC9GYHdRggCGXWtb9GBa9+GLMlzvHANJwUbfLSFYA+ucQI3YKSpucx5A S/LS63ywMrssdJzqZ6dHE7HW8FWNSBjz6Q7lPj3mDvVlij+TVEpE+XRJBHcUbaIj7VJd TbEg7v7h7QJwlFnPKMwlsjfwQZPeynOpFaqhiqdNl/nwagh0JabnqGu9lXtH25IvK9U6 WV5xJXvt9HfXta707Tg7OO9+bm5qSZooo2DwpmkMttnGPh4hjfg3DCuKCUOxcmOQclxZ YQQw== X-Gm-Message-State: AOAM531hpJdxaU9CqmSOwpnSLpYGo8g6pG+y9mFprET0ugwUifoz8Wdy zFt/GU5kWPp9NZP9x7f7zUwCWg== X-Received: by 2002:ac8:6b84:: with SMTP id z4mr10903446qts.227.1590068826804; Thu, 21 May 2020 06:47:06 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id m6sm4794876qkc.4.2020.05.21.06.47.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 06:47:06 -0700 (PDT) Date: Thu, 21 May 2020 09:47:05 -0400 From: Joel Fernandes To: Peter Zijlstra 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: <20200521134705.GA140701@google.com> References: <20200520222642.70679-1-joel@joelfernandes.org> <20200521085122.GF325280@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200521085122.GF325280@hirez.programming.kicks-ass.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > 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?" > > Special cases: > > > (1) > > The core-scheduling patchset contains a CGroup interface as well. In > > order for us to respect users of that interface, we avoid overriding the > > tag if a task was CGroup-tagged because the task becomes inconsistent > > with the CGroup tag. Instead return -EBUSY. > > > > (2) > > If a task is prctl-tagged, allow the CGroup interface to override > > the task's tag. > > 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 ;-) ;-). 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)? > > 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. > That also means we should very much default to disable. This is how it is already. thanks, - Joel